Hello;
I just joined the homeasistant family and am stuck in automation. What I want to do is to trigger the relay if the potentiometer data is lower than the dht data. If it is larger than dht data, it will close. I can’t understand syntax operations. Please don’t laugh, I’m just getting started…
thank you:)
Welcome to the HA world!
Here is a rough start for you:
alias: relay control
trigger:
- platform: numeric_state
entity_id: sensor.POTENTIOMETER
below: sensor.DHT
id: 'below'
- platform: numeric_state
entity_id: sensor.POTENTIOMETER
above: sensor.DHT
id: 'above'
action:
- choose:
- conditions:
condition: trigger
id: 'below'
sequence:
- service: switch.turn_off
entity_id: switch.RELAY
- conditions:
condition: trigger
id: 'above'
sequence:
- service: switch.turn_on
entity_id: switch.RELAY
Change the entity ID’s I left in UPPERCASE to your actual ones (use lowercase).
Another way could be:
alias: relay control
trigger:
- platform: numeric_state
entity_id: sensor.POTENTIOMETER
action:
- service: >
switch.turn_{{'off' if states('sensor.POTENTIOMETER') <= states('sensor.DHT') else 'on'}}
entity_id: switch.RELAY
hello spark;
I am grateful to you for your answer. I didn’t believe it when my friends who used home assistants said that the community helped. You have renewed my faith
By the way, which ymal file will I add them to?
would that be effective, dave?
If it’s effective, I’d like to base the logic on it.
Hang on… I’m just updating my post because I thought of a different way to do it… hold tight while I fix all the copy / paste mess!
Hopefully my edit is correct now… The first version uses ‘simple’ automation code (easy to read and understand what is going on) whereas the second one uses a template which is (in my mind) more difficult to do. This template is fairly easy but some templates are crazy and I always need help to get them working.
dear dave;
Where or in which ymal file will I write this automation code? by the way i declare you hassio my best friend for helping me when i was just getting started
You can actually do these via the automations editor GUI. That would be easiest for a beginner
Thank’s dave