MQTT to Relay with Node-Red

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

MQTT to Relay with Node-Red

#1 Post by JR01 » 24 Apr 2016, 11:53

Hi, I see a lot of discussions on using MQTT to actuate a relay. For instance this by @tozett, http://www.esp8266.nu/forum/viewtopic.p ... elay#p4271, that refers to the way Domoticz does it, and this one http://www.esp8266.nu/forum/viewtopic.p ... nHab#p5921 that controls MQTT for relay switching from OpenHab by @anantbhula, then I find very interesting MQTT import, http://www.esp8266.nu/forum/viewtopic.php?f=4&t=1148 by @namirda, which I would like use in future if it becomes part of the mainstream package, or easy to add.

I have originally planned to use OpenHab, so above topic on MQTT + OpenHab would work. But for now I am having so much fun with Node-Red, and as a controller it is simple, (for now). For now, I would like to send an MQTT message to the channel that the ESP have subscribed to. I am testing with matt-spy, where I publish:
- Topic: /RHZA/ESP12-02/GPIO/16/ (I also tried it without the last /)
- Data: '-n 1' and also tried with '1'

In order to switch on a relay on GPIO16, and by the way, the http command http://192.168.2.64/control?cmd=GPIO,16,1 works, it switches on the relay.

The ESP's name is ESP12-02, and it subscribed to /RHZA/%sysname%/#

Question 1: The actuation of the relay with http works without me defining anything in the devices section. To get this to work, should I add a Devices item, maybe with the switch? From the wiki http://www.esp8266.nu/index.php/Relais it does not seam necessary.
Question 2: Anybody has ideas on how to use MQTT pure, to actuate a relay?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#2 Post by tozett » 24 Apr 2016, 14:22

SEND
if you define your relay-item in the devices section,
you can set in the config to openhab-mqtt,
than you can configure node-red to get the MQTT-messages.
(it assume, the relay/gpio can send his states via MQTT

and check them in the debug section (see picture here).


RECEIVE
than, (i did not do this yet), it think you can install the experimente MQTT receive plugin,
and use RULES to switch the Relay via MQTT.

??
may you go this way ... :roll:
Attachments
Zwischenablage02-2.png
Zwischenablage02-2.png (204.42 KiB) Viewed 34354 times

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#3 Post by JR01 » 25 Apr 2016, 12:00

tozett wrote:SEND
if you define your relay-item in the devices section,
you can set in the config to openhab-mqtt,
than you can configure node-red to get the MQTT-messages.
(it assume, the relay/gpio can send his states via MQTT
Thank you tozett, I am sending all my sensors successfully onto MQTT using Openhab-MQTT option on sensors. I do rain water, warm water flow from geyser, temp outside DS18b20, temp / hum inside, which the messages from MQTT is subscribed in Node-Red, which then processes data, and sends to Thingspeak, a MySQL on RasPi, as well as serve it to web pages using node-red nodes, which provides house participants to info, like cost of warm water used last hour / day / previous days / weeks.

As per your suggestion, which you say you have also not done yet, I now need to send MQTT messages to ESP to switch geyser on/off. I will try your suggestions.... Tx.
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#4 Post by tozett » 25 Apr 2016, 13:23

as node-red may can send http-request to fulfill your goal,
i am interested in your succesions in switching gpios with mqtt.
i would think, doing most things on the espeasy with mqtt will be a good and universal protocol option...

may you can show in short how you serve your webpage from node-red,
as i considered doing the same (when i find time..)
;-)

best luck,
tozett

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#5 Post by JR01 » 26 Apr 2016, 21:07

@tozett, what an honour to help you, you have helped me in my darkest hours of trying to get the ESP from stopping to reboot! It is really really easy with Node-Red. See the screen below. the temp and humid comes straight from MQTT connectors, the warm water analytics (same with water with tipping bucket, both into an ESP12E, R78) comes from writing water flow meter, that writes via MQTT into an MySQL db on RasPi, then I do a query with visual programming with the Node-Red UI node, here. http://flows.nodered.org/node/node-red-contrib-ui. I can share more if you like.

an honour!
Attachments
Screen Shot 2016-04-26 at 9.03.29 PM.png
Screen Shot 2016-04-26 at 9.03.29 PM.png (41.97 KiB) Viewed 34116 times
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#6 Post by JR01 » 26 Apr 2016, 21:10

Here is a visual of the Node-Red nodes and flow to construct the UI. I also have more pages on it, to report the costs of warm water, then I ping the ESP's every 5min to check if they are alive, then write this into the MySQL if not alive, so when I do analytics, I know when not to trust the data.

What do you think?
Screen Shot 2016-04-26 at 9.08.46 PM.png
Screen Shot 2016-04-26 at 9.08.46 PM.png (232.27 KiB) Viewed 34115 times
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#7 Post by tozett » 26 Apr 2016, 22:19

Fantastic!

i will go your way, too!! :D
(my next sparetime for this)

thanks for the insight. i guess we will meet here someplace again...

:D

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#8 Post by tozett » 27 Apr 2016, 08:21

i am on debian 8,
installed the node-red-UI, but it dont show up...
anybody with a hint for me ?
(google has not that much, mostly working or raspberry...)
:o
Attachments
Zwischenablage07-3.png
Zwischenablage07-3.png (94.13 KiB) Viewed 34049 times

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#9 Post by JR01 » 27 Apr 2016, 08:34

Did you remember to first change directory to the node red dir before issuing the command to get and install?

cd ~/.node-red

Only then issue the command : npm install node-red-xxxx (applicable package name)
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#10 Post by tozett » 27 Apr 2016, 09:00

hey thanks,
now working.

it was annoying, that i am a noob at so many things,
so i dived deeper into testing/googling and found, that the

Code: Select all

npm install <module>
installs node.js modules in the local dir....
cannot remember how i installed node-red, so i cannot remember why my modules are installed at

/usr/lib/node_modules

but as i found the node-red-contrib-ui directory in the local /root/directory,
i copied it to /usr/lib/node_modules and it is working..

dont know if i have to do more about that, but its running... :D
------------------------------
edit2: i searched my brain, how i installed this, and now think i must have done it like the doku said:
https://nodejs.org/en/download/package- ... tributions
so that i am not aware about the path...
maybe i had to install the ui with something like -global or the like.. dont know...
Attachments
Zwischenablage08.png
Zwischenablage08.png (79.6 KiB) Viewed 34042 times
Last edited by tozett on 27 Apr 2016, 09:14, edited 1 time in total.

fluppie
Normal user
Posts: 89
Joined: 09 Oct 2015, 13:23

Re: MQTT to Relay with Node-Red

#11 Post by fluppie » 27 Apr 2016, 09:10

https://openenergymonitor.org/emon/node/12437 check this RaspberryPi image, emonCMS, Jessie Lite, Node-Red & openHAB. It's booting pretty quick.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#12 Post by tozett » 27 Apr 2016, 09:16

that was it, install as global, -g

i investigated the install of node-red, and as the wiki/doku said, i installed it as -global

http://nodered.org/docs/getting-started/installation

so i had to intall the UI with the same global-flag "-g" to have it at the right place.. :)
Attachments
Zwischenablage10.png
Zwischenablage10.png (117.68 KiB) Viewed 28817 times

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#13 Post by tozett » 27 Apr 2016, 15:11

i want to thank you for the inspiration with the web-ui in node-red.
i also install the 1-wire owfs module, and have all temp-values from my other server..
fantastic...
Attachments
Zwischenablage13.png
Zwischenablage13.png (93.67 KiB) Viewed 28799 times

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#14 Post by JR01 » 27 Apr 2016, 18:42

+1 ! Looks like you have done a lot today! Could you show us a screen shot of the UI?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#15 Post by tozett » 27 Apr 2016, 19:15

node-red-ui component builds the ui itself,
cannot manually control html-elements. so it looks:
Attachments
Zwischenablage16-3.png
Zwischenablage16-3.png (62.8 KiB) Viewed 28791 times

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#16 Post by JR01 » 27 Apr 2016, 20:08

Very impressive, well done!
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#17 Post by JR01 » 28 Apr 2016, 20:09

JR01 wrote:Hi, I see a lot of discussions on using MQTT to actuate a relay. .....
Question 2: Anybody has ideas on how to use MQTT pure, to actuate a relay?
For those wondering if actuation of relays works through MQTT-OpenHab - it does.
I have subscribed to: /RHZA/ESP12-01/# on an ESP12E-01 on R105.

Pumping into /RHZA/ESP12-01/GPIO/16 (I use Node-Red)
with payload 0 or 1
Switches the relay on or off. Mine is a 100A used to switch my geyser.
And no need to register GPIO16 under devices.
Thank you to dev's, this is great!
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#18 Post by tozett » 28 Apr 2016, 20:23

thanks for proof...
i saw this by accident, thought it would work the way you described, but was not sure.
in some discussions, the dev stated nothing special to develop this way,
but, hey: great! it works!

https://github.com/ESP8266nu/ESPEasy/bl ... sy.ino#L94 (or does it has nothing to do with your findings.. :? 8-) )
Attachments
Zwischenablage01.png
Zwischenablage01.png (55.69 KiB) Viewed 28728 times

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#19 Post by tozett » 29 Apr 2016, 14:08

i dont know, if i am on the right track ( :roll: ),
but if you really can switch the GPIO with MQTT, than the other commands "could" work also?
i am a computerlanguage i-literate, but it this works, maybe it should be documented in the wiki?
maybe new with version r1xx?
:oops:
Attachments
Zwischenablage07-3.png
Zwischenablage07-3.png (104.66 KiB) Viewed 28698 times

crsherman
New user
Posts: 7
Joined: 20 Jun 2016, 14:52

Re: MQTT to Relay with Node-Red

#20 Post by crsherman » 20 Jun 2016, 15:01

JR01 wrote:Here is a visual of the Node-Red nodes and flow to construct the UI. I also have more pages on it, to report the costs of warm water, then I ping the ESP's every 5min to check if they are alive, then write this into the MySQL if not alive, so when I do analytics, I know when not to trust the data.

What do you think?

Screen Shot 2016-04-26 at 9.08.46 PM.png
JR01,
Would you mind sharing your node red json file?

I am in the process of setting up feeds from temperature sensors using Linkit and MQTT. I am receiving the data within node-red but am having trouble with the function node to feed into a mysql database.

Any help would be appreciated.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#21 Post by JR01 » 21 Jun 2016, 19:15

.@crsherman, yeah, would not mind sharing my .jsons. My RPi is down currently, busy with refurbishment of the breadboards for ESP8266 to sensors - building into vera board solutions to take out instability, need to fire RPi up again next 3 days, then I will upgrade to the latest cool version 0.14.3 of NodeRed, then will post for you. I have lots going on on my .json file, point me to what you want to achieve so I can lift that out to start off with? And are you also interested in creating the phone html 'app' I use to control things with?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

crsherman
New user
Posts: 7
Joined: 20 Jun 2016, 14:52

Re: MQTT to Relay with Node-Red

#22 Post by crsherman » 21 Jun 2016, 23:04

JR01 wrote:.@crsherman, yeah, would not mind sharing my .jsons. My RPi is down currently, busy with refurbishment of the breadboards for ESP8266 to sensors - building into vera board solutions to take out instability, need to fire RPi up again next 3 days, then I will upgrade to the latest cool version 0.14.3 of NodeRed, then will post for you. I have lots going on on my .json file, point me to what you want to achieve so I can lift that out to start off with? And are you also interested in creating the phone html 'app' I use to control things with?

Thanks JR01!

Yes - definitely interested in the phone html app to control things.

My setup as it stands now:
1.) numerous sensors for temperature, humidity and weather using Linkit Duo and Grove sensors (soil moisture, temperatue, humidity at various locations). I wish to integrate these fully into NR for graphical display to a webpage for weather information for the family use.
2.) several other rasperry pi's and arduino's around the house setup for control of garage, outdoor lighting, misting system, and pool pumps. No rhyme or reason to why the mix - just developed that way
3.) MQTT Broker - mosquitto setup on macmini
3.) Node red server setup on same macmini
4.) Mysql database within MAMP setup on same macmini

I currently have most of my sensors publishing topics to my broker using Pubsubclient. I have most of these integrated into my NR flow but still having issues with the topic being saved to a mysql database. I currently have the datA but not the datE or timestamp being saved (still trying to work through a timestamp node injection - looking at thethingbox-node-timestamp ).

Looking at the next step of converting my arduino's and rpi's over to being controlled by my node-red flow. I have started this effort but am trying to get up to speed on tying NR to an html page. I have been studying and reading Peter Scargill's site extensively and was looking at Imperihome when i came across your blog.

All of this being done with the thought that whatever i come up with - the wife and kids can use easily (maybe the hardest part of all of this).

Any guidance/help or examples would be much appreciated.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#23 Post by JR01 » 21 Jun 2016, 23:46

In the mean time, some help to get the MySQL going: below is what I have in a function node, receiving for instance humidity from MQTT, and prior to a MySQL node.

ValA = msg.payload ;
msg.topic = "INSERT INTO `SysTaskVal2day` (`idSystem`, `idTask`, `tmstamp`, `val`) VALUES (1,1,now(),"+ValA+");" ;
return msg;

Check out my DB schema of MySQL here:

http://iotplay.blogspot.co.za/2016/05/a ... ation.html
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

crsherman
New user
Posts: 7
Joined: 20 Jun 2016, 14:52

Re: MQTT to Relay with Node-Red

#24 Post by crsherman » 22 Jun 2016, 05:29

JR01 wrote:In the mean time, some help to get the MySQL going: below is what I have in a function node, receiving for instance humidity from MQTT, and prior to a MySQL node.

ValA = msg.payload ;
msg.topic = "INSERT INTO `SysTaskVal2day` (`idSystem`, `idTask`, `tmstamp`, `val`) VALUES (1,1,now(),"+ValA+");" ;
return msg;

Check out my DB schema of MySQL here:

http://iotplay.blogspot.co.za/2016/05/a ... ation.html

Never thought to just put the timestamp into the sql query - duh!

I was taking the following approach.

Function timestamp Node with the following code:

msg.payload.data.date = new Date();
msg.payload = msg.payload.data;
return msg;

Function query node with the following code:

msg.topic = "insert into tempreadings (tmstamp, humidity, temp1) values (" + msg.payload.date + "," + msg.payload.temperature + "," + msg.payload.humidity + ")";
return msg;

Both of these sequentially feeding into a mysql node with the appropriate database information. The date piece was still giving me fits. I like your approach better and can easily modify my node flow - THANKS!

I took a look at your DB schema and was impressed. Logical way of approaching the setup of the databases. I was looking at the necessary setup to feed Imperihome also (still not sure if I want to go this route or the route of just html pages - quite frankly do not know enough to even know what i am getting into in regards to programming the flow for imperihome). Alot of information on Peter's blog on this. Any comment on whether or not your schema would still support their requirements.

Again - thanks for the help!

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#25 Post by JR01 » 22 Jun 2016, 06:33

I want to still look at Imperihome sometime, looked a bit after Pete blogged about it some weeks ago. But I am a bit of a purist, and the reason why I do home automation is not for the home automation, but to prove IoT concepts and to create parallels people can understand easily. So the database, and ability to do analytics on it, is key for me at this stage. I also tried that node with time stamp, was not able to get it going, but probably could have tried harder.
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#26 Post by JR01 » 22 Jun 2016, 07:57

Since I posted the info on my blog regarding the MySQL db design, and the issues blogged on Pete's blog and I also found prior to that discussions on OpenHab forums that RPi writes to sd card crashes at some point, as sd cards only has a limited amnt of writes, I implemented the concept proposal made by one of the users on Pete's site, with suggestion to mount a table with type Memory in the db, do the day's mqtt sensor writes to that table, which runs in memory, thus saving sd card writes, and that night at 24:00 write the temp in memory table to sd card once. This is working very well. Will share more details if you are interested. Still need to upd my blog with that outcome.
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

pppp33
Normal user
Posts: 71
Joined: 25 Oct 2015, 17:53

Re: MQTT to Relay with Node-Red

#27 Post by pppp33 » 22 Jun 2016, 22:17

YOU ARE TERRIFIC ! ;)
great work !
Thanx for sharing.....
paolo

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#28 Post by JR01 » 22 Jun 2016, 23:23

crsherman, I see you say you are also interested in the UI tool I used on NodeRed, not much to it, check out this node:
http://flows.nodered.org/node/node-red-contrib-ui. Once loaded & wired-up, you fire it up on mobile browser on your home wireless with: http://localhost:1880/ui

On my blog I briefly show the interface I have built, will write more what I have learnt of the family using it in future, and progress on it, see image of an earlier version here:
Image
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

crsherman
New user
Posts: 7
Joined: 20 Jun 2016, 14:52

Re: MQTT to Relay with Node-Red

#29 Post by crsherman » 28 Jun 2016, 02:44

JR01 wrote:crsherman, I see you say you are also interested in the UI tool I used on NodeRed, not much to it, check out this node:
http://flows.nodered.org/node/node-red-contrib-ui. Once loaded & wired-up, you fire it up on mobile browser on your home wireless with: http://localhost:1880/ui

On my blog I briefly show the interface I have built, will write more what I have learnt of the family using it in future, and progress on it, see image of an earlier version here:
Image


JR01,
I installed the node-red-contrib-ui and have been able to setup temperature feeds from mqtt but do not understand how I would go about controlling a pin on my remote Linkit Duo. Are you using mqtt to control the geyser switch? Any help would be appreciated.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#30 Post by JR01 » 28 Jun 2016, 22:20

Controlling geyser with MQTT ? = yes.

In an 'MQTT out' node, make the topic the below, and pass 1 into it via a flow:
/ESP03/GPIO/2

Means the following: Send to ESP03, to the GPIO, for pin 2, and switch it on.

Remember to make your MQTT subscribe template on the ESP:
/%sysname%/#

And the name of the ESP - in this case, is ESP03.

voila !

And the flow for the UI to switch it? I have a button, where the family can override the geyser on/off, which is on a schedule, but the override counts down 25min, then it switch the geyser off again.

Image
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

crsherman
New user
Posts: 7
Joined: 20 Jun 2016, 14:52

Re: MQTT to Relay with Node-Red

#31 Post by crsherman » 29 Jun 2016, 04:54

JR01 wrote:Controlling geyser with MQTT ? = yes.

In an 'MQTT out' node, make the topic the below, and pass 1 into it via a flow:
/ESP03/GPIO/2

Means the following: Send to ESP03, to the GPIO, for pin 2, and switch it on.

Remember to make your MQTT subscribe template on the ESP:
/%sysname%/#

And the name of the ESP - in this case, is ESP03.

voila !

And the flow for the UI to switch it? I have a button, where the family can override the geyser on/off, which is on a schedule, but the override counts down 25min, then it switch the geyser off again.

Image

Ok - I think I understand better but have a few questions.

I am using pubsubclient for arduino. So I believe my template code for subscribing to this topic would be something similar to this:

client.subscribe("ESP03/#"); --- I believe that this is what you are referring to when you mention the subscribe template???

I take it I also have to setup the appropriate pin modes on my duo also???

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#32 Post by JR01 » 29 Jun 2016, 06:08

No, the substibe template setting is on Advanced tab on EspEasy, I will oost a pic tonight if you are not finding it
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

tozett
Normal user
Posts: 734
Joined: 22 Dec 2015, 15:46
Location: Germany

Re: MQTT to Relay with Node-Red

#33 Post by tozett » 29 Jun 2016, 08:48

sub2.png
sub2.png (50.04 KiB) Viewed 30806 times

jram
New user
Posts: 5
Joined: 01 Jul 2016, 19:03

Re: MQTT to Relay with Node-Red

#34 Post by jram » 02 Jul 2016, 11:29

This is a great thread. I've been doing node-red for a while now but have only recently discovered ESPeasy.

One of the challenges that we face is learning to install and configure all this stuff. I found a great script on Peter Scargills site that almost completely automates the installation of Node Red, SQL Lite and all the support you need to get going from a 'bare' pi. Its here... http://tech.scargill.net/installing-the-works/

crsherman
New user
Posts: 7
Joined: 20 Jun 2016, 14:52

Re: MQTT to Relay with Node-Red

#35 Post by crsherman » 18 Jul 2016, 00:57

JR01 wrote:.@crsherman, yeah, would not mind sharing my .jsons. My RPi is down currently, busy with refurbishment of the breadboards for ESP8266 to sensors - building into vera board solutions to take out instability, need to fire RPi up again next 3 days, then I will upgrade to the latest cool version 0.14.3 of NodeRed, then will post for you. I have lots going on on my .json file, point me to what you want to achieve so I can lift that out to start off with? And are you also interested in creating the phone html 'app' I use to control things with?

JR01,
Would you mind lifting the geyser json first and sharing?

Thanks,
crsherman

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#36 Post by JR01 » 18 Jul 2016, 20:40

Sure, I did a write-up for you, with the json on my blog:

http://iotplay.blogspot.com/2016/07/swi ... es-on.html
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#37 Post by JR01 » 24 Jul 2016, 12:32

the boys over at node-red are about to release a new DASHBOARD on npm. I got it working on the pre-release, and IT IS AWESOME.

http://iotplay.blogspot.co.za/2016/07/u ... d.html?m=1

Image
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

crsherman
New user
Posts: 7
Joined: 20 Jun 2016, 14:52

Re: MQTT to Relay with Node-Red

#38 Post by crsherman » 24 Jul 2016, 15:23

JR01 wrote:Sure, I did a write-up for you, with the json on my blog:

http://iotplay.blogspot.com/2016/07/swi ... es-on.html
JR01,
Just got a chance to read and study your blog - it was just what I needed to understand the flow - thank you for sharing.

I am in the process of using espeasy and I have my project moving in the right direction thanks to you - much appreciated.

CRS

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT to Relay with Node-Red

#39 Post by JR01 » 24 Jul 2016, 22:59

8-) Your welcome !
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests