simple-thermostat icon indicating copy to clipboard operation
simple-thermostat copied to clipboard

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

Open ed-holland opened this issue 2 years ago • 5 comments

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

  • OS: Windos
  • Browser: Chrome
  • Simple Thermostat version from browser console: latest
  • Home Assistant version: 2021.9.7

ed-holland avatar Sep 26 '21 07:09 ed-holland

I have the same issue

DenisBY avatar Dec 03 '21 16:12 DenisBY

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?

Strixx76 avatar Feb 19 '22 12:02 Strixx76

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 avatar Jan 25 '23 08:01 alienatedsec

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

alienatedsec avatar Jan 25 '23 11:01 alienatedsec

@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

alienatedsec avatar Jan 27 '23 11:01 alienatedsec