Skip to content

OpenHAB manual integration

Leon Kiefer edited this page Mar 13, 2019 · 3 revisions

Presence detection (from @rickitaly)

in thing file:

Thing mqtt:topic:omgentrance (mqtt:broker:localBroker) {
Channels:
    Type string : blepresence "People Presence"  [ stateTopic="home/home_presence/OpenMQTTGatewayEntrance"]
}

in item file

String OMG_BLE_Entrance "BLE Entrance Detector" { channel="mqtt:topic:omgentrance:blepresence" }

Switch   Presence_Keys_Rick      "Rick's Keys"       <keyring>      (People, gKeys)        {expire="240s,OFF"}

In rule file:

rule "BLE Presence Detector"
when
Item OMG_BLE_Entrance received update
then
val String msg = (OMG_BLE_Entrance.state as StringType).toString
val String id  = transform("JSONPATH", "$.id", msg).toString
if(id == "xx:xx:xx:xx:xx:xx")
    Presence_Keys_Rick.postUpdate(ON)
end

NEXT INFOS TO BE UPDATED WITH JSON FUNCTIONNALITY this works only if #define simplePublishing true & #define simpleReceiving true are uncommented

The integration has to be done in the sitemap and the item file. On the sitemap file just add a normal switch like below : Switch item=PlugSwitch1

Switch item=IRtest

On the item file we will precise how OpenHAB will link the switch to the mqtt subject, the following text must be in one line :

Switch PlugSwitch1 "Test" {mqtt=">[broker: home/OpenMQTTGateway/MQTTto433:command:ON:1312081],>[broker:home/OpenMQTTGateway/MQTTto433:command:OFF:1312084],<[broker: home/OpenMQTTGateway/433toMQTT:state:ON:1312081],<[broker: home/OpenMQTTGateway/433toMQTT:state:OFF:1312084]", autoupdate="false"}
Switch IRtest "IR" <light> (GF_JA,Plugsm) {mqtt=">[broker:home/OpenMQTTGateway/commands/IR_GC:command:ON:38000,1,1,171,171,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,64,21,21,21,21,21,21,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,64,21,21,21,21,21,21,21,21,21,64,21,64,21,64,21,21,21,64,21,64,21,64,21,64,21,1114]"}

Where broker is the name of your broker defined in your openhab config file.

home/OpenMQTTGateway/MQTTto433 is the subject for outgoing states and home/OpenMQTTGateway/433toMQTT for the incomming command, home/OpenMQTTGateway/MQTTto433 is either changed by the acknowledgment of the gateway or by a physical action on a remote sending the defined code 1312081 or 1312084.

This definition enable to power ON and OFF the switch from OpenHAB and also to update the state of the switch into OpenHAB if you use the remote control.

For IR the principe is the same just change the subject and the values Switch PlugSwitch2 "Test2" {mqtt=">[broker: home/OpenMQTTGateway/commands/IR_SAMSUNG:command:ON:3772793023], >[broker:home/OpenMQTTGateway/commands/IR_SAMSUNG:command:OFF:3772793023]"}

I removed the incoming commands begining by "<" due to the fact that for IR it is less interesting compared to RF to have the incoming signal to update the switch test. Mainly due to the directional characteristic of infrared signals.

Clone this wiki locally
You can’t perform that action at this time.