I am trying to set up an automation for a freezer door so that if the door is open for more than a specified time, it will trigger an alarm, but if closed before that time, does not trigger the alarm. (The alarm device is already set up and working, it also goes off if a water sensor in the basement senses water.) I have it set up in config.yaml as follows:
- id: '1598911158887'
alias: freezer door open too long
description: freezer door open too long
trigger:
- entity_id: binary_sensor.freezer_door
for: 00:00:30
from: 'OFF'
platform: state
to: 'ON'
condition: []
action:
- device_id: 917e9ebbae3a44148d8716f7faecae93
domain: switch
entity_id: switch.water_detector_alarm_switch
type: turn_on
mode: single
I can get the alarm to go off on door opening for <>secs using mqtt but then the alarm goes off whether the door has been closed or not, so thatās not useful. I canāt figure out a way, using mqtt, to keep it from alarming if the door has been closed before the timer expires. If I go to console on the Sonoff rf-wifi bridge, I can see the correct messages being sent on door open and close, so the problem seems to be in my code in hass. Iāve found instances on youtube that do exactly what I want using the binary sensor method, so Iāve replicated them exactly (as far as I can tell) yet they still donāt work.
Set them to lower case now (pretty sure Iāve tried that as Iāve seen it both ways, but for the sake of argument, lower case it is.)
Iāve looked in āDev Toolsā and the binary sensor for that has never changed state, and I can see that it is real time, seems this might be the root of my problem. Now, how to fix it?
From console on rf-wifi bridge, looks like correct messages are being sent.
Roger that, I only have one binary sensor Iām dealing with right now but I do have others, so if I get this working thatāll be useful info for when I add the other devices.
Okay, I did it in a rush and Iām nowhere near a workstation, Iāve edited it again.
Each sensor should list under its own key. freezer_door: in this case
Edit: we donāt get many seeding machine officianados on this forum
Iāve corrected it as you suggest above, in doing a config check, I get
Error loading /config/configuration.yaml: mapping values are not allowed here
in ā/config/configuration.yamlā, line 41, column 17
which appears to be the colon at the end of the line of
Invalid config for [binary_sensor.mqtt]: [sensors] is an invalid option for [binary_sensor.mqtt]. Check: binary_sensor.mqtt->sensors. (See ?, line ?).
I did notice that the doc referenced says āplatform: templateā so Iām guessing that is a valid option for platofrm: template but not for platform: mqtt?
Do you see how each sensor has itās own header (key) ?
So it can be identified from the previous and the following.
The config checker, āsometimesā highlights something just before or just after the actual offending bit of code.
Tinkās offered example had indents āafterā the sensor entity, yours doesnāt
OK, I tried that, but I am not using templates, correct? I now have a whole boatload of errors on config check about dictionaries and dictionary values. I can list them if thatāll help. I am not a programmer by any means; Iāve been doing network technician/engineer stuff since ~1995 so there are things I understand and things I donāt. Programming is one that I donāt, despite having tried countless times over the years. Iāve seen how people do things using templates, but since I donāt āgetā how they work, Iāve avoided them.
Correct your platform would be mqtt instead
This was just an example, to show you the format and the required indenting.
Treat @Tinkerer 's as the definitive
You donāt need (or want as it will cause errors ) the āsensors:ā bit. Thatās only for template binary sensors. mqtt binary sensors are defined individually.
I donāt know if youāve tried this iteration yet but try this: