via MQTT-subscription: LED ON/OFF

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
binderth
New user
Posts: 6
Joined: 15 Apr 2022, 10:08

via MQTT-subscription: LED ON/OFF

#1 Post by binderth » 23 Mar 2023, 09:25

First off:
What's the best practise for sending to MQTT-topic 0:OFF and 1:ON for LED attached to an GPIO-port of an ESP?

What I did now:

1. added an MQTT device "ampelMQTT" listening to MQTT topic(s) and writing their payload to a variables: Ampel1, Ampel2
2. I send for each "traffic light"(aka Ampel in German): 0:green,1:red,2:yellow
3. the variables get updated in the Device/Value overview
4. I tried to add a rule:

Code: Select all

On ampelMQTT#Ampel1 Do
  logentry,"MQTT import Ampel1Gruen: %eventvalue1%"
  If %eventvalue1%=0
    GPIO,14,1
  Else
    GPIO,14,0
  Endif
  If %eventvalue1%=1
    GPIO,13,1
  Else
    GPIO,13,0
  Endif
Endon
So, my log shows this:

Code: Select all

3973110 : Info   : WD   : Uptime 66 ConnectFailures 0 FreeMem 17256 WiFiStatus WL_CONNECTED 3 ESPeasy internal wifi status: Conn. IP Init
3976473 : Info   : IMPT : [ampelMQTT#Ampel1] : 0.00
3980722 : Info   : IMPT : [ampelMQTT#Ampel1] : 1.00
So, for me the rule is not triggered? but how is this?

Thanks for your help!

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

Re: via MQTT-subscription: LED ON/OFF

#2 Post by TD-er » 23 Mar 2023, 09:55

Have you checked the checkbox "Generate events for accepted topics" ?

binderth
New user
Posts: 6
Joined: 15 Apr 2022, 10:08

Re: via MQTT-subscription: LED ON/OFF

#3 Post by binderth » 23 Mar 2023, 10:28

Thanks! That was it!

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests