Page 1 of 1
[solved]mqtt button ?
Posted: 27 Jul 2022, 16:17
by bledad
hello,
before I start, I would like to know if it is possible
i've mqtt server , the channel is : actions_bouton
i publish : sonnette#on , sonnette#off
from the espeasy side I would like
example :
Code: Select all
On Clock#Time=All,**:** Do
if mqtt#sonnette = on
if %syssec_d% > 28800 and %syssec_d% < 72000 //de 7h a 20h
gpio,13,0
else
gpio,13,1
endif
endif
if mqtt#sonnette = off
gpio,13,1
endif
endon
i,ve 8 button , its for each button
but now, I don't know how to do it
Re: mqtt button ?
Posted: 27 Jul 2022, 16:26
by Ath
This part is not going to work:
(Same for the one with 'off' )
as ESPEasy doesn't yet support string handling like that.
Depending on the build you use (Custom and MAX, AFAIR), the MQTT Import plugin can be configured to translate an on or off state to a numeric value (1 and 0 seem most appropriate), and stored in a Dummy task value.
Then that dummy can be checked:
Code: Select all
On Clock#Time=All,**:** Do
if [Dummy#Button1]=1 // Expects a `Generic - Dummy` task, with value Button1
if %syssec_d% > 28800 and %syssec_d% < 72000 //de 7h a 20h
gpio,13,0
else
gpio,13,1
endif
else // It must be off
gpio,13,1
endif
endon
Re: mqtt button ?
Posted: 27 Jul 2022, 17:16
by bledad
ok ,
i use "ESP_Easy_mega_20220616_normal_ESP8266_4M1M"
i think have a probleme , because some buttons has three state ( on, off , auto)
I need to rename the mqtt states?
ex : on > 1 , off > 2 , auto >3
and after for link mqtt with dummy in rules ?
Re: mqtt button ?
Posted: 28 Jul 2022, 13:56
by bledad
ok , iv'e renamed the mqtt states by value
now , in my mqtt server i have
channel : actions_bouton
topics : sonnette
if i put in rules :
mqtt server not receive
i do :
in controllers : openhab(mqtt) enable with ip , Controller Subscribe : actions_bouton/# and Controller Publish: actions_bouton/#
in Devices : MQTT Import enable with MQTT Topic 1: sonnette
what is the format mqtt for espeasy ?
or how to transcribe
Code: Select all
mosquitto_pub -h 192.168.1.51 -t 'actions_bouton' -m 'sonnette_status#1'
in espeasy ??
please
thank