Hi Guy, I am trying to setup an imap_email_content sensor to show previous ON or OFF state if email not regconised, Can you guys help me out with the script. I have try {{ (states.sensor.wan_0.state) }} but it will still show ‘unkown’ anyway since the present state is unkown.
here is what i’ve got in configuration.taml (it works fine without the {% else %} but get an “unknown” if it does not fall within those two subject.
sensor:
- platform: imap_email_content
server: imap.test.com
name: wan_0
port: 993
username: [email protected]
password: testpass
senders:
- [email protected]
value_template: >-
{% if 'WAN(0) Connection WAN(0) link down' in subject %}
off
{% elif 'WAN(0) Connection WAN was restored' in subject %}
on
{% else %}
# what to put here for 'else keep previous on or off state'
{% endif %}