- platform: rest
name: test
resource: http://192.168.20.2/test.txt
json_attributes:
- first
- second
- third
Here is the code I am using for the trigger:
- id: '201'
alias: Test Alerts
description: ''
trigger:
- platform: state
entity_id: sensor.test
attribute: first
to: 'true'
from: 'false'
action:
- service: notify.mobile_app_nameofphone
data:
message: First changed from false to true
I have tried false, ‘false’ and “false” in the trigger (boolean vs string?) but am unable to get the trigger to execute on a state change.
Any thoughts on how to get this to execute correctly?
I did try no quotes, but that does not work either.
The rest sensor does seem to be working correctly and detecting the change in state - below is a snapshot from the Configuration/Entities/(select entity, slider icon in top right) window:
September 29, 2020
9:30:28 AM
Changed to { "first": true, "second": false, "third": false }
first true
second false
third false
This is the state change that should be detected by the trigger, but still no luck (no evidence of trigger executing, Configuration/Automations does not show a last trigger time).
I have been trying to narrow down the problem further through debug… The rest sensor appears to be working correctly, and the transition to the new state is detected when attribute ‘first’ changes from false to true:
However, my trigger is still failing to detect the from: False to: True transition on the ‘sensor.test’ entity and ‘first’ attribute. I have tried False/True, false/true, ‘false’/‘true’ for the from: to: in the trigger but none work. I have also tried leaving the from: field blank and just using True in the to: field but this doesn’t work either.
OK, some further progress after hours of trying to get this going… In Developer Tools/Template, I can see the state changing with the code below, so the json file and rest sensor appear to be working correctly:
{{ is_state_attr('sensor.test', 'first', True) }}
(this reports False if ‘first’ is set to false in the json file, True if ‘first’ is set to true)
However my trigger:
Type = State
Entity = sensor.test
Attribute = first
From = False
To = True
is still not working?
If I can’t do what I am trying to do with the attributes, any ideas on alternative methods I could try?