I just wrote a small program which publishes the received codes from a 433Mhz receiver to a MQTT broker.
It is based on RFSniffer from ninjablocks and is best place besides RFSniffer in RPI_utils as there is a relative depency for the RCSwitch.h.
My setup has mosquitto installed on the rpi and also the MQTT binding in OpenHAB.
Using is as simple as usig the RPI_Utils. Follow the instructions from the readme or this thread help getting everything in place.
Then download the RFmqtt place it into the folder RPI_Utils, change the Makefile, and compile it.
(Follow the instruction in the Github folder.)
Then you can run the “RFmqtt”
Following the Instructions configuring the OpenHAB MQTT binding to use the default FRmqtt values.
mqtt.cfg
mymosquitto.url=tcp://localhost:1883
mymosquitto.user=admin
mymosquitto.pwd=password
setting up some items
.items
String MQTT_data "MQTT says: [%s]" {mqtt="<[mymosquitto:433MHz:state:default]"}
Switch MQTT_Remote
and something on my sitemap to see the received data.
.sitemap
Text item=MQTT_data
Switch item= MQTT_Remote
E viola pressing my remote i recieve the data on my sitemap.
(On my smartphone as somehow my Firefox still does not update the view, Edge does, Chrome alos doesn’t)
As i don`t know jet how to get e.g a swtich trigger when a spicific code was received, i take the route over a rule.
.rules
rule "433MHz RX"
when
Item MQTT_data changed
then
switch MQTT_data.state {
case "1328465": MQTT_Remote.postUpdate(ON)
case "1328468": MQTT_Remote.postUpdate(OFF)
}
end
If you only have one code which is send multiple times it will not trigger the rule multiple times as openhab only forwards changed statuses. At least i think so. So just reset the MQTT_data in the rule.
.rules
rule "433MHz RX"
when
Item MQTT_data changed
then
switch MQTT_data.state {
case "1328465": MQTT_Remote.postUpdate(ON)
case "1328468": MQTT_Remote.postUpdate(OFF)
}
if(MQTT_data.state.toString !="") MQTT_data.postUpdate("")
end
Maybe this helps other people having fun with openhab.