I’m trying to setup an IMAP event trigger. When a new email from a specific recipient with a number X in the body comes in, activate my water heater for X minutes. The email body has only the number in it.
from: [email protected]
subject: Water Heater On
date: Mon, 7 Mar 2022 01:08:54 -0800
body: 4
and I successfully see the sensor state update with the correct values for each email being received./
When I setup my automation though, I can’t seem to be able to get the event to trigger when a number X larger than 0 comes in. the event never gets triggered - even though under developer tools I can see the value for sensor.water_heater_manual_time gets updated correctly. This is my automation:
alias: Set water heater on - email time
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.water_heater_manual_time
above: '0'
condition: []
action:
- type: turn_on
device_id: XXX (I deleted this for this post)
entity_id: switch.water_heater
domain: switch
- delay: >-
{{ '00:{:02}:00'.format(states('sensor.water_heater_manual_time') | int)
}}
- type: turn_off
device_id: XXX (I deleted this for this post)
entity_id: switch.water_heater
domain: switch
mode: single
Make sure the sensor goes to zero between setting emails. If the sensor value changes from 4 to 5 without passing through a 0 state, the Numeric State trigger will never reset to a “listening” state.
In gmail you should be able to set an automation to delete the email after a couple minutes or you could automate a follow up email to reset the sensor to 0.
Hi, thanks for the reply!
I actually tried that, it didnt help. The problem seems to be that it never gets triggered to begin with (I followed the automation trace and it looks like it never gets triggered even when i start from zero)
Hello. Im new with HA, and trying to make this solution work. I have integrated IMAP service (IMAP - Home Assistant) and added my gmail account. I cant seem to find the way to integrate the script above to trigger my smart socket to turn on once I receive an email. Any help will be appreciated.
Please post the YAML configuration of the automation, screen shots of the UI editor collapse all the information. You can access it by clicking the menu button at the top right in the automation editor and choose “Edit in YAML”
Copy everything from the YAML editor then copy/paste it into a post. Be sure to format it properly by adding 3 back-ticks (```) on the lines above and below the pasted configuration
From the error message it looks like you have attempted to use a Numeric State trigger or condition without specifying an above or below value.
That history graph doesn’t look right for the normal ways IMAP sensors work. I would expect the graph value to match the state value. I think your sensor is either misconfigured or you may be running up against a reporting limited like that mentioned in the IMAP: Troubleshooting.