my difficulty is to start my project. I can’t manage to have a virtual button that allows me to then generate actions based on parameters, depending on whether I switch it to ON or OFF.
Is that switch.test_1_0x385b44fffe8e9495
or something else?
I couldn’t understand this tutorial and translate it… would that be my answer?!
something else (
a dry contact via a relay for example.)
I couldn’t understand this tutorial and translate it
It’s a virtual entity that is displayed as a switch with two states: on
and off
.
An automation employing a State Trigger can monitor the Input Boolean and perform actions based on the Input Boolean’s state-changes.
something else
If it’s “something else” then we need to know its entity_id
. That’s why I asked that you provide the entity_id
of every entity that will be involved in what you are attempting to control.
It’s a virtual entity that is displayed as a switch with two states:
on
andoff
.
An automation employing a State Trigger can monitor the Input Boolean and perform actions based on the Input Boolean’s state-changes.
I thank you very much for your help and these elements. what I’m going to try to do, with what you told me, is to manage on my own with the boolean and see if I can come up with something. and I come back to you. I may be able to get out of it if I manage to start thanks to you!
Here’s an example to help you get started.
alias: example
trigger:
- platform: state
entity_id: input_boolean.summer
condition: []
action:
- service: 'switch.turn_{{ trigger.to_state.state }}'
target:
entity_id: switch.module1
- delay:
seconds: 5
- service: light.turn_on
target:
entity_id: light.led
data:
color_name: "{{ iif(trigger.to_state.state == 'on', 'green', 'red') }}"
When the Input Boolean is turned on, it turns on a switch, waits 5 seconds, then sets a light’s color to green.
When the Input Boolean is turned off, it turns off a switch, waits 5 seconds, then sets a light’s color to red.
EDIT
Correction. Fixed typos.
you likely don’t need a script or a scene.
just start with the example of the automation posted above (tho I wouldn’t start out right from the start with the templates - it’s a little advanced for where you seem to be right now)
you seem to be trying to run before you can walk.
start basic (ex. when this one trigger happens then do this one action). Once you have the basics figured out then move on to something a bit more complex, then on to the next level. etc.
If it’s “something else” then we need to know its
entity_id
. That’s why I asked that you provide theentity_id
of every entity that will be involved in what you are attempting to control.
yes yes I understand, and I know it’s to help me as much as possible. Thanks a lot.
I’ll try to move forward a bit and let you know. thanks again.
I can’t reply yesterday because i’m new.
ous n’avez probablement pas besoin d’un script ou d’une scène.
commencez simplement par l’exemple de l’automatisation posté ci-dessus (même si je ne commencerais pas dès le début avec les modèles - c’est un peu avancé pour l’endroit où vous semblez être en ce moment)
vous semblez essayer de courir avant de pouvoir marcher.
démarrer de base (par exemple, lorsque ce déclencheur se produit, effectuez cette action). Une fois que vous avez compris les bases, passez à quelque chose d’un peu plus complexe, puis passez au niveau suivant. etc.
thank you too.
alias: example trigger: - platform: state entity_id: input_boolean.summer condition: [] action: - service: 'switch.turn_{{ trigger.to_state.state }}' target: entity_id: switch.module1 - delay: seconds: 5 - service: light.turn_on target: entity_id: light.led data: color_name: "{{ iif(trigger.to_state.state == 'on', 'green', 'red') }}"
When I read these things, I usually get the general idea.
However, in the example here, I’m interpreting:
when triggering “summer”, I change the state
of the switch module 1 (I do not interpret a switch to ON, but a change of state), wait 5 sec, then turn on the lights, and conditions in green if trigger switched to ON, and in red otherwise…
I do not interpret an ON condition of the summer trigger to switch the switch module 1 to ON, and to OFF if summer trigger is OFF…
I am wrong… ?
I do not interpret an ON condition of the summer trigger to switch the switch module 1 to ON, and to OFF if summer trigger is OFF…
Both input_boolean
and switch
have on
and off
states. The State Trigger is detecting when the input_boolean
changes state. Whatever state it changes to is represented by the variable trigger.to_state.state
.
All right !!
so in fact you shorthanded everything in this " _{{ trigger.to_state.state }}’ to stipulate that the switch follows the same state as the trigger…?
what is “dumb” for my situation is that I can’t recover my “input boolean summer” input as a trigger in an automation… because otherwise I think that afterwards I could have made everything flow simply by the automatic system creation of automation by HA…
That’s right. Everything between the {{ }}
part is code that will be evaluated (executed) at runtime and the result of that code will then be filled in. This is called templating. In this case he used the trigger object to get the new state. Here’s some more information about the trigger object in the docs.
Doing things this way is pretty popular these days, as it allows for shorter and more powerful automations. It’s also more complicated and can easily become pretty confusing. There’s also simpler ways to write automations, although they will often be longer and you may have to split things into multiple ones. Maybe take a look at the UI editor for automations too. It has come a long way since and is pretty usable for basic stuff.
Offtopic: Je suppose que tu connais le site de la communauté francophone pour HA (https://forum.hacf.fr) ? Ils ont un forum avec pas mal de monde et du coup ça t’éviterais de traduire tout (surtout que les traductions sur des thèmes techniques peuvent partir en vrille avec les mauvais termes et personne comprend ce que tu demandes ).
Hello and thank you for your answere. With all yours ideas, I progress
Je suppose que tu connais le site de la communauté francophone pour HA ( https://forum.hacf.fr ) ? Ils ont un forum avec pas mal de monde et du coup ça t’éviterais de traduire tout (surtout que les traductions sur des thèmes techniques peuvent partir en vrille avec les mauvais termes et personne comprend ce que tu demandes) :clin d’œil:.
Yes but I have begin here, and I wouldn’t make “duplicate”. But perhaps I’m going to slide on this site soon.
Thank you again
Hello to you !
good, with your comments and help, I was able to start and move forward.
I did something basic, and it works in the timeline.
however, I expose myself to operating anomalies if I intervene and change data.
Here is my “code” and I explain myself:
"
alias: AUTOMATISATION FILTRATION ETE
description: “”
trigger:
- platform: state
entity_id:- input_boolean.filtration_ete
from: “off”
to: “on”
condition: []
action:
- input_boolean.filtration_ete
- type: turn_on
device_id: 1ea6475bc6b42120527e9f592682a298
entity_id: switch.switch_pompe
domain: switch - delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0 - type: turn_on
device_id: 8356bf47044fc0de7b1a1a36e45c06f5
entity_id: switch.4_relais_vitesses_pompe_l2
domain: switch - delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0 - if:
- type: is_not_open
condition: device
device_id: 12d1c1745e3eda555bc7d130958f3e47
entity_id: binary_sensor.contact_debit_tamper
domain: binary_sensor
then: - type: turn_on
device_id: ea4d0240dffa6a7f93d3ae2d0bef5f7a
entity_id: switch.switch_regul_ph_cl
domain: switch - condition: time
after: “08:00:00”
before: “20:00:00”
weekday:- mon
- tue
- wed
- thu
- fri
- sat
- sun
else:
- stop: ERREUR PAS DE DEBIT DETECTE
error: false
mode: single
- type: is_not_open
"
so, as long as I don’t touch anything, it works.
as stated, I made the code logically in timeline: if that, then snap that, if that ok, then that… etc etc.
on the other hand, if one of the elements of my chronology changes state (and which would block in my chronological sequence), I would like it to react accordingly.
For example, if my binary_sensor.contact_debit_tamper goes is_open, switch.switch_regul_ph_cl should go turn_off, then switch.4_relais_vitesses_pompe_l2 too, then after 10 seconds, switch.switch_pompe too.
it will be the same procedure if I stop my
- input_boolean.filtration_ete
(pass in inverse from: “on” to: “off” )
also, this part:
else:
- stop: ERROR NO FLOW DETECTED
error: false
gives me nothing (feedback, information, action, notification, …)
well, I know it’s beginner level a bit boring I guess, and I’m sorry about that.
thank you in advance for your help !
Sylvain
Hello,
my problem does not seem to be very attractive
The problem is that your posts are very difficult to understand. I know this is due to the language barrier / bad automatic translation. But it makes it hard to help you if we don’t really know what you want, because the translation doesn’t make sense.
Also, your yaml is badly formatted, which makes it completely unreadable.
I would suggest you repost your question on HACF.
my problem does not seem to be very attractive
also, this part:
else:
- stop: “ERREUR PAS DE DEBIT DETECTE”
error: falsegives me nothing (feedback, information, action, notification, …)
As described in the docs the stop
message will only be in the automation trace. If you want it to be more obvious, use persistent notification.
- service: persistent_notification.create
data:
title: Erreur
message: "ERREUR PAS DE DEBIT DETECTE"