How to restart the smart plug that host the internet box?

OK this is cheap but not able to detect power loss/restore without additional hardware, this is what the goal was with this SIMPAL and on top to have the possibility to stop/start one slave plug using SMS or call… Surely expensive but reliable and stressless when I have all my equipments connected on HA (pool, air conditioning/heater, camera, …) as well as (and this is critical to me) the alarm system !!!..

It will not “detect” power loss (wonder how the SIMPAL could do that - with some backup battery pack maybe?) but the power restore will just be a boot event and that will be detected without extra hardware.

esphome:
  # ...
  on_boot:
    then:
      - delay: 5s
      - switch.turn_on: switch_1
      - sim800l.send_sms:
          recipient: '+123456789'
          message: "Power restored and relay turned back on for your convenience"

Actually with one esphome device with a sim800l you can control all devices on ha with sms/call’s - not only one extra device :wink: And really all devices that are connected to ha and not only all other esphome devices.

The docs give just a little sneak preview what could be possible - but as always sky is the limit :raised_hands:

It’s just a complete different niveau having full control over your devices :muscle:

You might want to consider looking at different devices in general. When I lose internet access to my house basically nothing changes smart home wise. Actually I guess I have to go outside to turn the hose on and off, my partner bought that one without checking with me :unamused: Everything else just keeps working, doesn’t even notice the internet is out.

When looking at devices I’d recommend looking up their integration in HA before purchasing. In the top right corner it tells you fundamentally how the integration works, here’s ZHA for example:
Screen Shot 2022-08-25 at 1.04.09 PM

Notice in that paragraph it says “Its IoT class is ‘Local Polling’”. The key word there is “local”. That means it works even if the device and HA are completely cut off from external internet access. The ones you want to avoid say “Cloud Polling” or “Cloud Push”, see here for the list. Those depend on your “internet box” for functionality.

I should note that if your LAN goes down then that will also take some local ones offline. Not Zigbee or Zwave devices since they use a different network entirely but integrations classified as “Local Polling” and “Local Push” may still depend on your LAN being functional. Sounds like that’s ok in this case.

If you would prefer not to look up each and every device you purchase to see what its IoT class is then some good keywords to look for are Zigbee, Zwave and Homekit. If a device implements one of these it is a very high probability it works with HA and it does not depend on the internet. In addition as others have noticed you can make your own local devices with ESPHome. Although I gather from this comment you would prefer to buy off the shelf then build:

Also just a small question, how necessary is it to have a smart plug behind your “internet box”? Do you find you have to restart it a ton or something? If so perhaps you should consider purchasing a new one or asking your ISP for a replacement instead of trying to deal with that yourself.

Just my two cents but sometimes smart stuff isn’t the answer. Like when it comes to power running to the internet box. Even if your smart home can handle an internet disruption, the humans in your house generally can’t. And I don’t know about you but I find it quite disruptive when the internet goes down as my personal devices take a few moments to come back online again. I realize this is probably blasphemy on this forum but IMO some things should remain dumb.

Are you aware that the main problem of the author was not the internet (that he turned off by himself actually) but the failure of HA? He wasn’t at home and couldn’t turn it back on :bulb:

Yes. So what? How you lost internet is a detail. The point is his house breaks when he loses internet

Actually he lost remote control but that was because the HA host was failing and he just locked himself out (by turning the power plug of the router off) at a later stage :bulb:

A smart solution (like a esphome plug) that is configured to automagically turn on the relay after it was turned off:

would indeed have saved him not only the day but would have made his plants much happier :sunflower:

I really don’t read that in the authors post. :thinking:

While at the same time I would never use cloud dependent actors/sensor at my home for sure but only go for full local control and obviously local push :raised_hands:

I will admit, I did miss that the internet box was also hosting the VM with HA on it. I gathered that it was not a router so I assumed it was some kind of modem.

In that case I need to emphasize my last point

Like I can’t emphasize enough how bad of an idea it is to give HA a button that cuts the power to the machine which is running HA. Even if it comes back on you are absolutely playing with fire. Nothing will have been given a chance to cleanly shutdown. Best case scenario you lose any data that hadn’t been written to history, restore returns everything to mostly the same state and the other addons recover as best they can. Worst case (and not even that out there) you’ve got data corruption that requires manual intervention.

I think almost nobody got this yet in this thread :joy:

He doesn’t need to expose the relay control of a esphome smart plug that is in charge for his internet/router/modem/vm/ha-super combo device that looks like that btw:

to get the comfort of still being able to have the chance resetting the power to it when his HA VM is dead.

And this is what the problem of the author was :bulb:

Even if it comes back on you are absolutely playing with fire. Nothing will have been given a chance to cleanly shutdown.

The authors machine was already dead. There really wasn’t anything to “save” here…

Simply resetting the power an win :tada: Suggesting a “dumb” switch for that use case can work when some is at home (as unplugging and re-plugging the cable will do to) but if some on is not at home it simply needs a “smart”/connected actor for that task. This thread meanwhile shows more than one solution to the authors problem - but a “dumb” switch certainly will not help :bulb:

Ok but to be clear, this isn’t the problem the author is asking for help solving

(emphasis mine)

HA was alive and well. Other features were not. Unless I’m reading this wrong again the author is specifically asking for a way to cycle the power on their Freebox Delta from HA:

Which again - EXTREMELY bad idea. Do not add that button to HA.

This sounds better. I see where you’re coming from now. However it should really also try and tell HA to do a host shutdown first with a timeout. I mean random power failures happen and HA is designed to be as resilient to those as it can be. But definitely don’t intentionally increase their frequency.

2 Likes

It can 100% … That’s the reason why I said your solution is a cheap solution needing more hardware (batteries, power failure detection, smart plugs working without Wifi…) to cover my requirements… because what is important in a power failure is the failure not when the power comes back because it could never come back if you are not fixing the root cause of the failure (if you can of course) as you are not aware of it.

Sounds about right. Now reading it again it makes more sense the host OS of that Freebox Delta struggled and not HaOS itself (which was my first thought on that topic reading that post)

Including me :point_up:

I think the author mainly asked for a plug that can turn on by itself after being switched off :point_down:

It should be no problem for a esphome device to tell home assistant to shut down before triggering the power cycle, something like that yaml-wise could work:

button:
  - platform: template
    name: Gentle HA restart
    on_press:
      - homeassistant.service:
          service: hassio.host_shutdown
      - delay: 50s
      - switch.turn_off: relay
      - delay: 5s
      - switch.turn_on: relay

As you can still access the smart plug from your Tuya app, you probably can setup a schedule to turn on automatically at a specific time. Set it for like, 10 minutes from the time you are accessing, then turn off and wait until the time you have set as the smart plug will turn on based on the schedule, regardless the availability of Wi-Fi.
Good luck!!

Do the schedules live on the devices?
I thought those commands was sent from Tuya server at the scheduled time. But I could be wrong.

1 Like

Hi,
Thank you all for your replies :wink:
What seems the best solution to me is to flash one of my Konyks smart plug with ESPHome, to get the ability to program the auto restart of this plug when it’s turned off.

As this way if the situation happen again, I’ll go on H.A turn off this plug, what will turn off my internet box (with H.A), and a few seconds later, the plug itself will turn on again, and internet will go live again one or two minutes later, as well as my VM’s (H.A + Plex).

As I didn’t found any smart plug preloaded with ESPHome with French plugs, only EU version (ground won’t work for me in this case), I think I won’t have other choice than flash a plug by myself…

2 Likes

Indeed - if they have a esp inside you can just supercharge it and benefit from all the possibilities that esphome offers :muscle:

I would expect your internet box to be powered by a (maybe 12V?) PSU that doesn’t even use a ground pin :wink:

You could also think of a DIY ~$3 setup like this and (because it’s always on anyways) even just use it to switch the DC line:

image

Wire it using the NC contact will even save some energy as the relay is not energized always then but only when disconnecting the load :zap:

1 Like

I don’t know if this would apply, but I have a dead-man’s switch on my router. It runs an Arduino program on a Wemos D1 Mini that pings Google or Amazon or a dozen other hosts at random once a minute. (I ping randomized hosts in case one of the hosts goes offline, and to not look like a hacker). If there is no successful ping for ten minutes, it assumes that the router is down and interrupts the router power for one second using a relay.

Hi, thanks for your feedback.

Despite the fact that I’m dev, I never used such boards.

How looks the relay that interrupts the router from Wemost board?

The relay board shown by orange-assistantthe real one would work well but you need a power supply. The Wemos D1 Mini is the same processor, but it has a USB port and power regulator on the board. I use the predecessor to this board to control a fan from a Wemos D1 Mini.

If I’m not mistaken the “newer” revisions of this type of relay board also accepts 12Vin so if the internet box from @noiwid is powered by 12VDC it should be able to just put this little board inline without a extra psu :trophy:

Hi,
Thanks all for your feedbacks.
I just received an ATHOM v2 plug, that has Tasmota preinstalled.
I’ve set it up with H.A without no problems.

I’ve find a way to send to the plug multiple MQTT commands at the same time :

Backlog Power off; Delay 10; Power on;

As commands can be sent to plugs by HTTP request, I used this way that seems the easyer to set up.
In H.A, I added a REST command (in config file) :

rest_command:
  freebox_restart:
    url: 'http://192.168.0.23/cm?cmnd=Backlog%20Power%20off%3B%20Delay%2010%3B%20Power%20on%3B'

I also added a card to trigger this URL on my dasboard:

show_name: true
show_icon: true
name: Redémarrer la Freebox
tap_action:
  action: call-service
  confirmation:
    text: Confirmer le redémarrage de la Freebox?
  service: rest_command.freebox_restart
type: button
icon: mdi:restart

I now want to add an automation that will also trigger this URL if internet goes down during a few minutes. Any advices on the best way to test if internet is Alive ? Ping Google ? How to wait for X minutes after an event (internet down) to trigger an action, except if another event don’t happen (internet up) ?

Thanks for your advices!