Avi_Cohen
(Avi Cohen)
November 14, 2022, 12:51pm
1
Trying to write automation which send notification based on specific from → to status.
I.e
When the charger station change status from Disconnect to other status than “unavailable” or “charging”.
Tried with template for both case but it is not working:
- id: '1668424971559'
alias: Charger station notify
description: ''
trigger:
- platform: state
entity_id:
- sensor.wallbox_portal_status_description
from: Disconnected
condition:
- condition: template
value_template: |-
- value_template: "{{ sensor.wallbox_portal_status_description != 'unavailable' or sensor.wallbox_portal_status_description != 'Unavailable' }}"
action:
- service: notify.mobile_app
data:
message: Charger station { states('sensor.wallbox_portal_status_description') }}
title: Update
Also tried filter out “unavailable” - also didn’t work
id: '1668424971559'
alias: Charger station notify
description: ''
trigger:
- platform: state
entity_id:
- sensor.wallbox_portal_status_description
from: Disconnected
condition: not
condition:
- condition: state
entity_id:
- sensor.wallbox_portal_status_description
state: unavailable
action:
- service: notify.mobile_app
data:
message: Charger station { states('sensor.wallbox_portal_status_description') }}
title: Update
Troon
(Troon)
November 14, 2022, 1:01pm
2
Your indentation is all over the place. condition
should be at the same horizontal position as action
and trigger
.
It’s also critical that the from:
parameter exactly matches the state you’re looking for: is it realy Disconnected
with a capital D?
123
(Taras)
November 14, 2022, 4:16pm
3
Use the State Trigger’s not_to
option.
- id: '1668424971559'
alias: Charger station notify
description: ''
trigger:
- platform: state
entity_id: sensor.wallbox_portal_status_description
from: 'Disconnected'
not_to: 'unavailable'
condition: []
action:
- service: notify.mobile_app
data:
message: 'Charger station {{ trigger.to_state.state }}'
title: Update
NOTE
Go to Developer Tools > States, find sensor.wallbox_portal_status_description
and check if its state
value is Disconnected
or disconnected
.
EDIT
Correction. Removed extraneous space character.
Avi_Cohen
(Avi Cohen)
November 19, 2022, 1:35pm
4
@Taras - thanks but is not working ,
I did confirm the state "Charing " and “unavilable”
based on ur example:
- id: '1668424971559'
alias: Charger station notify
description: ''
trigger:
- platform: state
event_type: state_changed
entity_id: sensor.wallbox_portal_status_description
from: 'Charging'
not_to: 'Unavailable'
condition: []
action:
- service: notify.avico_ha
data:
message: 'Charger station {{ trigger.event.data.new_state }}'
title: Update
getting:
2022-11-19 15:32:59.707 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities automation.charger_station_notify or it is/they are currently not available
123
(Taras)
November 19, 2022, 2:17pm
5
You made the following invalid changes to the example I posted:
A State Trigger doesn’t have an event_type
option.
The trigger
object doesn’t have an event
property for a State Trigger.
References:
State Trigger
Templates - State Trigger
Do you mean Charging
and unavailable
?
You put Unavailable
for not_to
which is not equivalent to unavailable
.
123
(Taras)
November 19, 2022, 2:28pm
6
Your example with corrections.
- id: '1668424971559'
alias: Charger station notify
description: ''
trigger:
- platform: state
entity_id: sensor.wallbox_portal_status_description
from: 'Charging'
not_to: 'unavailable'
condition: []
action:
- service: notify.avico_ha
data:
message: 'Charger station {{ trigger.to_state.state }}'
title: Update
Have your requirements changed? You originally wanted to know when the sensor changes from Disconnected
but your example detects when it changes from Charging
.