[solved]mqtt button ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bledad
Normal user
Posts: 82
Joined: 23 Nov 2020, 10:57
Location: France

[solved]mqtt button ?

#1 Post by bledad » 27 Jul 2022, 16:17

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
Last edited by bledad on 29 Jul 2022, 11:16, edited 1 time in total.

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: mqtt button ?

#2 Post by Ath » 27 Jul 2022, 16:26

This part is not going to work:

Code: Select all

  if mqtt#sonnette = on
(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
/Ton (PayPal.me)

bledad
Normal user
Posts: 82
Joined: 23 Nov 2020, 10:57
Location: France

Re: mqtt button ?

#3 Post by bledad » 27 Jul 2022, 17:16

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 ?

bledad
Normal user
Posts: 82
Joined: 23 Nov 2020, 10:57
Location: France

Re: mqtt button ?

#4 Post by bledad » 28 Jul 2022, 13:56

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 :

Code: Select all

Publish sonnette_status auto
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

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 18 guests