MQTT : Payload

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
CRS
New user
Posts: 2
Joined: 11 Mar 2018, 16:21

MQTT : Payload

#1 Post by CRS » 11 Mar 2018, 16:26

sorry for such a easy question however i am new to this.

is there away to change the MQTT : Payload from sending 1 and 0 to ON and OFF

if so how would i go about it?

Thank you

spachal
Normal user
Posts: 55
Joined: 22 Feb 2018, 22:11

Re: MQTT : Payload

#2 Post by spachal » 11 Mar 2018, 17:37

Hi, yes, you can do it by rules and Publish command, you can send anything you need to your broker :)
Or, if you're using openHAB and need this format of message there, you can change it by transformation map.
Please excuse my English, thanks!

CRS
New user
Posts: 2
Joined: 11 Mar 2018, 16:21

Re: MQTT : Payload

#3 Post by CRS » 11 Mar 2018, 19:28

would you be able to tell me what i would need to add to the rules to do this. i am using openHAB but dont know how to change it by transformation map.

many thanks

spachal
Normal user
Posts: 55
Joined: 22 Feb 2018, 22:11

Re: MQTT : Payload

#4 Post by spachal » 12 Mar 2018, 10:47

Hi, can you describe your situation or give us your current rules configuration?

For example, you're using PIR sensor and you need to send state to broker .. You have defined PIR as device and need to record it's state.
By default, you can use function in Device setting, Data Acquisition > Send to Controller to send payload, but you can't influence this payload. In this case you need to handle it in openHAB, using transformation map. Some good expamation is here: https://github.com/openhab/openhab1-add ... ansforming . You have to define small map file and use it in OH item definition (0=OFF, 1=ON).

But maybe better solution is send 'correct' payload already from ESP :]. It's easy, at first uncheck Send to Controller checkbox in Device. Then create rule:

Code: Select all

On PIR#Switch do
   If [PIR#Switch]=1
     Publish %sysname%/<PIRtopic>,ON
   Else
     Publish %sysname%/<PIRtopic>,OFF
   Endif
Endon
Hope it helps :]
Please excuse my English, thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests