Someone give a medal to this man! I was sick of stupid smart bulbs around the house turning on after a power outage and now I have finally a working solution-
Thank you! I have a few lights that don't remember their state after a power outage. These automatons are just what I wanted. Your tutorials are great, very easy to follow and understand, keep up the great work.
Thank you very much. I started looking through HA documentation and was lost. We have lots of load shedding and I added the fridge with a Sonoff basic. If anything causes restart, the fridge has to be on, at restart, and this tutorial is exactly what I needed.
That is what I was looking for!!! You are amazing. Thanks to your tutorial, I could create "power state" automation for my Tuya lamps, which were not able to restore their latest status when the power off. They all were turning on when the electricity gone. That's why I did only "off" automation for the home assistant restart trigger. They are already turning on after every power out :D
Watched it, and I hear you say how we need to think how to adopt this elsewhere and I think I have a use case and will probably come back and post here. -I want to say for the sake of feedback and hope others will follow if they feel the same. I have looked at helpers and specifically to a problem I was having with an automation. So I think helpers are underutilized gems I have yet to discover. Please consider other use cases to help us slower people. I know, I keep harping on Trigger IDs but I suspect I would probably be as excited when I learn of the increased functionality I can get in my automations from Helpers. You are my automations guru!- Now I need to get back on my reader, I am on my second D1 mini as I think I might’ve cooked my first with my cheap soldering iron. So new station arrived and helping hands, 00:30 EDT I am soldering in my bathrobe on my dinning room table on the way to bed. Seriously Junkie like behavior!
Thanks, clean, neat, easy to follow. I noticed in the comments people talking about resolving the root issue. The problem is often the default state of the globe after a power outage is random based on manufactory. IKEA recently updated the firmware to resolve this and Wiz has the state also maintained in their app.
Ok, I've now watch a few of your tutorials and have found them very useful. The pace you move at is almost perfect to follow along with. Almost everyone else I watch flys through the steps and they are very hard to follow. I find that I need to stop and rewind less often. Mostly I have to stop to allow time for me to do what you have just said, then continue. Probably all I need to do is set playback speed to 0.75. Its probably just that I need just a little more time to perform the tasks than others more experienced. Also, things have change just slightly with 2022.9. Overall, outstanding tutorials and much easier to learn and follow. Thank you... Now is we could only figure out a better way to do this. If someone has many lights, that's a lot of "helpers" and "automations" to create. I'm using zigbee2mqtt and it should take care of this in the background by itself. For all devices that have a state vs. sensors, it should monitor and maintain a database entry for each entity of that device and restore it upon restart. Possibly make this a switch / option for each entity created that we could turn on if we want to track current state or not...
Very good video and explained very well. They are very useful automations for those who do not have "power-on behavior" in their lamps. In local-tuya it already allows the configuration but even so there are many that are fantastic
Thank you very much for your video, it has helped me to solve a problem I had and to open my mind about the use of homme assistant. I have RF window sensors (they appear to me as binary sensors), when I want to restore the value of the bolean, these sensors do not appear as devices, I can not select the entity of the same, I'm still fighting with them and trying to solve it, if anyone knows how to do it I thank you to respond to the comment. Thank you very, very much for your videos, and great explanations.
Very helpful video mate , I wish this could work when the electricity goes off. When that happens all my lights turn on and sometimes I’m not at home . My R-pi is plugged into a UPS , so it never turns off . The video about the color state would be amazing mate . Keep it up 🤓🤓.
Thanks for the great tutorial. I use several Philips Hue GU10 RGB Spots. Unfortunately after a power failure (or when they are intended cut off from the power) they forget their brightness and colour, they had before. This works great for me. But: I cannot manage in your explained way, how to save RGB and brightness values and restore these. Have you got an idea / tutorial for other values than just on/off too? Thanks a lot in advance...
Ok, this solves another issue as well - I can use this to manually force the state of some mqtt door sensors, on reset they go to unavailable as they have forgotten the state. These ones don't have a retain flag option, and go into deep sleep when not in use. So this method can keep a system memory of their last known state, and force that state on reboot. Nice!
Another great video. I've automated this for 2 pumps for distributing hot water in the central heating system. When I do some programming and rebooting in winter my wife sometimes complains she gets cold. Then the pumps didn't stay on when I reboot HA. Now this will not happen again in the futher! PS: Because I use MariaDB, I put the boolean helpers also in the entities that should be recorded. If they are not recorded I think the automations will not work. But I'am not sure. Thanks Ed !!!
Thank you for your message! The well seems to be 48m deep but never checked. I think, the pump must start, check the pressure and, if not enough, restart after 30minute and so on. If no water 24 hours, HA must switch to the public water system. Now I must go to the pump and turn it on or off, manually. I cannot stay there all night...More, the system must remember which circuit get enough water and which was interrupted in view to continue the watering with it…
This can definately be automated with some sensors. I'm not sure of measuring the pressure and what sensor can be used for that. And the fact that your pump is so far away from your house is also a challenge. It can be done though by creating a WiFi access point close to the pump, or if you prefer Zigbee, set up a Zigbee network with enough Zigbee routers in between. If you find a pressure sensor that can be read by HA or build one with ESPHome, the rest shouldn't be a problem to set up.
Looks like a great guide. For some reason my homeassistant and my plejd automation have started to turn on and off after updates. It turns the lights on in the middle of the night in the kids room and turns some lamps off. I tried to follow this wonderful guide, but when i try to create a automation and then start with a empty automation. Then i get 3 choices Event, Condition and Actions. How do i do?
Thanks. Is it possible to group automations so that it is easier to find in the list? There will be quite a few that you have to keep track of and I'm not consistent with giving them reliable names ... It would be easier if it were possible to color code helper and automations
Thanks Ed to this tweak, I will check it closely and see how can I use it, I have to many automation works on time delays maybe this is what i need after restart it’s always break the time on my automations 🙏🙏🙏
Would you say that helpers could be used to restore the state of a light? I have an automation that lights a hall light at 15% to light the way to the toilet for my son. So the light remains in this state and that interferes with a manual switch i have to toggle it but it would come on 15%. So my motion automation at the last second of the wait time at 15% i go to next action and set brightness to 100% for a second. It isn't a problem for me but I feel i could fix this several ways and a helper might be a good way.
I see it as too tedious a job to have to go device by device. Can you recommend some good practice to handle several light bulbs? Every zigbee bulb in my house is affected by this issue… on power outage it will automatically turn on during the day or night.
@SmartHomeJunkie this works great if HA and the lamp lose power and come back on. But I have a UPS keeping my HA alive. HA doesn't restart because it never loses power, so this automation doesn't turn the light off when it's turned on when power is restored. Do you have a solution, please? At the moment, if I lose power during the night for even just a few seconds, the lamp turns on. This particular lamp is not attached to HA by ZHA or Z2MQTT. It's attached by a Tuya integration as it's wifi.
This is great, my concern is that the final automation is only run when home assistant starts, is there a way to have this checking all the time (or would that put too much stress on Home Assistant). Why I ask is this; my Home Assistant is always hooked to a UPS, so only if the power was out and the UPS died would the animation be triggered to restore the state. Another example would be, lets say I decided to move a lamp from one position to another, I unplug the lap, move it, and the light stays on because that is the default state after power. The Boolean would show the lamp should be off, but its not reset because again HA has not restarted. Looking for your thoughts on the best practices :)
Thx Andrej! Yes, you can try that too. I did not by the way 😉. But, it's more about the general idea that you can restore a state after a restart by storing the states in helpers.
Thanks. I want to make an automation that, when triggered by occupancy, restores a light group to it's previous state if it has been off for less than 15 mins, otherwise it will launch the preset scene. I think you've covered all the building blocks I need for that, but another video would be great, cheers!
Is there also a way to restore the last light state after your motion sensor stops sensing movement? Currently I switch a scene, but that isn't efficient when the led strip in our kitchen was turned off in its previous state. I want a identical setting as I had in the Philips Hue software
Yes, that is possible and it's on my list to create a video about. You can do this by creating a scene "on the fly" when motion is detected. After motion is stopped you can restore that scene. This doesn't survive a reboot, but it's still cool to use.
@@SmartHomeJunkie That sounds very interesting. I used to work as a Hue specialist, before I progressed in the smart home industry. I really miss the easy functionality of the motion sensors when I compare it to the ui of home assistant. Although I can do a lot more with home assistant, I still think that a ui like Hue for motion sensors is a basic option that has to be implemented to attract new users. I've made your alarm system by the way haha. My wife almost loves it. My next step is to stream a dashboard with the alarm panel to our nest hub, so it reminds my wife to enter the code during the 30 seconds. Something like: if the motion group has the state on, and the condition is alarm is triggered, then use the action to stream the alarm panel dashboard to the nest hub
@@Badg0r Watch the NFC tag reader video so that you can give your wife an NFC tag and then she does not have to enter a code anymore. You can buy that reader also plug and play from a website that I linked in the description of that video.
This feels like one of the most annoying things in Home Assistant. The correct solution is that it should be a property of devices that they are 'stateful' or 'stateless'. Meaning that when the system restarts, they are either put back in the states before the system stopped, or are in 'in'/'off' or whatever default state or are not touched. But as a property of the device, not something one should 'program' for each devices. But thanks for sharing the tutorial anyway ;-).
@@walter-- I mean the state of the lightbulbs should be preserved. Some lightbulbs do have the option to set how they should behave after a power outage.
Is it possible to just change the state of the light in HA without actualy calling the service light.turn_on ? Cause in my case the lights stay on (or off) after a restart, but for HA there are off (my lights are managed by a separate system and there is no link to HA regarding the status).
Super thanks for this tip, was searching for a while how to fix this in case of a power outage. Have applied this now, top! Only I am still looking for the next solution. Have a motion sensor (Hue) on the driveway so that when people drive by, the lights go to 100% brightness. However, after a few minutes I would like the lights to automatically return to the originally set dimming level (e.g. 30%). Within Hue you can set that, but how to do it in HA? Can someone help me with that? Many thanks for the help!
I'm glad the tip helped you! I'm not sure about the solution for your specific situation, but hopefully someone in the community can provide some guidance. Good luck!
I was hoping for color and intensity but it was just on and off tutorials. I'll see if I can figure out how to. If not I'll be looking forward to a tutorial.
thank you for this interesting idea, I can learn quite a lot from your tutorials. Recently I followed your tutorial about the alarm panel. I think about combining these 2 tutorials: restore the state of the alarm panel after power outage. But this requires a helper with 4 states (disarmed, armed-night, armed-away, armed-vacation), something like a vector or an array. Do you have an idea which can kick-off to my idea?
@@SmartHomeJunkie I found this video looking for that exact solution. I used a options dropdown helper and similar automatons to those shown in the video and it worked like a charm! Thanks.
Unrelated but my HA added my router July 6 update... It works great but shows unavailable much of the time... (dropout). Router is working fine, if I reload the integration it updates ok. Is there somewhere I can adjust the polling interval???
Wow! As a currently migrating OpenHAB user, this is amazingly tedious. Doesn’t HA have persistence methods to automatically store the current state on every device? I have to admit, if HA and OH merged, they would a KILLER application! They each obvious but separate strengths!
What should I use in case of a power loss? My home assistant device is on a UPS, but my lights are not. Every time the power goes out, all my lights turn on, even if they were off before the power went out.
That is a good question. Maybe you can create an automation that checks if all the lights turn on and in that case restore all your lights to the latest status stored in their helpers? Or have one light that is always turned off as "control" light and as soon as that light turns on, restore all the lights in the house to the l latest status stored in their helpers? And turn the "control light" of again?
Do you have the issue that the status of your lamps sometimes changes when you restart Home Assitant? Or is that no issue for you at all? Let me know in the comments!
@@maarten2760 I think there's also a bug in Zigbee2MQTT currently that causes this issue to happen too. In that case, Install the Edge version of Zigbee2MQTT. In that version, it is fixed. At least on my side. You can also wait for the official release of course.
This is timely, I actually noticed two of my lights come on after a restart today. Tracked it back to some automation triggers that were just monitoring a state of a door sensor - just triggering when going to open. Of course when the state changed from unavailable to open, then it triggered. Fixed by making the trigger 'goes from closed to open' which filters that instance out. But this light state restore is a great idea, should really be a default option baked in...
Yeah, there are some caveats to this method, but it can really help. It depends what your use case is. Hope that it will give people an idea how to set up a system that restores itself after a restart.
I have a tuya based contact sensor. I have the local key, id and the ip address for it, I am not able to add it to local tuya in homeassistant. Please guide how can I add it via .yaml configuration to local tuya. Kindly guide.
@@SmartHomeJunkie the sensor comes online just for some milli seconds whenever it changes it state. And I have to add it in this time frame which is nearly impossible. Only these contact sensors are not getting added via local tuya UI other tuya devices are auto detected. So I am searching for the correct local tuya configuration for yaml to add the contact sensor
@@SmartHomeJunkie already tried that, with no success.. I guess only thru local configuration.yaml it will get added. Any idea what would be the right .yaml entries for the contact sensor
I do not use Node Red for a couple of reasons: 1. I do not want an extra layer that costs me resources. 2. Creating situations on a mobile device with Node Red is nearly impossible 3. When you want to do complex things, Node Red is not that easy anymore 4. You can do everything in Home Assistant itself. 5. Home Assistant automations are faster.
So I am a little confused- If I do this using a STATE vs a ENTITY you don't get the the on or off option do you leave the from/to entries blank (when using STATE) or do you need to fill that in with one or the other? Thanks
@@SmartHomeJunkie Cool! So based on the current version, I chose STATE and left the other options blank. Then under actions IF-THEN>STATE>my entity light group>state:on>THEN>Call Service>Input boolean:turn on>my status helper>ELSE>Call Service>input boolean:turn off>my status helper. Assuming that is all correct if I understood correctly I should have mad a entry under Triggers using eother on or off? which one should I use?
@@SmartHomeJunkie I think maybe I am not being clear because I don't see the connection between my question and using ID's or and this is always a strong possibility I am just to dense to follow ! LOL. I just am not getting it. I have 3 lights in my office they are all in 1 fixture in the ceiling. I could set this up as you have done in the video and either do a automation for each bulb or I could set up all the bulbs in the same automation (I think) like you did- both options would make for a long or a lot of automations or I could use the light group I have set up for those bulbs. That is what I want to do but the options to do it this way need to be different since you do not get the same options. If you get time and come back to re do a video like this show us how to do this with a group if you would. Thanks for trying to help me out!
Watching your live steam and when you went over your "new" automation example I think I finally figured out what you mean once you were showing the trigger id part of that !
@@SmartHomeJunkie Usually for developers, fixing bugs is a higher priority than adding new features, I have about 60 Philips Hue bulbs, this happens to me all the time, thank you very much for the solution
I lost the ability to adjust to previous light state for Hue bulbs when they're added via Deconz. I'd love to be able to restore to the previous state after a power outage but Home Assistant retains the same light state on power outage (my server is on a battery backup, so no issue there). I assume the only way to trigger the lights adjusting to the previous state when power is back on is to use maybe a smart outlet to determine when power is back on. Unless you have another idea? I can't figure out how to use the light itself, since the state remains static after a power outage (e.g., light state remains on if light is on during power outage).
@@TheLawIX Maybe you can switch a toggle helper as soon as a lamp gets unavailable and when it gets up again check the helper state and based on that restore all the lights? Just a rough thought though. I'm not due if you can check on a status unavailable directly in an automation. Otherwise you should create a template sensor that detects that state. Something like that.
@@SmartHomeJunkie Deconz reports the lights as on or off (previous state before power outage). The only way it shows unavailable is if home assistant restarts and the lights are powerless. I hope they would go unavailable if power went out, but not while HA is running.
I am located on an island in Greece where I have a garden with trees. For watering, it is a well and a Hunter box for 9+ circuits. The program works but the problem is...the water. The well can give 30 minutes of water only or nothing at all. Hunter can start watering but if no water, the pump will work for just nothing, around 2 hours… I would like to install a pressure sensor (I have one) or something alike, and if no water, the pump must not start. The program will be delayed till the system will have enough pressure. If the water will stop during watering 1st circuit, the pump must stop too and restart when will be enough pressure, for the rest of time. When program 1 is finished, the Home Assistant must start circuit 2, if the system has still water. And so on. Another problem: the pump is 100m far away of my house. I would like to monitor all from my house, wirelessly. Can you help me with an idea about this, please? Thank you. Cezar
please help! Instructions for creating automatically create 2 switches to control 1 light, when restarting the homeassistant the state of the lights does not change
It is incredible we have to apply all this effort just to address the most basic purpose of using home automation...lights. Restore previous states should be a global setting. Failing that, HA Devs to implement the ability for us to look up "previous_state" via the log. It is there after all. This is a big effort for 50 smart devices and binary sensors (yes I went crazy)
Confirmed this also worked for a power outage as I unplugged my HA Blue, and then plugged it back in. Sure takes a lot longer to boot from a power on vs a restart.
Here is how to do with multiple triggers and choices in one Automation. Uses entities (supports light group) instead of device. Always best to use entity over a device when you can in my opinion. I use this for Sengled lights which turn on, no matter what, after a power failure, and unable to configure option like a Hue. alias: Monitor Light Status Computer Room Ceiling description: "" trigger: - platform: state entity_id: - light.computer_room_ceiling to: "on" id: "On" - platform: state entity_id: - light.computer_room_ceiling to: "off" id: "Off" enabled: true - platform: homeassistant event: start id: Start condition: [] action: - choose: - conditions: - condition: trigger id: "On" sequence: - service: input_boolean.turn_on data: {} target: entity_id: input_boolean.computer_room_ceiling_status enabled: true - conditions: - condition: trigger id: "Off" enabled: true sequence: - service: input_boolean.turn_off data: {} target: entity_id: input_boolean.computer_room_ceiling_status - conditions: - condition: trigger id: Start sequence: - if: - condition: state entity_id: input_boolean.computer_room_ceiling_status state: "on" then: - service: light.turn_on data: {} target: entity_id: light.computer_room_ceiling else: - service: light.turn_off data: {} target: entity_id: light.computer_room_ceiling mode: single
Can't you make the automations more simple by just seting the boolean to whatever state the light switches to (you may need to filter the Unavailable in the Conditions)? At startup, send the command to the light with whatever the boolean helper is. Worst case you try to switch off a light that is off, or on when it is aleady on.
I have no issue with this technique but when you have a household of over 70 devices it's just too much overhead. This functionality should be part of HA behind the scenes. The state of every device should be tracked automatically with an option to restore state after power on.
Someone give a medal to this man!
I was sick of stupid smart bulbs around the house turning on after a power outage and now I have finally a working solution-
Thank you for the🏅! Love it!
Thank you! I have a few lights that don't remember their state after a power outage. These automatons are just what I wanted. Your tutorials are great, very easy to follow and understand, keep up the great work.
Thank you John!
Thank you very much. I started looking through HA documentation and was lost. We have lots of load shedding and I added the fridge with a Sonoff basic. If anything causes restart, the fridge has to be on, at restart, and this tutorial is exactly what I needed.
Awesome! Great that it helped!
That is what I was looking for!!! You are amazing. Thanks to your tutorial, I could create "power state" automation for my Tuya lamps, which were not able to restore their latest status when the power off. They all were turning on when the electricity gone. That's why I did only "off" automation for the home assistant restart trigger. They are already turning on after every power out :D
Spot on, I've been thinking of trying this for a while, your tutorial made this quick and easy to implement, keep up the good work 👏
Thank you for the compliments!
Watched it, and I hear you say how we need to think how to adopt this elsewhere and I think I have a use case and will probably come back and post here.
-I want to say for the sake of feedback and hope others will follow if they feel the same. I have looked at helpers and specifically to a problem I was having with an automation. So I think helpers are underutilized gems I have yet to discover. Please consider other use cases to help us slower people.
I know, I keep harping on Trigger IDs but I suspect I would probably be as excited when I learn of the increased functionality I can get in my automations from Helpers. You are my automations guru!-
Now I need to get back on my reader, I am on my second D1 mini as I think I might’ve cooked my first with my cheap soldering iron. So new station arrived and helping hands, 00:30 EDT I am soldering in my bathrobe on my dinning room table on the way to bed. Seriously Junkie like behavior!
Thanks, clean, neat, easy to follow.
I noticed in the comments people talking about resolving the root issue. The problem is often the default state of the globe after a power outage is random based on manufactory. IKEA recently updated the firmware to resolve this and Wiz has the state also maintained in their app.
Exactly! Thank you for this addition.
Ok, I've now watch a few of your tutorials and have found them very useful. The pace you move at is almost perfect to follow along with. Almost everyone else I watch flys through the steps and they are very hard to follow. I find that I need to stop and rewind less often. Mostly I have to stop to allow time for me to do what you have just said, then continue. Probably all I need to do is set playback speed to 0.75. Its probably just that I need just a little more time to perform the tasks than others more experienced. Also, things have change just slightly with 2022.9. Overall, outstanding tutorials and much easier to learn and follow. Thank you...
Now is we could only figure out a better way to do this. If someone has many lights, that's a lot of "helpers" and "automations" to create. I'm using zigbee2mqtt and it should take care of this in the background by itself. For all devices that have a state vs. sensors, it should monitor and maintain a database entry for each entity of that device and restore it upon restart. Possibly make this a switch / option for each entity created that we could turn on if we want to track current state or not...
Great tutorials, very easy to follow. Now my sensor state will remain after reboot.
Thanks for Tutorial ! Greetings from Romania :)
Thanks for your comment. Great to hear!
Just what I was looking for, thanks SHJ!
Very good video and explained very well. They are very useful automations for those who do not have "power-on behavior" in their lamps. In local-tuya it already allows the configuration but even so there are many that are fantastic
Nice. Can I use it for zigbee valve which is so retatrded that it shouts off after power outage? No option to change it...
Thank you very much for your video, it has helped me to solve a problem I had and to open my mind about the use of homme assistant.
I have RF window sensors (they appear to me as binary sensors), when I want to restore the value of the bolean, these sensors do not appear as devices, I can not select the entity of the same, I'm still fighting with them and trying to solve it, if anyone knows how to do it I thank you to respond to the comment.
Thank you very, very much for your videos, and great explanations.
Very helpful video mate , I wish this could work when the electricity goes off.
When that happens all my lights turn on and sometimes I’m not at home .
My R-pi is plugged into a UPS , so it never turns off .
The video about the color state would be amazing mate .
Keep it up 🤓🤓.
Working on it...
@@SmartHomeJunkie I'm trying to find a video if you've created a solution for this?
Thanks for the great tutorial.
I use several Philips Hue GU10 RGB Spots. Unfortunately after a power failure (or when they are intended cut off from the power) they forget their brightness and colour, they had before. This works great for me. But:
I cannot manage in your explained way, how to save RGB and brightness values and restore these.
Have you got an idea / tutorial for other values than just on/off too?
Thanks a lot in advance...
Ok, this solves another issue as well - I can use this to manually force the state of some mqtt door sensors, on reset they go to unavailable as they have forgotten the state. These ones don't have a retain flag option, and go into deep sleep when not in use. So this method can keep a system memory of their last known state, and force that state on reboot. Nice!
Yes, it's powerful, isn't it? 💪🏻
A random question from newbie can fitbit be integrated to home assistant if yes how . would there be a video on it in future?
As far as I can see in the documentation it can be: www.home-assistant.io/integrations/fitbit/
Another great video. I've automated this for 2 pumps for distributing hot water in the central heating system. When I do some programming and rebooting in winter my wife sometimes complains she gets cold. Then the pumps didn't stay on when I reboot HA. Now this will not happen again in the futher!
PS: Because I use MariaDB, I put the boolean helpers also in the entities that should be recorded. If they are not recorded I think the automations will not work. But I'am not sure.
Thanks Ed !!!
Hi Danny. The recorder should not have any effect on your automations.
Thank you for your message! The well seems to be 48m deep but never checked. I think, the pump must start, check the pressure and, if not enough, restart after 30minute and so on. If no water 24 hours, HA must switch to the public water system. Now I must go to the pump and turn it on or off, manually. I cannot stay there all night...More, the system must remember which circuit get enough water and which was interrupted in view to continue the watering with it…
This can definately be automated with some sensors. I'm not sure of measuring the pressure and what sensor can be used for that. And the fact that your pump is so far away from your house is also a challenge. It can be done though by creating a WiFi access point close to the pump, or if you prefer Zigbee, set up a Zigbee network with enough Zigbee routers in between. If you find a pressure sensor that can be read by HA or build one with ESPHome, the rest shouldn't be a problem to set up.
Looks like a great guide. For some reason my homeassistant and my plejd automation have started to turn on and off after updates. It turns the lights on in the middle of the night in the kids room and turns some lamps off. I tried to follow this wonderful guide, but when i try to create a automation and then start with a empty automation. Then i get 3 choices Event, Condition and Actions. How do i do?
Thanks. Is it possible to group automations so that it is easier to find in the list? There will be quite a few that you have to keep track of and I'm not consistent with giving them reliable names ... It would be easier if it were possible to color code helper and automations
Hi, not yet, but the developers are working on this currently. This should become available in one of the upcoming releases of Home Assistant!
Thanks Ed to this tweak, I will check it closely and see how can I use it, I have to many automation works on time delays maybe this is what i need after restart it’s always break the time on my automations
🙏🙏🙏
You might also want to look at timers. They survive a reboot nowadays.
Would you say that helpers could be used to restore the state of a light? I have an automation that lights a hall light at 15% to light the way to the toilet for my son. So the light remains in this state and that interferes with a manual switch i have to toggle it but it would come on 15%. So my motion automation at the last second of the wait time at 15% i go to next action and set brightness to 100% for a second. It isn't a problem for me but I feel i could fix this several ways and a helper might be a good way.
Yes! There's also a way called scenes on the fly that might help you. I am planning a video for that.
I see it as too tedious a job to have to go device by device. Can you recommend some good practice to handle several light bulbs? Every zigbee bulb in my house is affected by this issue… on power outage it will automatically turn on during the day or night.
This is an interesting idea. I may incorporate it into my system at some point.
@SmartHomeJunkie this works great if HA and the lamp lose power and come back on. But I have a UPS keeping my HA alive. HA doesn't restart because it never loses power, so this automation doesn't turn the light off when it's turned on when power is restored. Do you have a solution, please? At the moment, if I lose power during the night for even just a few seconds, the lamp turns on. This particular lamp is not attached to HA by ZHA or Z2MQTT. It's attached by a Tuya integration as it's wifi.
Hi Ed. It worked. Thank you...
This is great, my concern is that the final automation is only run when home assistant starts, is there a way to have this checking all the time (or would that put too much stress on Home Assistant). Why I ask is this; my Home Assistant is always hooked to a UPS, so only if the power was out and the UPS died would the animation be triggered to restore the state. Another example would be, lets say I decided to move a lamp from one position to another, I unplug the lap, move it, and the light stays on because that is the default state after power. The Boolean would show the lamp should be off, but its not reset because again HA has not restarted. Looking for your thoughts on the best practices :)
Excellent video! Did you try MQTT to save states? I see people use that too.
Thx Andrej! Yes, you can try that too. I did not by the way 😉. But, it's more about the general idea that you can restore a state after a restart by storing the states in helpers.
Thanks. I want to make an automation that, when triggered by occupancy, restores a light group to it's previous state if it has been off for less than 15 mins, otherwise it will launch the preset scene. I think you've covered all the building blocks I need for that, but another video would be great, cheers!
Indeed, just trigger on the state of the group instead of in the Device and you'll be fine.
Veri nice and clear tutorial. Thank you , works perfectly. Thank you !
I'm glad it helped!
Is there also a way to restore the last light state after your motion sensor stops sensing movement? Currently I switch a scene, but that isn't efficient when the led strip in our kitchen was turned off in its previous state. I want a identical setting as I had in the Philips Hue software
Yes, that is possible and it's on my list to create a video about. You can do this by creating a scene "on the fly" when motion is detected. After motion is stopped you can restore that scene. This doesn't survive a reboot, but it's still cool to use.
@@SmartHomeJunkie That sounds very interesting. I used to work as a Hue specialist, before I progressed in the smart home industry. I really miss the easy functionality of the motion sensors when I compare it to the ui of home assistant. Although I can do a lot more with home assistant, I still think that a ui like Hue for motion sensors is a basic option that has to be implemented to attract new users. I've made your alarm system by the way haha. My wife almost loves it. My next step is to stream a dashboard with the alarm panel to our nest hub, so it reminds my wife to enter the code during the 30 seconds. Something like: if the motion group has the state on, and the condition is alarm is triggered, then use the action to stream the alarm panel dashboard to the nest hub
@@Badg0r Watch the NFC tag reader video so that you can give your wife an NFC tag and then she does not have to enter a code anymore. You can buy that reader also plug and play from a website that I linked in the description of that video.
@@Badg0r I'm not familiar with the UI of Hue for motion sensors. Do you have an example screenshot or video that I can watch?
@@SmartHomeJunkie I've made an automation to switch of certain automations with the click of a button.
This feels like one of the most annoying things in Home Assistant. The correct solution is that it should be a property of devices that they are 'stateful' or 'stateless'. Meaning that when the system restarts, they are either put back in the states before the system stopped, or are in 'in'/'off' or whatever default state or are not touched. But as a property of the device, not something one should 'program' for each devices.
But thanks for sharing the tutorial anyway ;-).
Well, this is just a workaround for those devices that act "fishy". I think most of the time it works as expected.
@@SmartHomeJunkie thanks for the feedback! Where do I find the 'expected' behavior described? A pointer to an example?
@@walter-- I mean the state of the lightbulbs should be preserved. Some lightbulbs do have the option to set how they should behave after a power outage.
Bedankt
Dank je wel voor je support!
Is it possible to just change the state of the light in HA without actualy calling the service light.turn_on ? Cause in my case the lights stay on (or off) after a restart, but for HA there are off (my lights are managed by a separate system and there is no link to HA regarding the status).
I don't think so. At least, not that I know of.
Super thanks for this tip, was searching for a while how to fix this in case of a power outage. Have applied this now, top!
Only I am still looking for the next solution.
Have a motion sensor (Hue) on the driveway so that when people drive by, the lights go to 100% brightness. However, after a few minutes I would like the lights to automatically return to the originally set dimming level (e.g. 30%).
Within Hue you can set that, but how to do it in HA?
Can someone help me with that?
Many thanks for the help!
I'm glad the tip helped you! I'm not sure about the solution for your specific situation, but hopefully someone in the community can provide some guidance. Good luck!
I was hoping for color and intensity but it was just on and off tutorials. I'll see if I can figure out how to. If not I'll be looking forward to a tutorial.
I am working on another tutorial that restores whole scenes...
thank you for this interesting idea, I can learn quite a lot from your tutorials. Recently I followed your tutorial about the alarm panel. I think about combining these 2 tutorials: restore the state of the alarm panel after power outage. But this requires a helper with 4 states (disarmed, armed-night, armed-away, armed-vacation), something like a vector or an array. Do you have an idea which can kick-off to my idea?
I don't think so. You can just use one helper, but use a text helper instead of a toggle helper and store the state in the text helper.
@@SmartHomeJunkie I found this video looking for that exact solution. I used a options dropdown helper and similar automatons to those shown in the video and it worked like a charm! Thanks.
Unrelated but my HA added my router July 6 update... It works great but shows unavailable much of the time... (dropout). Router is working fine, if I reload the integration it updates ok. Is there somewhere I can adjust the polling interval???
I have no idea to be honest 🤷🏼
thank you for the awesome tutorial..!
Thank you for the awesome comment! 🙃😉👍🏻
Have to try it, thanks
Excellent video thanks.
Wow! As a currently migrating OpenHAB user, this is amazingly tedious. Doesn’t HA have persistence methods to automatically store the current state on every device? I have to admit, if HA and OH merged, they would a KILLER application! They each obvious but separate strengths!
Well, most of the time this workaround is not needed!
so dear , now when home assistant are turn off and start again does it keep device previse state until change by user in home assistant dashboard
What should I use in case of a power loss? My home assistant device is on a UPS, but my lights are not. Every time the power goes out, all my lights turn on, even if they were off before the power went out.
That is a good question. Maybe you can create an automation that checks if all the lights turn on and in that case restore all your lights to the latest status stored in their helpers?
Or have one light that is always turned off as "control" light and as soon as that light turns on, restore all the lights in the house to the l latest status stored in their helpers? And turn the "control light" of again?
Do you have the issue that the status of your lamps sometimes changes when you restart Home Assitant? Or is that no issue for you at all? Let me know in the comments!
I had exactly this problem! So your tutorial is on the right moment! Thank you
@@maarten2760 I think there's also a bug in Zigbee2MQTT currently that causes this issue to happen too. In that case, Install the Edge version of Zigbee2MQTT. In that version, it is fixed. At least on my side. You can also wait for the official release of course.
This is timely, I actually noticed two of my lights come on after a restart today. Tracked it back to some automation triggers that were just monitoring a state of a door sensor - just triggering when going to open. Of course when the state changed from unavailable to open, then it triggered. Fixed by making the trigger 'goes from closed to open' which filters that instance out.
But this light state restore is a great idea, should really be a default option baked in...
Yeah, there are some caveats to this method, but it can really help. It depends what your use case is. Hope that it will give people an idea how to set up a system that restores itself after a restart.
I have a tuya based contact sensor. I have the local key, id and the ip address for it, I am not able to add it to local tuya in homeassistant. Please guide how can I add it via .yaml configuration to local tuya.
Kindly guide.
Not sure why you cannot add it. To local Tuya. I never had that before and I never added a local Tuya device through Yaml.
@@SmartHomeJunkie the sensor comes online just for some milli seconds whenever it changes it state. And I have to add it in this time frame which is nearly impossible. Only these contact sensors are not getting added via local tuya UI other tuya devices are auto detected. So I am searching for the correct local tuya configuration for yaml to add the contact sensor
@@nehajain2974 Van you keep it alive to push a button on the sensor every 1 or 2 seconds? I do not have that many Tuya devices. I prefer Zigbee.
@@SmartHomeJunkie already tried that, with no success.. I guess only thru local configuration.yaml it will get added. Any idea what would be the right .yaml entries for the contact sensor
@@nehajain2974 I'm sorry, but no. I never did that before.
Why do you not use node red with this? I think it will be easier
I do not use Node Red for a couple of reasons:
1. I do not want an extra layer that costs me resources.
2. Creating situations on a mobile device with Node Red is nearly impossible
3. When you want to do complex things, Node Red is not that easy anymore
4. You can do everything in Home Assistant itself.
5. Home Assistant automations are faster.
So I am a little confused- If I do this using a STATE vs a ENTITY you don't get the the on or off option do you leave the from/to entries blank (when using STATE) or do you need to fill that in with one or the other? Thanks
You need to fill it in. But... From the 2022.9 Renae which will be released this Wednesday, you can choose state options 🎉
@@SmartHomeJunkie Cool! So based on the current version, I chose STATE and left the other options blank. Then under actions IF-THEN>STATE>my entity light group>state:on>THEN>Call Service>Input boolean:turn on>my status helper>ELSE>Call Service>input boolean:turn off>my status helper. Assuming that is all correct if I understood correctly I should have mad a entry under Triggers using eother on or off? which one should I use?
@@Joseph-ko2kl You shouldn't leave the options empty within state. Maybe you can watch my trigger ID video to better understand how automations work.
@@SmartHomeJunkie I think maybe I am not being clear because I don't see the connection between my question and using ID's or and this is always a strong possibility I am just to dense to follow ! LOL. I just am not getting it. I have 3 lights in my office they are all in 1 fixture in the ceiling. I could set this up as you have done in the video and either do a automation for each bulb or I could set up all the bulbs in the same automation (I think) like you did- both options would make for a long or a lot of automations or I could use the light group I have set up for those bulbs. That is what I want to do but the options to do it this way need to be different since you do not get the same options. If you get time and come back to re do a video like this show us how to do this with a group if you would. Thanks for trying to help me out!
Watching your live steam and when you went over your "new" automation example I think I finally figured out what you mean once you were showing the trigger id part of that !
This is a bug, I don't know why we still have to endure this in version 2023.10.3, why is this problem not solved yet?
Well, this is just a workaround when you encounter this behavior with certain devices. Most of the times it just works.
@@SmartHomeJunkie Usually for developers, fixing bugs is a higher priority than adding new features, I have about 60 Philips Hue bulbs, this happens to me all the time, thank you very much for the solution
@@iotgh3792 Oh wow, that really shouldn't be the case. I totally agree that this should be fixed.
I lost the ability to adjust to previous light state for Hue bulbs when they're added via Deconz. I'd love to be able to restore to the previous state after a power outage but Home Assistant retains the same light state on power outage (my server is on a battery backup, so no issue there).
I assume the only way to trigger the lights adjusting to the previous state when power is back on is to use maybe a smart outlet to determine when power is back on. Unless you have another idea? I can't figure out how to use the light itself, since the state remains static after a power outage (e.g., light state remains on if light is on during power outage).
I'd have to think about this indeed. I do not have an answer right away, but for sure there's a solution. 🤔
@@SmartHomeJunkie agreed 👍
@@TheLawIX Maybe you can switch a toggle helper as soon as a lamp gets unavailable and when it gets up again check the helper state and based on that restore all the lights? Just a rough thought though. I'm not due if you can check on a status unavailable directly in an automation. Otherwise you should create a template sensor that detects that state.
Something like that.
@@SmartHomeJunkie Deconz reports the lights as on or off (previous state before power outage). The only way it shows unavailable is if home assistant restarts and the lights are powerless. I hope they would go unavailable if power went out, but not while HA is running.
@@TheLawIX I really have to check what the solution could be. Its an interesting use case!
I am located on an island in Greece where I have a garden with trees. For watering, it is a well and a Hunter box for 9+ circuits. The program works but the problem is...the water. The well can give 30 minutes of water only or nothing at all. Hunter can start watering but if no water, the pump will work for just nothing, around 2 hours… I would like to install a pressure sensor (I have one) or something alike, and if no water, the pump must not start. The program will be delayed till the system will have enough pressure. If the water will stop during watering 1st circuit, the pump must stop too and restart when will be enough pressure, for the rest of time. When program 1 is finished, the Home Assistant must start circuit 2, if the system has still water. And so on. Another problem: the pump is 100m far away of my house. I would like to monitor all from my house, wirelessly. Can you help me with an idea about this, please? Thank you. Cezar
Interesting use case. I will think about it. Maybe I can use it as an example for my live stream on the 6th of August.
please help! Instructions for creating automatically create 2 switches to control 1 light, when restarting the homeassistant the state of the lights does not change
klinkt interessant stel je hebt 30 lampen hebt moet je dan ook 60 automations maken? of kan je meerder lampen in 1 automation maken ?
You can do this with light goups too.
@@SmartHomeJunkie oke want bij triggers kan ik geen group vinden vandaar
@@RichardMSK You have to choose for call service and choose the service light.turn_on at actions in case of a group.
@@SmartHomeJunkie oke zal er naar kijken als je keer een video wil over maken zal super zijn
It is incredible we have to apply all this effort just to address the most basic purpose of using home automation...lights. Restore previous states should be a global setting. Failing that, HA Devs to implement the ability for us to look up "previous_state" via the log. It is there after all. This is a big effort for 50 smart devices and binary sensors (yes I went crazy)
True. But I would say, just do it for lights that have issues.
Confirmed this also worked for a power outage as I unplugged my HA Blue, and then plugged it back in. Sure takes a lot longer to boot from a power on vs a restart.
Yes, after a power outage, the whole host has to start, which definately takes a longer time.
If my lamp is at 50% when restarting home assistant, will it go to 50% or just to 100??
Here is how to do with multiple triggers and choices in one Automation. Uses entities (supports light group) instead of device. Always best to use entity over a device when you can in my opinion. I use this for Sengled lights which turn on, no matter what, after a power failure, and unable to configure option like a Hue.
alias: Monitor Light Status Computer Room Ceiling
description: ""
trigger:
- platform: state
entity_id:
- light.computer_room_ceiling
to: "on"
id: "On"
- platform: state
entity_id:
- light.computer_room_ceiling
to: "off"
id: "Off"
enabled: true
- platform: homeassistant
event: start
id: Start
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: "On"
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.computer_room_ceiling_status
enabled: true
- conditions:
- condition: trigger
id: "Off"
enabled: true
sequence:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.computer_room_ceiling_status
- conditions:
- condition: trigger
id: Start
sequence:
- if:
- condition: state
entity_id: input_boolean.computer_room_ceiling_status
state: "on"
then:
- service: light.turn_on
data: {}
target:
entity_id: light.computer_room_ceiling
else:
- service: light.turn_off
data: {}
target:
entity_id: light.computer_room_ceiling
mode: single
Good idea, but it would be tedious with a lot of lamps. But if you have some special or problematic devices it's good
Yeah, it's a fallback scenario of you have a device that acts weird after a reboot. You can apply this to that device only.
Can't you make the automations more simple by just seting the boolean to whatever state the light switches to (you may need to filter the Unavailable in the Conditions)? At startup, send the command to the light with whatever the boolean helper is. Worst case you try to switch off a light that is off, or on when it is aleady on.
Can you make an instructional video based on Bearded Tinkers comment, to reset the state of MQTT's censors?
I'll look into it!
Thanks
I have no issue with this technique but when you have a household of over 70 devices it's just too much overhead. This functionality should be part of HA behind the scenes. The state of every device should be tracked automatically with an option to restore state after power on.
Yeah, most of the time it just works, but if you have certain devices that don't work that will, this might be a solution.