I have a couple sonoff plugs that are running fairly important items that are responsible for cooling. It is all currently configured through HA, MQTT, and nodered. My issue is if the power goes out then the server may not come back online properly after the power is restored and therefore what needs cooled may not get proper cooling.
Is there a script or something I can add on the sonoff s31 plugs to check for MQTT connection and if not available then turn the sonoff on automatically?
Look for default_state (Power ON state) of the switch on the S31
@lordwizzard Where can I find that? I looked in the tasmota GUI on the switch, but didn’t see anything.
Not sure for tasmota, it is there under SonoffLAN by AlexxIT (HACS) and the eWelink add-on.
Found some stuff at these links:
opened 11:07PM - 14 Aug 17 UTC
closed 01:36AM - 15 Aug 17 UTC
Restarting Sonoff Tasmota 5.5.2 with web interface resumes with Power state ON a… lways.
I have just uploaded new Tasmota 5.5.2 to a new Sonoff. I am using Home Assistant as my Automation server, however I am not sure that is in play here. The problem I have is that after resetting the device with the Tasmota web interface, it comes back with power state ON even if it was OFF when the restart occurred and even if the Home Assistant last state was off.
After the restart, the web interface and Home Assistant are updated to show the ON state. I have changed many settings suggested here, but non seem to work. This is the current state:
With Tasmota user. config.h:
#define SAVE_DATA 1
#define SAVE_STATE 1
#define MQTT_USE 1
#define MQTT_BUTTON_RETAIN 0
#define MQTT_POWER_RETAIN 1
#define MQTT_SWITCH_RETAIN 1
I did not change any of the PUB_PREFIX, SUB_PREFIX defaults. I just changed the topic in the web interface to "pumpswitch".
It took me a long time to figure out I needed the "POWER" as the last bit of the state_topic and command_topic in HA to get the talking back and for to work in a way I expected.
Home Assistant configuration.yaml:
switch:
- platform: mqtt
name: "Fountain Pump"
state_topic: "stat/pumpswitch/POWER"
command_topic: "cmnd/pumpswitch/POWER"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
My understanding of the above options, Tasmota is not only supposed to save the last state to flash (so as to recover it after a problem?), but also Home Assistant also has retain set, so I should be covered both ways. So even without HA, the Sonoff should come back in the state it left. But that does not happen.
I found that if I used the console and send "cmnd/sonoff/PowerRetain on" then on restart, it would come back in the state it was before the reset. Can this be set in user.config.h somehow as an option? If it is already there, please point it out to me. This is the preferred setting for me, not something I should have to enter on the console command of the web interface each time I update the firmware.
Hi,
I have flashed my Sonoff RF with Tasmoto & using it with HA.
It works great.
I have the following issue.
How do I set Default Powen ON state Sonoff Tasmoto?
When Power reset’s or I switch off & Switch ON the physical switch I want the sonoff to TURN ON & stay as a default state.
But for me, the sonoff Turn’s ON for few seconds & switches OFF automatically, When Power reset’s or I switch off & Switch ON the physical switch
Am I Missing some MQTT code in yaml file or I need to make any …
@lordwizzard Thank you very much for the info. I have found the below information as pertinent to what I want. Please excuse my ignorance, but how can I change the PowerOnState?
Is it as simple as sending the following command in the CLI within the gui?
PowerOnState ON; (not sure I need the semicolon, from documentation).
I’m not a a MQTT/Tasmota user, you will have to experiment on issuing some test commands and see if the action happens as expected.
Thank you. I will do that. I’ll post up here with results so anyone else can use the information as I didn’t come across obvious info regarding this.
That did the trick. I tested it every possible way I could and it powered on immediately after it was plugged in.
Simply put the below command into the command line in the gui. If you want to see what the setting is already then just put PowerOnState and it will tell you.
PowerOnState ON