alias: test ping
description: test ping
trigger:
- platform: state
entity_id:
- binary_sensor.192_168_1_4
- binary_sensor.192_168_1_5
from: "on"
to: "off"
- platform: state
entity_id:
- binary_sensor.192_168_1_4
- binary_sensor.192_168_1_5
from: "off"
to: "on"
condition: []
action:
- action: notify.me_gmail_com
metadata: {}
data:
message: >-
Connection to {{ trigger.to_state.attributes.friendly_name }} is now {{
trigger.to_state.state }} at {{now().strftime("%Y-%m-%d %H:%M:%S")}}
title: >-
Connection to {{ trigger.to_state.attributes.friendly_name }} is now {{
trigger.to_state.state }} at {{now().strftime("%Y-%m-%d %H:%M:%S")}}
target: [email protected]
mode: single
and it works great but!!.. this is what it creates:
Connection to 192.168.1.4 Access point in Shed is now off at 2024-09-27 19:04:20
What i would like is to ensure that instead of “off” and “on” status I get a “Connected” or “Disconnected” text in the email?
So basically what the GUI shows:
Not need on if/then statements in the automation as I am sure this is just a matter of getting this syntax correct ?..
I do not think you can have access to translations here because state_translated does not work on a state from the trigger variable, so an inline if or iif is probably easiest. Still if, but at least you do not need multiple lines:
{{ 'connected' if trigger.to_state.state == 'on' else 'disconnected' }}
Edit : come to think of it (haven’t tried) for the new state you can probably also use something like:
I wonder… rather than me have a list of entity_id in the automation, I wonder if it’s possible to have this list based on the contents of the area: