MQTT input in rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
werner_g
Normal user
Posts: 31
Joined: 11 Jun 2017, 14:19

MQTT input in rules

#1 Post by werner_g » 03 May 2018, 15:41

My watering systems grows in line with all the plants in springtime. I have this rules working, and I receive MQTT-messages in my Node-RED:

Code: Select all

On startwatering do 
   Pulse,4,1,40
   Pulse,5,0,40 //start watering (open valve)
   Publish aussen/state/WM/Garten01/watering,startwatering
   timerSet,1,60 //timer 1 set for 1 minutes
endon
I need help - I have no idea how I can send a MQTT-message from Node-RED (or any other system) to open/close the valve.

User avatar
grovkillen
Core team member
Posts: 3331
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: MQTT input in rules

#2 Post by grovkillen » 03 May 2018, 17:07

ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

werner_g
Normal user
Posts: 31
Joined: 11 Jun 2017, 14:19

Re: MQTT input in rules

#3 Post by werner_g » 04 May 2018, 00:05

Thanks. So I modified my rules in adding the event-command:

Code: Select all

On startwatering do 
   Pulse,4,1,40
   Pulse,5,0,40 //start watering (open valve)
   Publish aussen/state/WM/Garten01/watering,startwatering
   event,MQTTwatering=startwatering
   timerSet,1,60 //timer 1 set for 1 minutes
endon
But nothing happens when I set this command:

Code: Select all

msg: aussen/state/WM/Garten01/watering/cmd
payload: event,MQTTwatering
So still I am looking for help.

User avatar
grovkillen
Core team member
Posts: 3331
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: MQTT input in rules

#4 Post by grovkillen » 04 May 2018, 00:26

werner_g wrote:
04 May 2018, 00:05
Thanks. So I modified my rules in adding the event-command:

Code: Select all

On startwatering do 
   Pulse,4,1,40
   Pulse,5,0,40 //start watering (open valve)
   Publish aussen/state/WM/Garten01/watering,startwatering
   event,MQTTwatering=startwatering
   timerSet,1,60 //timer 1 set for 1 minutes
endon
But nothing happens when I set this command:

Code: Select all

msg: aussen/state/WM/Garten01/watering/cmd
payload: event,MQTTwatering
So still I am looking for help.
You're calling an event that you have not defined, try this:

Code: Select all

payload: event,startwatering
And remove this one:

Code: Select all

event,MQTTwatering=startwatering
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

werner_g
Normal user
Posts: 31
Joined: 11 Jun 2017, 14:19

Re: MQTT input in rules

#5 Post by werner_g » 04 May 2018, 09:36

so easy... thanks a lot, of course now it works!

joyNstay
Normal user
Posts: 9
Joined: 11 Jul 2018, 14:42

Re: MQTT input in rules

#6 Post by joyNstay » 11 Jul 2018, 15:11

Did this works if you want to set the rules for the lights too? I mean If you want to set a rule that opens the light and close it after 8 hours? or it is possible only for some seconds?
Thanks

waspie
Normal user
Posts: 117
Joined: 09 Feb 2017, 19:35

Re: MQTT input in rules

#7 Post by waspie » 12 Jul 2018, 02:50

joyNstay wrote:
11 Jul 2018, 15:11
Did this works if you want to set the rules for the lights too? I mean If you want to set a rule that opens the light and close it after 8 hours? or it is possible only for some seconds?
Thanks
the sky is the limit.

whatever is sending the mqtt should be able to send whenever you want it to...

joyNstay
Normal user
Posts: 9
Joined: 11 Jul 2018, 14:42

Re: MQTT input in rules

#8 Post by joyNstay » 12 Jul 2018, 11:37

Nice! If I understood correctly this rules can only me applied and change throw the website of ESP easy ,right? Is it possible to create a custom UI to change the rules? For example may be there are some numbers to the rules that I want to change with the press of a button? What should I look for?

User avatar
grovkillen
Core team member
Posts: 3331
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: MQTT input in rules

#9 Post by grovkillen » 12 Jul 2018, 11:50

Yes you can do that with dummy devices. Store the value with them.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

joyNstay
Normal user
Posts: 9
Joined: 11 Jul 2018, 14:42

Re: MQTT input in rules

#10 Post by joyNstay » 12 Jul 2018, 12:04

I don't know if that will work... It seems that this is just commands in the rule section. When I wrote button I mean a visual button in the browser. Sorry for the confusion.

User avatar
grovkillen
Core team member
Posts: 3331
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: MQTT input in rules

#11 Post by grovkillen » 12 Jul 2018, 12:34

No problem to send HTTP commands using a web interface. Or what's the hiccups?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

waspie
Normal user
Posts: 117
Joined: 09 Feb 2017, 19:35

Re: MQTT input in rules

#12 Post by waspie » 12 Jul 2018, 14:34

joyNstay wrote:
12 Jul 2018, 12:04
I don't know if that will work... It seems that this is just commands in the rule section. When I wrote button I mean a visual button in the browser. Sorry for the confusion.
i don't think the espeasy is really meant to be used as a control panel (of sorts). it's more for setting up the device to control things (motors, lights, etc). what you need is home automation software that sends the commands to the esp and then the esp makes it happen.


you need to be looking at openhab, domoticz, home assistant, etc.

joyNstay
Normal user
Posts: 9
Joined: 11 Jul 2018, 14:42

Re: MQTT input in rules

#13 Post by joyNstay » 18 Jul 2018, 16:13

So If I have understood currently ESPeasy is more to send an signal and the esp do it immediately and software like openhab is more hard coded and you have the logic in the esp( or sonoff)?

TD-er
Core team member
Posts: 1935
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: MQTT input in rules

#14 Post by TD-er » 18 Jul 2018, 22:13

joyNstay wrote:
18 Jul 2018, 16:13
So If I have understood currently ESPeasy is more to send an signal and the esp do it immediately and software like openhab is more hard coded and you have the logic in the esp( or sonoff)?
ESPeasy has a number of possibilities.
For example:
- Operate sensors/displays on a number of pins. (support for specific sensors is done in "Plugins" or "Tasks" as they are called in ESPeasy)
- Collect data from the sensors and do some simple computations on them. (Formulas at the bottom of each "plugin" page)
- Send sensor data to a number of typical data-collecting/processing units (they are called controllers in ESPeasy)
- Act on events and perform some time-based actions (Rules in ESPeasy)

Its possibilities are not limited to these, but in general it is the functionality of ESPeasy.

The controllers interface to some other tools, which are often more the general interface hubs of the home automation system.
For example Domoticz, OpenHAB, HomeAssistant, etc.

There is also a plugin called MQTT input, which is just plainly a hack, since it does not fit as plugin (a plugin interacts with hardware) and it is not used as a controller (what it should be)
Problem with the current implementation of controllers is that they're just sending data and not (yet) meant to collect data, so I get why it was written like it is now.

I hope it is now a bit more clear how each interacts with eachother.
N.B. this may (and will) change/shift in the future, but for now, that's how it is working.

joyNstay
Normal user
Posts: 9
Joined: 11 Jul 2018, 14:42

Re: MQTT input in rules

#15 Post by joyNstay » 19 Jul 2018, 00:47

Thank you for you reply but still nobody has answer my question. Can from the ESPeasy and maybe MQTT change the code from ESP( foe example sonoff)?
For example some how to say to sonoff turn on in 3 hour and after 4 hours turn off. And that will happened both when it is connected to the network and when it is not connected. I have found that it is possible throw MQTT message but MQTT works only when it is connected to the network because the message is turn onn/off NOW. I need a tool to do time scheduling. Do you know anything about that?

User avatar
grovkillen
Core team member
Posts: 3331
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: MQTT input in rules

#16 Post by grovkillen » 19 Jul 2018, 08:06

You can use event command and send a integer/float values as %eventvalue% and that value could be used as the timer duration.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

wim16
Normal user
Posts: 77
Joined: 01 May 2017, 20:35

Re: MQTT input in rules

#17 Post by wim16 » 19 Jul 2018, 09:48

And you might store the %eventvalue% in a dummy variable so that it is still available when there is no network connection.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests