I am right now using my iPad, when I test it will be using my desktop.
Thanks tom_l: and 123 Taras.
I will update after it is applied in the automation.
well…technically…it doesn’t matter which order anything is in. It will still work as long as all the sections are still there no matter what order they are in. That is proven by the results from the automation editor.
However, it is common practice, and it helps readability, if you do it the way taras recommends to do it.
I just wanted to mention it because you will see it in other ways in the forums when people post code created in the UI editors and it is still valid.
I just created an automation using the Automation Editor. Here’s the YAML it produced:
The key-names within each section are sorted alphabetically but it preserves the logical order of trigger, condition, and action.
Just for fun, I rearranged the sections like this:
It passed ‘Check Configuration’. That means, yes, the order of the three sections isn’t critical but, no, Automation Editor does place them in logical (causal?) order.
I never use the Automation Editor so I couldn’t say if this behavior is old or new (other than the alphabetically sorted keys). FWIW, I created the automation using Home Assistant 0.110.0 on an RPI3 (a new test system I recently implemented).
I’ve always used the “Core” version and so I was ‘out-of-the-loop’ when people discussed Supervisor, Add-Ons, snapshots, etc. Now I have two instances of Home Assistant running, one as an RPI3 disk-image and the other as Supervised on Ubuntu.
Hi, can you explain why nothing will happen if the binary sensor comes on at 17 :00. In this case I want the pump to come on at 18:00. Please let me know if I need to correct the logical conditions.
The trigger is that the state of the binary sensor changes - but the state does not any more, it has changed already, so: not state change, not action.
For simplicity, I’d just create a 2nd automation that checks at 6:00h and at 18:00h if the state of the binary sensor is ‘on’ already - and use the same action.
I assume you already have another automation that will switch the pump off again when necessary.
Thanks @chairstacker and @tom_l.
Since I want my pump to run in a period of 2 hours from 06:00:00 or 18:00:00, I have modified the automation, with triggers at every 30 minutes. In the condition I have the low and high level sensors. This is my automation:
- id: Check Water Level In Overhead tank
alias: Time To start Pump
trigger:
- at: 06:00:00
platform: time
- at: 06:30:00
platform: time
- at: 07:00:00
platform: time
- at: 07:30:00
platform: time
- at: 08:00:00
platform: time
- at: '18:00:00'
platform: time
- at: '18:30:00'
platform: time
- at: '19:00:00'
platform: time
- at: '19:30:00'
platform: time
- at: '20:00:00'
platform: time
condition:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.ohtank_level_low
state: 'on'
- condition: state
entity_id: binary_sensor.ohtank_level_high
state: 'on'
action:
- entity_id: switch.ohtank_pump
service: switch.turn_on
I used the automation editor to do this.
Is there another way of coding this?