Tasmota light get state after node red restrart

Hi,

I have some tasmota sonoff basic light switch. Need state after node-red restart imediatelly.
I try the node red contrib tasmota but after setup and restart node red I see below the node one gray cube and don't know the state the light.
When I phisically turn on the light get first the real state below the node ON.
Is it possible to get the state after node red restart?

You could send an HTTP Request and read the returned string if you don't want to use MQTT.

http(s)://'IP Address'/cm?cmnd=Power

(You can also send commands using this technique.)

https://tasmota.github.io/docs/Commands/

HTH,
Colin J

For meg good the MQTT but after Node-Red restart can't get the state. Only after the first toggle get the real state. So how to get the state after restart from MQTT?
Thats why I download this node-red-contrib-tasmota because it is told this: The value is also requested on startup, so the output state is always accurate and full of all the available light info.
But on startup get a gray cube without state info until toggle the light.

If you make the topic that the device reports the state to Retained in MQTT then when node-red restarts it will automatically pick up the latest value.

If you place the HHTP Request node early in your start/power up part of the flow, even as a branch on the original Inject node, it will go get the status. You can look at the returned message and act accordingly.

EDIT: Forgot I have Tasmota firmware in my sonoffs. Above instructions apply to Tasmota, not sure about vanilla Sonoff Devices.

Have this:

[{"id":"55314f02.e9981","type":"Tasmota Light","z":"748a08d7.d5d218","broker":"81b41eba.4b79","device":"sonoff_5","name":"Pince","outputs":1,"uidisabler":false,"fullTopic":"","cmndPrefix":"","statPrefix":"","telePrefix":"","havedimmer":false,"havetemp":false,"havecolors":false,"tempformat":"K","colorsformat":"HSB","x":400,"y":140,"wires":[["44f1f095.8dee9"]]},{"id":"81b41eba.4b79","type":"mqtt-broker","name":"MQTT","broker":"192.168.1.242","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]

and see this after deploy:
after deploye

after turn on manually:
after turn on

where is the problem? Maybe the settings somewhere?
I need state after deployed immediatelly if it possible.

As I said, make the MQTT topic that the state is sent to (assuming it is) Retained.

Sorry but I'm not a perfect coder, so where and how can I do this?
In the MQTT settings? I I change the retain to true the problem is the same:

The publisher has to make it retained, presumably that is in the device.

For me this command http://192.168.1.24/cm?cmnd=Power always turn on my sonoff light after node-red restart. And if I paste to my browser the result is the same. Turn on my light. Don't know why. Have latest tasmota 9.1.

I am running 8.5.0 (not updated yet), but in this version, and past versions, the command 'Power' should return the current status. 'Power On' will turn the device on' Power Off - off.

From the current documents here...

Every command used without a parameter (payload) returns the current setting .

Power returns the status of first defined power output (usually Relay1)"

Instead of 0 you can use off or false and instead of 1 you can use on or true .

Power ON turns first defined power output (usually Relay1) on

Power1 1 also turns first defined power output (usually Relay1) on

Power1 True also turns first defined power output (usually Relay1) on

Yes I found that too. Not working for me...

Hmm, I can try updating much later today on a spare device. Need to fetch it though.

There would appear to be some breaking changes to 9.1.0 - the Template being one of them.

As the instruction from the Browser is not functioning 'correctly', AND the Tasmota Node is showing the same symptoms, it suggests either a config error, or a Tasmota firmware error and not something specific to Node-RED. It might be an idea to raise it over on the Tasmota site.

Observations:
You don't need Node-RED to run the command in the Browser. This would eliminate Node-RED.

  • When you say 'sonoff basic light switch', do you mean a Sonoff Basic Smart Switch?
  • Or do you mean a Sonoff Touch Switch? (My Touch Switches display state when issued with web request command.)
  • ...and just to be clear in my head. You can physically see the light turn on and off? (try Power, Power on and Power off to see what happens)

@spider7611 I have updated one of my standby Sonoff Basics following the migration path from Sonoff Basic 6.6.0 to Tasmota 9.1.0 using the 'minimal' file and then upgraded to tasmota.bin.

Console and web page confirms Tosmota 9.1.0.

Used the Web Request command and all is OK. It fetches status and I can switch on and off and fetch status in between without affecting state of the module.

I am sorry, but I am at a loss to suggest what to do next other than reload the Firmware and reconfigure module for Sonoff Basic(1)

Colin J

Thank You to try to help. So for me in the browser http://192.168.1.24/cm?cmnd=Power

Get this message and turn on Sonoff Basic Smart switch.

{"Time":"2020-11-13T09:22:57","Uptime":"2T11:53:18","UptimeSec":215598,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":7,"POWER":"ON","Wifi":{"AP":1,"SSId":"sponge","BSSId":"50:C7:BF:3E:09:AB","Channel":1,"RSSI":54,"Signal":-73,"LinkCount":2,"Downtime":"0T00:00:22"},"POWER":"ON"}

I just get this..

{"POWER":"OFF"}

I wonder if a complete reset is in order to take the module back to it's default settings and start again?

Wrote the rest of this post and then, being intrigued by the problem, had this thought. Send this command from the browser before you do anything.

http://192.168.1.24/cm?cmnd=Status 0

Post back the results - Not saying I can interpret all, but it might be a starting point, especially if you compare it the same message sent to the 'clean' device.

Not sure how much you are into Tasmota, but this will mean you logging into the Sonoff WiFi and starting again.
Local WiFi Credentials, restart, connect to local WiFi and configure to Sonoff Basic.
If we start with a clean sheet...

My reasons for saying this are as earlier, if you are sending commands via Web Browser, there is nothing external to the Sonoff to affect the outcome of the message. I feel we are looking at a Sonoff problem.

I am currently trying to automate configuration of the Sonoff type devices using Node-RED and there are many many commands you can use, it only needs a slight error and it could have bad results.

Have 4 Sonoff basic and shelly1 with tasmota 9.1 and do the same thing after this: http://192.168.1.xx/cm?cmnd=Power
turn on and get that lot of things in the message.
Always do the firmware update (first with minimal firmware) and they working good anyway.
Maybe later will reset one and reconfigure and will see how it is working.

1 Like

You will always get a lot of messages in the console when Tasmota powers up. The Status 0 message before and after the reset will help.

> 00:00:00 CFG: Loaded from flash at FB, Count 50
> 00:00:00 QPC: Count 1
> 00:00:00 Project tasmota Kitchen Heater Version 9.1.0(tasmota)-2_7_4_5
> 00:00:00 WIF: Connecting to AP1 <SSID> Channel 13 BSSId 5..........A in mode 11N as sonoff-6385...
> 00:00:01 WIF: Connected
> 09:57:07 HTP: Web server active on sonoff-6385 with IP address <IP ADDRESS>
> 09:57:07 RSL: INFO1 = {"Module":"Sonoff Basic","Version":"9.1.0(tasmota)","FallbackTopic":"cmnd/DVES_B338F1_fb/","GroupTopic":"cmnd/sonoffs/"}
> 09:57:07 RSL: INFO2 = {"WebServerMode":"Admin","Hostname":"sonoff-6385","IPAddress":"<IP ADDRESS>"}
> 09:57:07 RSL: INFO3 = {"RestartReason":"Software/System restart"}
> 09:57:07 RSL: RESULT = {"POWER":"OFF"}
> 09:57:07 RSL: POWER = OFF
> 09:57:11 QPC: Reset
> 09:57:11 RSL: STATE = {"Time":"2020-11-13T09:57:11","Uptime":"0T00:00:08","UptimeSec":8,"Heap":28,"SleepMode":"Dynamic","Sleep":250,"LoadAvg":3,"MqttCount":0,"POWER":"OFF","Wifi":{"AP":1,"SSId":"<SSID","BSSId":"5............A","Channel":13,"RSSI":52,"Signal":-74,"LinkCount":1,"Downtime":"0T00:00:03"}}