TCP output node. Sonoff switch with ESPEasy

232 views
Skip to first unread message

Sjoerd van Staveren

unread,
Aug 15, 2017, 2:44:30 AM8/15/17
to Node-RED
Hi

I am using a Sonoff switch on which I flashed the ESPEasy  firmware. The switch turns a ventilator on or off. I can use this switch together with Domoticz. Domoticz sends a command to the switch in this way:


where 192.168.2.40 is the IP address of the Sonoff switch. I can also turn the ventilator on and off by simply typing the command in the address bar of my webbrowser. The Sonoff switch then replies with OK and switches on.

This is the switch I use:



I have tried to use the Node-RED TCP output node to do same with these settings:






I also tried using the complete message (http://192.168.2.40/control?cmd=event,TurnOn) as payload. Both don't work. Has anybody a suggestion on how I should do this?

Best regards,

Sjoerd van Staveren

Dave C-J

unread,
Aug 15, 2017, 2:45:50 AM8/15/17
to node...@googlegroups.com
You need http-request not tcp

Sjoerd van Staveren

unread,
Aug 15, 2017, 3:08:15 AM8/15/17
to Node-RED
Which node is that? In the default list of output nodes I have the HTTP response node and in the list of input nodes the http node. Do you mean these two?

Op dinsdag 15 augustus 2017 08:45:50 UTC+2 schreef Dave C-J:
You need http-request not tcp

Sjoerd van Staveren

unread,
Aug 15, 2017, 3:11:56 AM8/15/17
to Node-RED
Found it. It works, thanks a lot.

Op dinsdag 15 augustus 2017 09:08:15 UTC+2 schreef Sjoerd van Staveren:

Garry Hayne

unread,
Aug 15, 2017, 3:50:52 AM8/15/17
to Node-RED
Sjoerd,
just for information, have you seen this for the Sonoff switches?

https://github.com/arendst/Sonoff-Tasmota/wiki. It works with MQTT and you can also add sensors to the Itead devices.

Garry

fluri...@gmail.com

unread,
Aug 15, 2017, 4:14:17 AM8/15/17
to Node-RED
MQTT is also supported by ESPEasy and works with node-red.

Sjoerd van Staveren

unread,
Aug 15, 2017, 4:39:58 AM8/15/17
to Node-RED
Hi Garry,

I know. There are a lot of possibilities with these Sonoff devices. I also noticed the MQTT part. I haven't installed an MQTT server yet. I want to use the mosquitto server but I haven't figured out how exactly to do this. It is on my ToDo list :)

Sjoerd
 
Op dinsdag 15 augustus 2017 09:50:52 UTC+2 schreef Garry Hayne:

Julian Knight

unread,
Aug 15, 2017, 6:13:14 AM8/15/17
to Node-RED
On any Debian/Ubuntu based device: "sudo apt-get install mosquitto"!


There is a separately maintained repo as well I think if you want to be more up-to-date.

That should be enough to get you going. Until you want to add TLS security, users and so on, there really isn't a lot that needs configuring. It just works :)

You might want to grab a good GUI client though, MQTT-Spy works well. It will help you understand what is going on.

Big advantage of Mosquitto is that it runs easily in limited environments.

Neil Cherry

unread,
Aug 15, 2017, 7:52:43 AM8/15/17
to Node-RED


On Tuesday, August 15, 2017 at 6:13:14 AM UTC-4, Julian Knight wrote:
On any Debian/Ubuntu based device: "sudo apt-get install mosquitto"!


First time listener, long time caller ... ;-)

Also install the mosquitto clients. Useful in shell scripts to publish/subscribe to topics. Also learn about QoS and then learn about retain. Some folks confuse retain for something only used on certain QoS levels. It's independent. Retain does exactly what the name suggest, it retains the (last) topic data (or doesn't if set to 0).

I love using Mosquitto (MQTT) with my HA and the Sonoff devices work very well with Sonoff-Tasmota code.

Simon H

unread,
Aug 16, 2017, 3:57:52 AM8/16/17
to Node-RED
up-vote on sonoff-tasmota.
I use this on 6 or 7 ESP8266 devices, and it's really very mature now.
It's really very flexible, although I do tend to build custom images (mainly just to get my wireless burnt in so I don't have to fit a switch to get them operational).
Mine include:
Immersion heater controller with 4 DS18x20 sensors and 2 SSR
Pond controller (basically an adapted 4 way extension lead with D1mini & relay board bolted to outside).
3 sonoff for lights.
Greenhouse controller which talks to a separate MCU via 1-wire to gather soil dampness, temp, humidity (and originally was to control the window, but my wife barred me from control insisting it took the fun out of  gardening!).
All are exclusively MQTT controlled; and even though they support wemo (?), I choose to emulate wemo in NR for Alexa control, and use MQTT to actually control the devices.
All is fine until the main controller (orangepizero) corrupts it's SD card and needs a few hours of rebuild, taking out the hot water!

On MQTT - I did notice a NR contrib node which implemented Mosca inside NR as an MQTT server; did not investigate much as it seemed hardwired to a backend I don't use, but refactored to use a memory backend, it would be good for most of our kind of usage.
Also on MQTT, watch out for MQTT nodes in NR adopting QOS 2 by default - always check and set your QOS and Retain settings to what you actually want (note Mosca does not do QOS2, but recent mods allow it to 'downgrade' certain messages if so configured).
s
Reply all
Reply to author
Forward
0 new messages