strange-v / ha_deck

Config-driven Home Assistant dashboard (built on top of ESPHome)
MIT License
150 stars 42 forks source link

Question - how to push back light state into display? #5

Closed ronaldt80 closed 9 months ago

ronaldt80 commented 9 months ago

Hi, thanks for this great project.

I successfully installed your software on my wt32-sc01-plus. There was a small hiccup with the platformio options (seems no longer possible to define the board_upload.flash_size?) - will prep a pull request.

Not sure however how to update the button on the display to match the light state if turned on through a regular button. Do you have example code for this?

I added the light state as follows:

sensor:
  - platform: homeassistant
    id: light_state
    entity_id: light.livingroom_ceiling

And was hoping to tweak the button as follows:

        - type: button
          position: 8, 216
          text: Dummy
          icon: 󰝩
          toggle: true
          enabled: return true;
          checked: |-
            return id(light_state).current_values.is_on();
          on_turn_on:
            - homeassistant.service:
                service: light.turn_on
                data:
                  entity_id: light.livingroom_ceiling
          on_turn_off:
            - homeassistant.service:
                service: light.turn_off
                data:
                  entity_id: light.livingroom_ceiling
strange-v commented 9 months ago

Yes, the way to set a flash size is changed. Thanks, I'll check the PR soon.

Regarding the light state, you can use something like this:

checked: |-
            return id(light_state).state == "on";

I doubt the sensor supports is_on method.

ronaldt80 commented 9 months ago

Ok.. should probably have realized directly that we need a binary sensor. I managed to get it working as follows:

binary_sensor:
  - platform: homeassistant
    id: light_state
    entity_id: light.livingroom_ceiling
- type: button
          position: 8, 216
          text: Lights
          icon: 󰝩
          toggle: true
          enabled: return true;
          checked: |-
            return id(light_state).state;
          on_turn_on:
            - homeassistant.service:
                service: light.turn_on
                data:
                  entity_id: light.livingroom_ceiling
          on_turn_off:
            - homeassistant.service:
                service: light.turn_off
                data:
                  entity_id: light.livingroom_ceiling
lukedoomer commented 7 months ago

Yes, the way to set a flash size is changed. Thanks, I'll check the PR soon.

Regarding the light state, you can use something like this:

checked: |-
            return id(light_state).state == "on";

I doubt the sensor supports is_on method.

@strange-v the device lost the states if we switch the current screen to another then switch back

how to get over it?

strange-v commented 7 months ago

@lukedoomer, please open a new issue and provide full configuration.