Homeassistant: Doing stuff with Node-Red; Sunrise/Sunset
It’s 2022 and my energy supplier just informed me some weeks ago that the kwh (kilowatt per hour) will experience a price increase of ±30%. As a fan (or amateur) in home automation I was looking for some ways to use my Homeassistant to cut some of the costs.
Most of my “heavy” used power plugs are actually Meross devices, which are connected via the Meross IoT cloud to both Alexa and Homeassistant.
Looking into some of the data, one of the bigger consumers is my working desk, with a pretty powerful notebook and two additional screens, plus wifi repeater, gigabit switch, well you get the idea.
As I have a habit of basically just running away from that desk when I am done with my day (normally between 17:00 and 18:30) all this devices stay on and consume standby power.
So in my head it made sense to automate the shutdown of the power supply.
As I am bad with automations and scenes and scripts but on the other hand pretty good with Node-Red, I thought of going that route to solve the issue.
Let’s have a look at the components I use
- Sun rise/set: This is an out of the box node which simply (besides other stuff, but I only use this) provides you with “0” if it is night and “1” if it is day. You have some methods to adjust the settings of what day and night means in the node settings.
One important thing is that the node has two outputs, the upper one will provide the current phase (0 or 1) every minute, the other only on state change. As I don’t want to filter, I use the lower one.
- Switch: This simply converts the input into two outputs, here I separated the 1’s and the 0’s , as I want to turn my workplace off at night and on in the morning.
- Call service: This is a build in Homeassistant node which simply lets you perform some “actions” on the system. I use the turn_off and turn_on service on the devices I want to turn on and off (see picture below). On the same power plug I also have my NAS and the Homeassistant server, so those should maybe not turned off.
- Debug Node: well, it shows you the data from the connected nodes. Pretty useful, for example if you think the Sun rise/set output is “day and night” instead of “on state change” or “every minute” 🙂
This is a short one, I hope there are more following this one as I want to do some more stuff with HA
That’s it for today, please leave a 👏 and be excellent to each other.