Home Assistant Deck component (HA Deck)

It doesn’t seem to be related to the HA platform. Changing the screen seems to cause the issue in my setup:

I have a button “Licht” on my main screen. It’s should be checked, if any light is switched on.

        # C2: Button Licht
        - type: button
          position: 126, 216
          text: "Licht"
          icon: 󰝩
          enabled: return true;
          checked: |-
            return id(**licht_kontrolle**).state;
          on_click:
            lambda: |- 
                id(deck).switch_screen("$SCREEN_LICHT");

In my scenario, id(licht_kontrolle).state is true. The button “Licht” is checked.

After switching to another screen e.g. “Licht” and going back to the main screen, Button “Light” is unchecked. The state of licht_kontrolle has not been changed at all.

Updating the binary sensor id(licht_kontrolle) checks the button on the main screen again.

My feeling is, that the state of licht_kontrolle is lost after switching the screen and not reloaded.

  1. Enable web UI and add a template sensor
binary_sensor:
- platform: template
  id: test
  name: test
  lambda: return id(licht_kontrolle).state;
  1. Open the web UI, reproduce the bug performing screen change, or whatever is needed.
  2. Check the state of the test sensor

If the state doesn’t correlate with the current button state on the screen - it’s a bug in the component rendering. If the binary sensor changed its state but shouldn’t - I don’t know what is happening. Maybe check that you have enough free RAM.

Nice approach.
The test sensor is ok. It stays “on” after switching the screen, but the button gets unchecked.

|23:50:58|[D]|[homeassistant.binary_sensor:026]|'light.licht_wohnzimmer_z2m': Got state ON|
| --- | --- | --- | --- |
|23:50:58|[D]|[homeassistant.binary_sensor:026]|'binary_sensor.licht_kontrolle': Got state ON|
|23:50:58|[D]|[binary_sensor:036]|'licht_kontrolle': Sending state ON|
|23:50:58|[D]|[binary_sensor:036]|'test': Sending state ON|

I solved it:

        # C2: Button Licht
        - type: button
          position: 126, 216
          text: "Licht"
          icon: 󰝩
          toggle: true   #added
          enabled: return true;
          checked: |-
            return id(licht_kontrolle).state;
          on_turn_off: #added
            lambda: |- 
                id(deck).switch_screen("$SCREEN_LICHT");
          on_turn_on: # added
            lambda: |- 
                id(deck).switch_screen("$SCREEN_LICHT");
          # on_click:
          #  lambda: |- 
          #     id(deck).switch_screen("$SCREEN_LICHT");

toggle: true needs to be active, but the screen is crashing when “on_click” is used.
So I switched to on_turn_off: and on_turn_on:

Now ist works.