Rules & MQTT

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ambassadoro
Normal user
Posts: 40
Joined: 17 Nov 2015, 15:58

Rules & MQTT

#1 Post by ambassadoro » 05 Aug 2016, 20:00

Hi,
I created a simple rule to switch on a light when I press a pushbutton connected to a GPIO.

Code: Select all

on Taster#Taster do
  if [Taster#Taster]=0
    gpio,12,0
  else
    gpio,12,1
  endif
endon
Works great! But when I send via mqtt:

Code: Select all

mosquitto_pub -q 1 -d -t /Garten/Taster/Taster -m 1
The light is switched on, but when I press the button, I need to press twice to get it off. Seems that the value doesn't get set to 1 via MQTT.
What can I do for finetuning to get rid of this behaviour?

Update:
I tried around and found no solution so far. But I am trying something different, I like to address the rules directly via mqtt, but so far I had no luck. How can this be done?

Martinus

Re: Rules & MQTT

#2 Post by Martinus » 11 Aug 2016, 21:30

ambassadoro wrote:I tried around and found no solution so far. But I am trying something different, I like to address the rules directly via mqtt, but so far I had no luck. How can this be done?
Could you elaborate more on "address the rules directly via MQTT" ?
Do you mean to trigger an event from MQTT?
You can send an event using the "event <event>" command on topic <template>/cmd

ambassadoro
Normal user
Posts: 40
Joined: 17 Nov 2015, 15:58

Re: Rules & MQTT

#3 Post by ambassadoro » 12 Aug 2016, 10:35

Martinus wrote: Do you mean to trigger an event from MQTT?
You can send an event using the "event <event>" command on topic <template>/cmd
Yes! I like to send to an event. I try this soon. Thank you.
And I like to "inject" a value in a rule. for example, a timer-value. For example, a light should stay on for X seconds, depending on the value thats transmitted by MQTT. How does the payload then look like?

ambassadoro
Normal user
Posts: 40
Joined: 17 Nov 2015, 15:58

Re: Rules & MQTT

#4 Post by ambassadoro » 15 Aug 2016, 13:52

Hi,

now I have a static working solution. I first define a timer, in the rules, then I call it via MQTT:

Code: Select all

/myesp/cmd/TimerSet
Now I can start a predefined timer. The only thing thats missing that I like to "inject" the timer-time first before I start it.

Post Reply

Who is online

Users browsing this forum: No registered users and 103 guests