arun2118
(Arun2118)
December 28, 2017, 5:04am
1
I don’t see how to post code keeping the correct indents…wait i think i got it. First hit preformatted text, then blockquotes.
I want to send a MQTT msg every 10 mins when my aquarium temp or sump temp falls out of a range and not send it when its not. The device that’s monitoring the temps is capable of sounding a alarm via mqtt msg.
This is the automation part so far, it sends a text msg to my phone… Actually just tested and its not working
- alias: 'Temp Alarm'
trigger:
platform: numeric_state
entity_id: sensor.tank_temp
above: 79
below: 75
action:
- service: notify.Sms_alert
data:
message: 'Aquarium Temp is {{states.sensor.tank_temp.state}} and Sump is {{states.sensor.sump_temp.state}}'
target:
- +1xxxxxxxxxx
Is there a better way then something like this “How can repeat this automation? - #2 by PhyberApex ”, that process just seems long.
The part i plan to adapt is:
automation:
- alias: 'Porta casa de banho'
trigger:
platform: state
entity_id: binary_sensor.porta_casa_de_banho
state: 'on'
for:
seconds: 20
action:
- service: script.stuff
script:
stuff:
sequence:
- condition: state
entity_id: binary_sensor.porta_casa_de_banho
state: 'on'
- service: shell_command.play_wc
- service: script.stuff_loop
stuff_loop:
sequence:
- condition: state
entity_id: binary_sensor.porta_casa_de_banho
state: 'on'
- delay:
seconds: 20
- service: script.stuff
RobDYI
December 28, 2017, 6:00am
2
I would use time every 10 mins as the trigger and the temps as the condition and your script as the action.
1 Like
arun2118
(Arun2118)
December 28, 2017, 6:16am
3
Would that mean if temp falls out of range, then I may need to wait 10 mins before hearing the first alert?
btw…
is this the correct way to call the action
- alias: 'Temp Alarm'
trigger:
platform: numeric_state
entity_id: sensor.tank_temp
above: 79
below: 75
action:
RobDYI
December 28, 2017, 6:40am
4
You can add the state change of the “alarm via mqtt msg” as another trigger to get a instant notification.
Hi,
I have installed a window sensor and I’d like to send repeated notifications when the window is open for a certain amount of time (currently 10 minutes).
I have an automation that calls a script after the window is open for 10 minutes.
The script generates a single notification message and then turns on another (previously inactive) automation that should send repeated notifications until the window is closed again:
alias: 'Bedroom Window Open: Send Repeated alerts'
hide_entity: True
ini…
arun2118
(Arun2118)
December 28, 2017, 7:08am
5
I somewhat followed that link, no scripts, i put this in automations which i believe should yield a notification…
- alias: 'Temp Alarm 2 test'
trigger:
platform: time
minutes: '/2'
condition:
- condition: numeric_state
entity_id: sensor.tank_temp
above: 79
below: 75
action:
- service: notify.Sms_alert
data:
message: 'Aquarium Temp is {{states.sensor.tank_temp.state}} and Sump is {{states.sensor.sump_temp.state}}'
target:
- +1xxxxxxxxxx
could the issue be the sensor is read as 73.39 and i’m only putting 75 for instance… it should be
condition:
- condition: numeric_state
entity_id: sensor.tank_temp
above: 79.00
below: 75.00
RobDYI
December 28, 2017, 3:49pm
6
You can optionally use a value_template to process the value of the state before testing it. This should change it to an integer.
condition:
condition: numeric_state
entity_id: sensor.temperature
above: 17
below: 25
# If your sensor value needs to be adjusted
value_template: {{ int(state.state) }}
You can test the automation in the state dev page by going to the sensor and changing the temp to see if it triggers.
- alias: 'Temp Alarm 2 test'
trigger:
- platform: time
minutes: '/2'
- platform: numeric_state
entity_id: sensor.tank_temp
value_template: {{ int(state.state) }}
# Optional
# value_template: '{{ int(states.sensor.tank_temp.state) }}'
above: 79
below: 75
condition:
- condition: numeric_state
entity_id: sensor.tank_temp
above: 79
below: 75
value_template: {{ int(state.state) }}
action:
- service: notify.Sms_alert
data:
message: 'Aquarium Temp is {{states.sensor.tank_temp.state}} and Sump is {{states.sensor.sump_temp.state}}'
target:
- +1xxxxxxxxxx
arun2118
(Arun2118)
December 28, 2017, 5:56pm
7
Error “invalid key: “OrderedDict([(‘int(state.state)’, None)])”
in “/home/homeassistant/.homeassistant/automations.yaml”, line 36, column 0”
RobDYI
December 28, 2017, 9:11pm
8
does it work without that line?
did you try to use this commented line?
# value_template: ‘{{ int(states.sensor.tank_temp.state) }}’
did you try above: 79.00 below: 75.00 ?
arun2118
(Arun2118)
December 29, 2017, 3:41am
9
value_template: ‘{{ int(states.sensor.tank_temp.state) }}
gives me “Template error: UndefinedError: ‘int’ is undefined”
and this also does not work.
- alias: 'Temp Alarm 2 test'
trigger:
- platform: time
seconds: '/5'
- platform: numeric_state
entity_id: sensor.tank_temp
# value_template: {{ int(state.state) }}
# Optional
# value_template: '{{ int(states.sensor.tank_temp.state) }}'
above: 79.00
below: 75.00
condition:
- condition: numeric_state
entity_id: sensor.tank_temp
above: 79.00
below: 75.00
#value_template: {{ int(state.state) }}
action:
I have decided to edit the code on controller “esp9266” to sound alarm instead as this would be more reliable also.
Thank you for your help.