This is strange. I have this variable set up in Variables+History:
Entity ID: binary_sensor.espresense_aktivert_deaktivert
Friendly name: ESPresense aktivert/deaktivert
It basically decides if other automations should act on ESPresense triggers or not. So I have this condition in those other automations:
- condition: state
entity_id: binary_sensor.espresense_aktivert_deaktivert
state: "on"
If it’s on they unlock the door, if it’s off they don’t. That works as it should. The problem is when I want to turn on and off the state of the binary sensor, done with Aeotec The Button. I need to know if I’m turning it on or off without looking at the GUI, so I have set up separate automations for turning it on and off with long presses of the button, which also triggers a signal (the lock unlocking twice for off and once for on. This is the automations:
alias: Aktivere ESPresense med The button
description: Slå på ESPresense
trigger:
- platform: device
device_id: e7a66c58543543b2bc7008490940ceb1
domain: zwave_js
type: event.value_notification.central_scene
property: scene
property_key: "001"
endpoint: 0
command_class: 91
subtype: Endpoint 0 Scene 001
value: 2
condition:
- condition: state
entity_id: binary_sensor.espresense_aktivert_deaktivert
state: "off"
enabled: true
action:
- service: variable.update_binary_sensor
target:
entity_id: binary_sensor.espresense_aktivert_deaktivert
data:
value: "true"
replace_attributes: false
enabled: true
- service: lock.unlock
data:
entity_id: lock.mastiff_lock
enabled: true
alias: Deaktivere ESPresense med The button og GUI-knapp
description: Slå avESPresense
trigger:
- platform: device
device_id: e7a66c58543543b2bc7008490940ceb1
domain: zwave_js
type: event.value_notification.central_scene
property: scene
property_key: "001"
endpoint: 0
command_class: 91
subtype: Endpoint 0 Scene 001
value: 2
condition:
- condition: state
entity_id: binary_sensor.espresense_aktivert_deaktivert
state: "on"
enabled: true
action:
- service: variable.update_binary_sensor
target:
entity_id: binary_sensor.espresense_aktivert_deaktivert
data:
value: "false"
replace_attributes: false
enabled: true
- service: lock.unlock
data:
entity_id: lock.mastiff_lock
enabled: true
- service: lock.unlock
data:
entity_id: lock.mastiff_lock
enabled: true
For some strange reason turning it works from off to on works, while turning it from on to off does not, even if the automation shows that both triggers, and the right condition fails. Can anybody see what I’m doing wrong here?