I have just started to look at your code to build an IR blaster type device with 433MHz support. I am using a Wemos D1 mini style board and built a binary using the following in a prod_env.ini file.
To make it easier for me to integrate into openHAB, I wanted to use the simple publishing/receiving presuming I would just get a numerical “value” to publish to the mqtt broker and cause an IR pulse to be transmitted.
When I press my IR remote, I get two strings of data seen on the ‘/IRtoMQTT’ topic seen in the ‘mqtt.fx’ software. One is a string of numbers e.g. 12345678 and the other seems to be the JSON output {“value”:12345678, etc…etc…}.
To publish using openHAB as the control, I have setup some virtual switches that use a rule to publish the JSON path'{"value":12345678}'. This works but I thought I should just be able to publish 12345678 instead.
I noticed that the /SYStoMQTT topic is also in JSON format. Can I force all topics to report just their individual payloads rather than JSON outputs? I was hoping to set all configurations using the prod_env.ini file so I didn’t need to modify the ‘Github’ files every time there is an update to the code.
I use the text file approach with openHAB rather than PaperUI. This is what I have got working using JSON encoded mqtt messages. You need to have the JSONPATH transformation add-on and I use the EXPIRE binding to create openHAB switches that send the JSON payload as a String when selected ON using a rule. The EXPIRE binding then returns that switch back to OFF. I have setup four switches for four remote functions on my LG TV. I’ll probably make a .items and .rules for each remote I want to replicate.
.THINGS
Bridge mqtt:broker:mqtt-broker {
Thing mqtt:topic:MQTT_GATEWAY "Open MQTT Gateway" @ "MQTT-IR" {
Channels:
Type string : GW_version [ stateTopic="home/OpenMQTTGateway_D1/version" ]
Type string : GW_online [ stateTopic="home/OpenMQTTGateway_D1/LWT" ]
Type string : GW_IR_Rx [ stateTopic="home/OpenMQTTGateway_D1/IRtoMQTT" ]
Type string : GW_Sys [ stateTopic="home/OpenMQTTGateway_D1/SYStoMQTT" ]
Type string : GW_MQTT_IR [ commandTopic="home/OpenMQTTGateway_D1/commands/MQTTtoIR" ]
}
}
.ITEMS
String GW_version "Gateway Version" { channel="mqtt:topic:MQTT_GATEWAY:GW_version" }
String GW_online "Gateway Online" { channel="mqtt:topic:MQTT_GATEWAY:GW_online" }
String GW_IR_Rx "Gateway IR Rx [JSONPATH($.value):%s ] " { channel="mqtt:topic:MQTT_GATEWAY:GW_IR_Rx" }
String GW_Sys_RSSI "Gateway RSSI [JSONPATH($.rssi):%s ] " { channel="mqtt:topic:MQTT_GATEWAY:GW_Sys" }
String GW_Sys_UT "Gateway Uptime [JSONPATH($.uptime):%s ] " { channel="mqtt:topic:MQTT_GATEWAY:GW_Sys" }
String GW_Sys_Ip "Gateway Ip [JSONPATH($.ip):%s ] " { channel="mqtt:topic:MQTT_GATEWAY:GW_Sys" }
String GW_MQTT_IR "Gateway IR Rx" { channel="mqtt:topic:MQTT_GATEWAY:GW_MQTT_IR" } // Gives a readout of the 'value' received by 'openmqttgateway'
// Each switch is used in a rule to send mqtt payload to 'openmqttgatway' which triggers the IR pulse
Switch LG_Power_On "LG Power On" { expire="1s,OFF" }
Switch LG_Power_Off "LG Power Off" { expire="1s,OFF" }
Switch LG_Vol_Up "LG Vol Up" { expire="1s,OFF" }
Switch LG_Vol_Dn "LG Vol Dn" { expire="1s,OFF" }
.RULES
var String jsonString
rule "MQTT to IR"
when
// Item to check to see if selected to ON. Add a 'or' for each remote button you want to use in openHAB
Item LG_Vol_Up changed to ON or
Item LG_Vol_Dn changed to ON
then
// JSON 'value' to send as 'String' to 'openmqttgateway'
if(LG_Vol_Up.state == ON) jsonString = "{\"value\":551502015}" // LG_Vol_Up
if(LG_Vol_Dn.state == ON) jsonString = "{\"value\":551534655}" // LG_Vol_Dn
GW_MQTT_IR.sendCommand(jsonString)
end