Event that I don't know

Hi there all,
I have a problem with an event that I don’t know where from arrive.
I have Hassio installed via docker in a ubuntu partition.

Every night at 4:11 there is something that stop all my switch
and then turn back on.

I have for example sonoff that turn on and off every night at 4:11.

I install the LOG VIEWER addon but there I see nothing.
I’ll try to turn an info log on my MQTT brocker (MQTT Server & Web client)
in order to see if some message arrive from MQTT.

Is more than a week that I can’t understand what’s wrong there
Please help me with some idea :frowning:

Thanks all

Turn your Wi-Fi access point off then back on. When Wi-Fi is restored, if all your Sonoff devices turn on, then they need to re-configured.

If the Sonoff devices remain off then try turning off the power to one or more of them. Then turn the power back on and see if the Sonoff stays off or turns on. If it turn on then its configuration needs adjustment.

1 Like

Ok … thanks a lot.
I’ll try when arrive home in some hour.

Anyway… now that I think, there is some other thinks
that turn OFF and ON around that hour:


Can be some wifi interruption scheduled at that hour ??? …maybe
The wifi it was not controlled yet…

Thanks again

It was my Wifi Mesh cube … it was programmed to reted every night at 4:00 in the morning.
So that one put my sonoff switches on OFF and back to ON

Thanks a lot

Glad to have helped narrow down the source of the problem.

You may want to consider re-programming the Sonoff switches so that they don’t automatically turn on when they connect to Wi-Fi.

I was mistaken, there’s no such setting in Tasmota. I was thinking of the PowerOnState option (see my post below).

And do you know where I can do this please ?
I mean, I use Tasmota… so where I can tell to sonoff to not automatically OFF/ON please ?

Thanks again

I’ll correct myself and say that Tasmota has a PowerOnState option that determines how the switch behaves when it is powered up. This is unrelated to Wi-Fi. There’s no command to control how it behaves when it first connects to Wi-Fi.

However, what will affect the switch, when it first connects to Wi-Fi, is if the switch’s command_topic contains a retained message. That means the last command sent to the switch is stored (retained) by the MQTT Broker. So when the switch connects to Wi-Fi, it connects to the broker and immediately receives the last transmitted command … which might have been to turn on the light.

Check the configuration of your switches in Home Assistant and look for any that are using retain: true.

On my 2 pieces of sonoff topic I have the “retain true” in the configuration if I remember.
But… this PowerOnState is work also when WiFi is lost ?
…or is work only on powering up the device sonoff ?

I’ll take a look when I’ll arrive home.
Thank’s a lot again

That’s the leading cause for lights to magically turn themselves on after disconnecting/reconnecting to Wi-Fi.

No, I was wrong about that. I read Tasmota’s documentation and PowerStateOn only applies when the switch is powered up.

You will need to remove retain: true from the configuration (retain: false is the default). However, there is one more very important step. You must delete the retained message stored in the MQTT Broker.

I can explain how to do that but, honestly, the easiest way is to use MQTT Explorer. It displays all of the MQTT broker’s topics, you select the topic containing the retained message, and click the ‘Retained’ button to delete the retained message in that topic.

The usual way to do it is to publish an empty retained message to the topic. Explaining how to do that takes more time that if you just install MQTT Explorer and use it to delete the retained message. :slight_smile:

Thanks a lot
I’ll study this think about retained messages and I’ll do some experiment at home.

Thanks a lot for your help.

You may find this helpful:

Thanks a lot I have solve my problem of the 04:00 AM On/Off :slight_smile:

Now I have a little other problem.
The 2 switch that I have from sonoff with last tasmota firmware
can remember the state (if On or Off) after reboot of Hassio.

But I have a switch on my automatic door (switch that I do)
that every time I reboot hassio it’s olways take the Off status.

Do you know please how can I solve this ?

Thanks a lot again

Do you mean they can not remember their state after a reboot? Is their state reported as unknown after a reboot? Or is it unavailable?

Thanks again for your help

Before I boot it’s on ON
and after I reboot it’s on OFF and in the mean time I don’t touch the switch.

It’s a switch that open and close the chicken coop door via WiFi :slight_smile:

Thanks again


Here is how your system works now:
Your switch publishes its status as a NON-retained message. That means a topic’s message is received only by clients that are currently connected to the broker. When Home Assistant restarts:

  • it connects to the broker
  • subscribes to the switch’s topic
  • receives no message for this topic (because it is NOT retained by the broker)
  • defaults to indicating the switch’s state is off

Set Tasmota’s PowerRetain option to on. This will make the switch publish its status message to the MQTT Broker as a retained message. The broker will store (retain) this message. When Home Assistant restarts:

  • it connects to the broker
  • subscribes to the switch’s topic
  • immediately receives the topic’s message (because it is retained by the broker)
  • indicates the switch’s current state
1 Like

Thanks a lot Taras
sorry for late… I was in hollyday :slight_smile: