A virtual PushButtonSwitchGroup (PBSG) device:
-
Behaves like a keypad with multiple buttons, where:
-
Only one button can be active at any time.
-
An optional default button is activated if no other button is active.
-
-
Each button has a corresponding VswWithToggle child devices.
-
The state of the PBSG and its Child devices is continuously reconciled.
-
PBSG methods include
activate(button),deactivate(button),push(buttonNumber). -
Child devices support
on(),off()andpush()|toggle().
-
A PBSG is a Hubitat-compatible virtual device where …
- buttons
(required) -
A list of button names.
- defaultButton
(optional) -
A button (from the buttons list) that becomes active if no other PBSG button is active.
-
Only one button is active at any time.
-
The defaultButton (if specified) is activated when no other button is active.
-
One child VSW exists per button.
-
Child VSW state is updated when the PBSG state changes.
-
PBSG state is updated when child VSWs are turned on or off.
-
A PBSG realizes a mutually-exclusive collection of buttons and corresponding switches.
-
Use cases include: Managing Hubitat modes, Managing per-room scenes, etc.
-
The PBSG can support Hubitat’s
pushableinterface and concurrently facilitate Alexa integration (which is limited to turn on / turn off).
The structure of a PBSG can be defined:
-
Using the device drilldown page in the Hubitat GUI.
-
In code using available API calls.
buttons |
An ArrayList of all the buttons managed by the PBSG |
|---|---|
active |
The button that is currently 'on' |
dflt |
The button that is turned 'on' if active becomes null |
lifo |
The list of 'off' buttons where the most recently |
PBSG state (issued for any state change):
[
== MINIMAL/COMPREHENSIVE SUMMARY OF STATE
active: String or null - 'on' button
lifo: ArrayList - 'off' buttons
dflt: String or null - 'dflt' button
== FOR `PushableButton` CAPABILITY
numberOfButtons: Integer - N
pushed: Integer - Position 1..N
== FOR CONVENIENCE
buttons: ArrayList - 'all' buttons
buttonToPosition: Map - button name → 1..N
display: String - Log-friendly state
]
PushableButton (issued when cited fields change):
[
numberOfButtons: Integer - N
pushed: Integer - Position 1..N
]
-
Requests on the PBSG itself (from the parent, from events)
-
Actions on the VSWs (fielded by the parent)
-
No entries survive a hub reboot; so, state must be rebuilt.
-
Each PBSG has a Concurrent State Map (csm) stored in perPbsgState at key device.idAsLong.
-
Concurrency extends to operations on this inner Map.
-
To abbreviate 'concurrentState', 'ccs' is used.
-
Treatment wrt the following is TBD:
-
|
Note
|
The ConcurrentHashMap perPbsgState is used in lieu of state or atomicState.
|