nervetattoo / simple-thermostat

A different take on the thermostat card for Home Assistant ♨️
MIT License
743 stars 112 forks source link

Header Toggle is not showing real state / Action is not executed #276

Open ed-holland opened 3 years ago

ed-holland commented 3 years ago

Describe the bug I'm using a header toggle with a lock entity (provided by a tuya TH213 device). The action to enable the lock, does not lock. If i lock using the lock-entity, it does not show the status

To Reproduce

  1. Click on Toggle to change state
  2. Lock entity does not change
  3. Use entity to lock
  4. Toggle does not change

Expected behavior Toggle to follow lock status

type: custom:simple-thermostat
entity: climate.og_bath_parents
step_size: '1'
decimals: '0'
control:
  preset:
    Home: true
    Smart: false
    Sleep: true
    Away: true
  hvac:
    heat:
      name: false
    off:
      name: false
sensors:
  - attribute: external_temperature
    name: Floor
    unit: °C
    decimals: 1
  - attribute: heating_switch_state
    name: Heating
  - entity: lock.og_bath_parents
    name: Locked
header:
  toggle:
    entity: lock.og_bath_parents
    name: Lock
layout:
  mode:
    names: true
    icons: true
    headings: false
hide:
  state: true

Screenshots image

Browser

DenisBY commented 2 years ago

I have the same issue

Strixx76 commented 2 years ago

I have Tuya TS0601 thermostats and I would also like to able to switch the child lock on and off. Maybe the best way to solve it would be to have a choice to add an lock-entity instead of an toggle/switch in the header?

alienatedsec commented 1 year ago

It sounds like a great idea - I have the same which seems to be annoying as cannot be enabled.

image

@ed-holland I would not call it a bug but an enhancement to define what a toggle could do. Let's say when it's on, the specific state is set. I am not sure if this was resolved since it was raised

image

@nervetattoo maybe you could help?

alienatedsec commented 1 year ago

I got this sorted now. Created both: helper (input_boolean - already mentioned in Readme) and automation to publish MQTT when it's toggled.

alienatedsec commented 1 year ago

@Strixx76 @DenisBY @ed-holland if you are interested about automations to address the following:

  • Click on Toggle to change state
  • Lock entity does not change

Create input_boolean helper and automation to publish via MQTT when it is toggled

  • Use entity to lock
  • Toggle does not change

Add another trigger to the above automation to update the toggle with input_boolean.turn_off and input_boolean.turn_on services. You just need to workout your payloads and change some naming.

Here it is:

alias: childlock_thermostat
description: ""
trigger:
  - platform: state
    entity_id:
      - input_boolean.childlock
    to: "off"
    id: "1"
  - platform: state
    entity_id:
      - input_boolean.childlock
    to: "on"
    id: "2"
  - platform: state
    entity_id:
      - lock.thermostat_bedroom_child_lock
    to: unlocked
    id: "3"
  - platform: state
    entity_id:
      - lock.thermostat_bedroom_child_lock
    to: locked
    id: "4"
condition: []
action:
  - if:
      - condition: trigger
        id: "1"
    then:
      - service: mqtt.publish
        data:
          topic: zigbee2mqtt/Thermostat_Bedroom/set
          payload: "{\"child_lock\": \"UNLOCK\"}"
          qos: "0"
  - if:
      - condition: trigger
        id: "2"
    then:
      - service: mqtt.publish
        data:
          payload: "{\"child_lock\": \"LOCK\"}"
          topic: zigbee2mqtt/Thermostat_Bedroom/set
          qos: "0"
  - if:
      - condition: trigger
        id: "3"
    then:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.childlock
    else: []
  - if:
      - condition: trigger
        id: "4"
    then:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.childlock
    else: []
mode: single