I have the following script that works except for the condition.
'1533219231046':
alias: Plant Moisture
sequence:
- data:
message: The moisture is {{states.sensor.calatha_orbifolia_moisture.state}}
percent.
service: notify.downstairs_dot
- condition: state
entity_id: sensor.calatha_orbifolia_moisture
state: =< 15
- data:
message: You really should water it.
service: notify.downstairs_dot
I want to be able to trigger a secondary action (another Alexa tts) if the moisture is equal to or below 15 but the condition doesnāt seem to be triggering. I wonder if someone can point me in the right direction.
Thanks for that, I was trying to make it work via the HA UI, I know most people prefer to do it yaml and it looks like I need to go the same way.
The automation and script UI needs some love to bring it up to speed. For example duplication of actions/coditions, re-arranging actions and duplication of entire automations/scripts.
Yeah, itās pretty bad. I donāt think many people use it. Only beginners usually. I suggest learning yaml. Youāll have headaches at first, but once it clicks it becomes second nature.
So I couldnāt get your example to work so I read the docs and came up with the following which works great. Notice the delay between one Alexa TTS and the other so they donāt cut each other off:
'1533219231046':
alias: Plant Moisture
sequence:
- data:
message: The moisture is {{states.sensor.calatha_orbifolia_moisture.state}}
percent.
service: notify.downstairs_dot
- below: '15'
condition: numeric_state
entity_id: sensor.calatha_orbifolia_moisture
- delay: 00:00:2
- data:
message: You really should think about watering it.
service: notify.downstairs_dot
assuming your ācurrent_positionā returns something that can be converted to a number (no symbols such as %, etc) then this should work:
value_template: "{{ state_attr('cover.tapparella_studio', 'current_position') | int <= 25 }}"
and you donāt need to use ādata_template:ā in your action service call. ādata:ā will work since you arenāt arenāt actually using a template in that section.
So if the value_template for cover.tapparella_soggiorno evaluates to false, the script ends processing there and wonāt continue to check the other conditions for cover.tapparella_studio and cover.tapparella_stanza_di_adele.
Based on your response, Iām going to assume you were not aware of how conditions work in a script. Therefore the answer to your original question is that there was nothing wrong with the conditionās template. The problem was the script never processed it because it halted execution at the previous condition (that had evaluated to false).
Scripts are a sequence of instructions. Script processing stops at the first condition that evaluates to false. Scripts do not have flow-control like āif this is true then do something else do other thingā.
Your script contains a long sequence of checking the position of several covers and moving them if required. I suggest you create separate automations to handle each cover. The script calls each automation. Thatās what youāre already doing at the beginning of the script (calling other automations).
Alternately, you can create a python_script to replace parts of your script (perhaps just the parts handling the covers) or even the entire script. A python_script provides more flexibility and control than a script.