Here’s my scenario. I suspect this will happen other places.
I have a custom presentation with a dashboard
containing a pushButton
that cycles a string attribute named status
. Think of the pull-chain on a ceiling fan. Fast-Medium-Slow-Off repeat.
It’s my understanding that alternatives
does not have to cover every possible value. If there’s a key
match, the alternatives value
is used in its place. Most people probably use all or none for alternatives
, but what happens if you omit some keys? I’m observing a weird ‘latching’ behavior. As I’m advancing through the keys, after the first alternatives
match occurs, my status
attribute won’t update to anything that isn’t in alternatives
. emit_event() fires with the correct value, but it’s ignored-- even if I force state_change = true
.
So, why am I doing this? alternatives
allows you to control the active/inactive appearance of the icon and button. By including a single generic ‘Off’/inactive in alternatives
, I can display all other states programmatically. At least that’s what I was expecting. In reality, the ‘Off’ works like a pothole. Once you get stuck, you can never escape. I display the same status in detailView
, so I know my code works. The actual state is stored in a Lua variable. This is a display issue.
capability
attributes:
status:
schema:
type: object
additionalProperties: false
properties:
value:
type: string
commands:
doAction:
name: doAction
arguments:
- name: action
optional: true
schema:
type: string
presentation
dashboard:
states:
- label: '{{status.value}}'
alternatives:
- key: 'Off'
value: 'Off'
type: inactive
actions:
- displayType: pushButton
pushButton:
command: doAction