Skip to content

YAML vs Node Red

Welcome to my 2nd blog about my migration adventure from Athoms Homey to Home-Assistant.

I would like to talk you guys through 3 topics/questions today :

- Why is YAML not the best option?
- Think your way through your automation
- Bugs are everywhere

Why is YAML not the best option?

When you start with a new Home-Assistant installation you tend to use everything they advise you to. Home-Assistant has a lot of build in features that you can use to automate tasks or to make your life easier, which is awesome. But sometimes.... sometimes, what you get is not the best that you can get, or so i've learned on my journey.

Automating tasks in Home-Assistant is done through automations. You specify a trigger (what is trigger my automation), a condition and an action. It sounds pretty straightforward and it is also.
A simple example of an automation could look like this :

- alias: "Media player paused/stopped"
- platform: state
entity_id: media_player.htpc
from: 'playing'
to: 'idle'
- condition: state
entity_id: sun.sun
state: 'below_horizon'
service: scene.turn_on
entity_id: scene.livingroom_normal

This automation turns on a scene (for your lights) when your HTPC reports that a movie is being paused and the sun is below the horizon (sunset). Epic, right?
Yeah, it is. But it still is YAML, and that sucks, bigtime. So when you are building bigger automations, your code will become a mess. Finding bugs can become quite the challenge for example. At some point i had automations which were > 60 lines of code. Fine if it works, but annoying to debug, enhance or read.

Then a Tweaker gave me a very valuable tip. He said it probably was a good idea to check out Node Red. I heard of it (while debugging and Googling a lot of my automations because i was stuck with them) so i started doing some investigation.
I've learned that Node Red is a default add-on which you can install on your installation. It's a product made by IBM for "wiring together hardware devices, APIs and online services in new and interesting ways.". Sounds pretty funky.
So i've installed it. What i found, was in one word amazing.

Node Red is essentially this : It's a graphical way of making your automations. You can simply drag & drop blocks on-to your "whiteboard" in Node-Red, link them together with wires and tell them what to do.
So then i went from 60 lines of code for just one automation to this :

Really happy with Node Red so far. It gives you a very good overview of what your automation is doing, helps with debugging and makes you feel like you've just won a unicorn somewhere. Pretty cool.
In the next blog i will talk you guys through making your first automations/flows in Node Red! For now, if you want to start with Home-Assistant and plan on doing a lot of automations : Please, please, pick Node Red and don't start with the YAML Automations because after 2 long nights of debugging your head will explode. Believe me.

Think your way through your automation
Automating things in your home, and around your home is really cool. You can drop all your creativity in your Home-Assistant / Node Red setup and make it do all kinds of weird/cool/handy stuff. Want to turn on the lights when it's after sunset and there is motion in your hallway? Sure, automate it. Want to receive a push message once your dishwasher is done? Sure, also possible. The options are endless, really.

But it also has a 'downside'. Everything that you automate, build, code and script can fail. It can give weird behavior, it can cause bugs, your lights might turn on green instead of yellow and things like that. The trick here is not to think "OHHHHH i want to automate ALL shit in my home right now" but to think "OHHHHHH i want to automate ALL shit in my home right now. Let's start with the lights in the hallway". You really need to take it piece by piece. And with every piece you need to think very hard.

Sure, you can turn on the lights every time there is motion in your dining room. But is that the only thing? What are the conditions or edge cases? Maybe you don't want to turn on the lights when there is motion and the sun is still up? Or maybe you don't want your robot vacuum to start unless all the doors are closed so it can not get stuck on a doorstep.

The thing i want to tell you is : Take your time. Think it through. When i have to make big, complex automations, i just open up my notes app on my phone and start describing what it needs to do and when. And when it should NOT do anything.

Making an automation from written down notes that describe behavior is a lot smarter than doing it by head while your head is going 200% because you are so excited that you are now able to automate your coffee-machine.

I really had a lot of times when i thought my automation was right, but then i forgot something. My lights didn't want to turn on at night, i did a DOS like attack on my Philips Hue bridge because of a bug and my lights kept turning on green instead of yellow. I deleted all my Node Red automations, made notes first, started again, and now it is working perfectly! Just take your time ;-)

Bugs are everywhere

Yep, if you start with home-automation you will encounter bugs. Or not really bugs, but things you didn't think about well enough.
The main reason i want to tell you guys more about this is because it can become quite annoying to trigger bugs when you immediately go from 0% to 100% automation.

As with the other subjects, it's key to take your time. Do you want to automate your lights? It might be a good idea to make a flow that does everything that you want, except for turning on or off your lights. As a last step, set a push-message to your phone that says "Ok, now the lights should have been turned on" so that you can analyse the behavior of your automation a few days before letting it mess with your smart lights.

I had this, but it wasn't with lights..... it was with my alarm sirens. I want to rebuild the alarm that i had on my Homey to be a good, working, safe solution for my Home-Assistant. I hooked up my Z-Wave sirens to Home-Assistant and was building my alarm. Guess what, that freaking sirens went off every time. And that really is not funny, because it is 2x 100dB, so it's really load. Not only annoying for me, also for my neighbours. I've replaced the sirens in the flow with a push message that says "Attention : The alarm should have sounded now! Please check the house". It attends me on a possible break-in, but does not sound the sirens.

Also, when you are not leaving on your own, but you have a girlfriend, boyfriend, roommates or something else in your house, keep in mind that they also have to adjust to your automation-urge. They can't turn off lights with the buttons anymore, but have to rely on your automation. Take them with you in the process, tell them what you do and what they can expect. Really, do that, if you don't, there might come a day when someone says "Ok, fuck your automation shit. I'm just going to do it with buttons again".

So... this was kind of a psychological blog about Home-Automations. Things i hoped you picked up from my blogs : Take your time, make mistakes but make the right ones, tell other people in your house about what you are doing and then just start doing it. Experiment, make mistakes, learn from them, try again. In the end you will be able to automate things without the frustration, irritation and anger that comes with "doing everything from head, fast fast fast".

Next time we will really dive in-to coding, Node-Red, flows, devices, and so on! See you then!

Questions, remarks or tips? Contact me : [email protected]


No Trackbacks


Display comments as Linear | Threaded

private lesson on :

Amazing, outstanding weblog framework! The span of time have you ever been writing a blog to get? you have made blog view uncomplicated. The total peek within your web-site is definitely excellent, and private lesson also the written content!

Add Comment

Standard emoticons like :-) and ;-) are converted to images.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.

Form options