Rules and triggers

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Rules and triggers

#1 Post by garnold » 19 Jun 2019, 05:14

I've been digging into the Rules section of the wiki and trying to test out some triggers to use for my project. I'd like an LED to light when WiFi is connected, same for MQTT connected and lastly every time an MQTT Publish happens. I've found the WiFi and MQTT triggers but not one for the MQTT Publish. Also, the Wifi and MQTT connect triggers do not seem to be firing for me.

This works
On System#Boot do
gpio,16,1
endon

But these do not
On MQTTimport#Connected do
gpio,16,1
endon

On WiFi#Connected do
gpio,16,1
endon

Am I doing something wrong?

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

Re: Rules and triggers

#2 Post by grovkillen » 19 Jun 2019, 06:16

Are you sure they don't work? Looked in the logs?
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:

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Rules and triggers

#3 Post by garnold » 19 Jun 2019, 13:51

I’m just basing this on the fact that the led I have attached to the gpio does not light up. When I run the system boot rule the led lights up fine. I’ll check the logs but why would that be diffferent?

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules and triggers

#4 Post by ThomasB » 19 Jun 2019, 18:36

I’ll check the logs but why would that be diffferent?
It should show entries for GPIO-16 and other events so you can debug the problem. But you should use Serial Log (not web log) because the WiFi and MQTT rule actions will occur before web log has begun.

BTW, I tested ESP_Easy_mega-20190409_normal_ESP8285_1M.bin on a Sonoff Basic and confirmed that MQTTimport#Connected and WiFi#Connected work correctly. You didn't say which version you are using, so if it's not a recent release then try the latest MEGA version.

Please note that MQTTimport#Connected requires that you have a properly configured MQTT Controller **and** have also enabled the Generic MQTT Import plugin. If the MQTT Import plugin is not installed then use the MQTT#Connected rule instead.

- Thomas

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Rules and triggers

#5 Post by garnold » 19 Jun 2019, 18:55

Thank you Thomas and you are correct, should have posted the version I'm using. Currently I'm trying to use up these 1mg Wemos D1 mini boards I have. Since they only have 1mg flash I'm using the ESPEasy_R120_1024.bin build. Can I use the serial monitor on this build? I'll keep testing more tonight.

Thank you

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules and triggers

#6 Post by ThomasB » 19 Jun 2019, 19:08

ESPEasy_R120_1024.bin is old legacy code. It might not support what you are trying to do. Install the latest MEGA release and try again.

- Thomas

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Rules and triggers

#7 Post by garnold » 19 Jun 2019, 22:24

From what I'm reading, I don't think I can run mega (easily) on this little 1 mg Wemos :-(
That is completely cool because ESP Easy is rather powerful and getting it all to fit on a little 1mg slot it crazy!
I have more then enough functionality to do what I need right now with this older build to play with and will just have to pick up some 4mg Wemos boards.
Really not a problem and worth it to get to use the Mega build HAHAHA!

Running on 1mg
https://www.letscontrolit.com/wiki/inde ... MB_modules

Thank you again!

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules and triggers

#8 Post by ThomasB » 19 Jun 2019, 23:59

From what I'm reading, I don't think I can run mega (easily) on this little 1 mg Wemos
As mentioned earlier, I tested your rule examples with ESP_Easy_mega-20190409_normal on a 1MB Sonoff module. Your 1MB Wemos should work fine too if you flash with a MEGA release that was built for your 1M modules. You can't OTA flash, you need to use serial flash.

- Thomas

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Rules and triggers

#9 Post by garnold » 20 Jun 2019, 00:24

Sounds good to me! I'll get the USB cable out now and play HAHAHA! Thank you

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Rules and triggers

#10 Post by garnold » 20 Jun 2019, 01:56

Quick update. I flashed ESP_Easy_mega-20190607_normal_core_241_ESP8266_1M to the Wemos and it installed fine. Would this be the latest version? I'm not sure what the 241 means in the build name and saw some higher numbers in the list. Regardless, just like you said Thomas, both rules work perfectly! I did end up using the MQTT rather then MQTTImport. I didn't realize the difference so thank you for pointing that out. I'm going to do some more playing with rules because I would like to have the LED blink when an MQTT publish is sent. I'm pretty sure I saw an event for that so I'll go have some fun!

Honestly I have to say that once I get the hang of ESP Easy it's gonna be so much easier to create my IoT projects. I'll still be hacking away at the Arduino IDE for my other stuff but for sensor communication this is the way to go for sure!

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules and triggers

#11 Post by ThomasB » 20 Jun 2019, 02:42

I flashed ESP_Easy_mega-20190607_normal_core_241_ESP8266_1M to the Wemos and it installed fine. Would this be the latest version?
At the moment it is the latest.
... both rules work perfectly!
Congrats on your success.

- Thomas

garnold
Normal user
Posts: 93
Joined: 17 Jun 2019, 03:59

Re: Rules and triggers

#12 Post by garnold » 20 Jun 2019, 03:32

Whelp, I guess I miss read the events in the wiki. I thought I saw one for when an MQTT publish happens. Right now I have all my hardware together and I tested everything based on System Boot, WiFi Connect, MQTT Connect just to confirm that the rules would work and that my horrible solder skills held up! HAHAHA

Is there an event that I can listen for that fires when an MQTT Publish happens?

Thank you

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Rules and triggers

#13 Post by ThomasB » 20 Jun 2019, 03:44

Is there an event that I can listen for that fires when an MQTT Publish happens?
Instead of using a plugin's Send to Controller option, you can create rules that are triggered when the device's value changes. In the rule you can publish the MQTT message, plus call a timer rule that winks the LED.

- Thomas

Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 55 guests