Hi, I’m struggling with yaml, and HA in general and understanding tehcniques / docs.
I have this dead simple automation, but it will not work. The switch triggers (visible in HA and log) but the automation do not, and I cannot understand why. Can anyone point me in the right direction here?
I’ve never attempted to use the event trigger, so maybe the way your trying to do it is a possibility, but I think what your actually looking for is the state trigger. As @rpitera said, you could do away with the condition if you wanted but maybe you have a use for it.
- alias: Livingroom Switch Bottom Off
trigger:
platform: state
entity_id: switch.livingroom_switch_bottom
from: 'off'
to: 'on'
condition:
condition: state
entity_id: switch.livingroom_switch_bottom
state: 'off'
action:
service: light.turn_off
entity_id: light.livingroom_ceiling
Just make the trigger the state change and use that to trigger the action.
Could you please point me to documentation, so I can learn how to do and interpret your solution? The condition is only based on my general programming knowledge, if this or this and that then do but that kind of logic is does not seem to be available for me in HA / yaml.
And in this specific case, you say it’s not necessary with a condition like this, but I cannot figure out how to read and learn other techniques accomplishing tasks / automations like these.
I’m looking for a really simple solution here. I have a wall switch, that sends “off” and “on” commands via rfxtrx. I want to activate a scene when I press “on”, and turn off all lights in two groups when I press “off”.
As I’ve already said, I’m having a hard time understanding the documentation but I am willing to learn.
I’ve read documentation ofcourse. But in combination with slow reloading / crashing of HA when faulty configuration it is really hard to figure out what you actually can do with “from” and “to” for example. And I cannot find a separate source documenting what types properties / values / functions you can pass between functions. And how to properly use and parse them.
It’s that kind of documentation I’m missing. Feels like you have to know a lot before you can learn HA. Obviously it’s on me, missing the goals by trying to accomplish unnecessary functions, where there in fact is better solutions to my problems.
Anyway, thank you for your hospitality and patience. I’m trying to learn!
- alias: Livingroom Switch Bottom On
trigger:
platform: state
entity_id: switch.livingroom_switch_bottom
from: 'off'
to: 'on'
action:
service: scene.turn_on
entity_id: scene.your_scene_with_the_lights_on
- alias: Livingroom Switch Bottom Off
trigger:
platform: state
entity_id: switch.livingroom_switch_bottom
from: 'on'
to: 'off'
action:
service: scene.turn_on
entity_id: scene.your_scene_with_the_lights_off
This is the most straightforward way to do it. But there are advanced ways to combine both of these with service templates. The problem is that there are many ways to do things in HA and the only way to learn them is by playing around and reading posts in the forums, watching tutorial videos and reading tutorial posts and asking questions like this. You start with something simple like this, get it working and then try to build on that.
There’s no one real method for learning HA. When I came here in April/May '16, I never even used linux or a Pi before. I had zero experience. But I spent a lot of time reading posts that were of interest to me and learned a lot by trying things out that I read in the posts and then asking questions when I had a problem implementing them.
I also spent a lot of time looking at examples and then comparing them to the docs so that I could understand what was going on. It took a bit of time and effort and a LOT of mistakes, but that is part of the learning process.
Another thing I did was watch all the videos in Ben’s channel at:
This means that there’s logic happening behind the scenes where HA does the conditional testing for us and decide which trigger to run based on our from and to parameters. This is exactly what I mean by “hard to learn” and complex documentation.
Thank you @rpitera, people like you make foras like these exceptional!
To be fair, I looked at it the same way when I started my first automation. But after one or two, you start to see the flow and it becomes more intuitive. After that, when you start doing complex automations, it can be difficult to even figure out how you’d accomplish such a thing but then you look in the forums and see someone has already done it and four others have figured out and even better way and that becomes a new part of your arsenal.
The biggest thing I learned was that there is a lot to be gained by reading forum posts that you wouldn’t otherwise read; stuff that applies to devices you don’t have or setups that are different but the user is seeking to accomplish a similar task.
That and answering questions on things that I know. As soon as I started getting up to speed, I started cherry picking the forums for questions I knew I could answer. That raised my visibility in the community so that when I had a problem myself, other more experienced people recognized me and said, “Well, he helps out a lot, let me see if I can help him…”
This led to me ending up being a mod, getting invited to test out beta code and now being involved in projects (I did the skins on the new HA Dashboard beta - hope you get a chance to look at it!)
It’s up to you how much you want to get involved, and while I appreciate your praise just know that I am the rule rather than the exception here - people involved with HA are super friendly, love to share and give back and consider themselves personal ambassadors to the project. It’s easy to get hooked.
I’m glad I can help you and will be glad to help where I can in the future.
I haven’t had time do follow up on this. I’ve done as you’ve said, been reading lots of forum posts but it’s a really vast amount of different techniques and problems that are being solved. Since I am at the moment using only RTXtrx (433) there is not much that corresponds to my simple issues.
For example, using “from” and “to” trigger values does not work for me since there is no 2-way binding of the switches. I can’t know which state the switch is currently on.
- alias: Livingroom Switch Bottom On
trigger:
platform: state
entity_id: switch.livingroom_switch_bottom
from: 'off'
to: 'on'
action:
service: scene.turn_on
entity_id: scene.your_scene_with_the_lights_on
So what I would need, is some way to say:
"When switch sends state “off”, do this action. And when switch sends state “on” do another action.
A conditional trigger, but the one I posted in the beginning of this thread is not working. I would really appreciate your help!
It’s great. But scary that I don’t understand why it works. Where does HA the magic and figures out that when I’ve pressed on the “On” button on my switch? HA somewhere does a conditional on that event, and test if the state sent was “on”, then runs the automation that has the property event_data containing state: on.
This is magic, and crazy confusing to learn / figure out where to find in docs.
@rpitera, I’m another newbie trying to keep his head afloat … I started a week or so with HA on a Pi3 and my biggest challenge is where to find the right information to read, but I confess that I’ve made huge progress on configuring it after spending so many hours reading and watching videos, yet to start with the automation side though.
I wonder in case you can pass me a link on how to start with the Dashboard. Is there any tutorial/post you recommend?
@torrfura hey mate, I’m in the same boat as you were back in March, it has been few months since your last post, and I wonder in case you got the hook of it? in case you did, and you’ve written down any valuable notes along the way, appreciate sharing with us