I have a door sensor installed on my dogs door hatch to go to the backyard. I want to use that to toggle a binary sensor that i can use to tell if my dog has gone through the hatch and is on the backyard or if it has returned. Ideally as a switch as well so i can re-sync the status as needed. Any ideas suggestions to do this? can i toggle a switch template everytime the hatch sensor moves from on to off?
thank you. i am having a problem though. I can see the “binary_sensor.dog_hatch” state moving from off to on in the states page. But for some reason it doesnt trigger the automation. Here is the full code.
binary_sensor:
- platform: mqtt
name: "Dog hatch"
state_topic: "rtl_433/Generic-Remote/23868/cmd"
payload_off: "14"
payload_on: "10"
device_class: opening
input_boolean:
dog_in_yard:
name: Dog In Yard
icon: mdi:dog
... in automations.yaml file...
- alias: Dog status
trigger:
platform: state
entity_id: binary_sensor.dog_hatch
to: "on"
action:
service: input_boolean.toggle
entity_id: input_boolean.dog_in_yard
binary_sensor.dog_hatch works well on its own as i can monitor it in the states page from off to on. I can also manually trigger the automation from the automations menu and it toggles the input_boolean successfully. So it looks like the “on” state change is never recognized by the trigger
Do you think that the device_class has anything to do with it?