Simple rule with homematic switch not running

Hi folks,

i run oh2 v2.2 on a rPI3 with HM-MOD-RPI-PCB for my homematic componentes, a nanoCUL434 for my Intertechno sockets and have a lot of sonoff sockets, which all are communicating with the mosquitto on the rPI3. My homematic components communicating with homegear on the rPI3, this works fine. Then i have some homematic pushbuttons (2way, 6way) and a lot of heating controller. My Intertechno sockets are switched on and off over rules, this works fine.

But i want to switch my sonoff / Intertechno sockets with a push button. Therefore i created a simple rule:

rule "Stehlampe_An"
when
     Channel 'homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS_SHORT' triggered SHORT
     then
     if (MQTT_Stehlampe.state != ON)
     {
         sendCommand(MQTT_Stehlampe, ON)
     }
     else if (MQTT_Stehlampe.state != OFF)
     {
         sendCommand(MQTT_Stehlampe, OFF)
     }
end

My items:

Switch TA_Schlafzimmer1_S   "Taster_1 "  { channel="homematic:HG-HM-PB WM55:aea48cbf:LEQ0571338:1#PRESS_SHORT"}
Switch TA_Schlafzimmer2_S   "Taster_2 "  { channel="homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:2#PRESS_SHORT"}
Switch MQTT_Stehlampe   "Stehlampe"    { mqtt=">[broker:cmnd/stehlampe/POWER:command:ON:1],
 >[broker:cmnd/stehlampe/POWER:command:OFF:0],
<[broker:stat/stehlampe/POWER:state:default]" }

When i press the button short, i see this in the openhab2.log, but the lamp is not switched on. Did i missed something? I’m happy about help.

Regards, machnetz

What do you see in the log?

And could you add some log statement.

From the i see nothing wrong at the first moment, but i am not sure with the trogger condition. maybe you could modify it for testing pursoses to

When
   Item TA_Schalfzimmer1_s changed to ON 

so if the switch changed to on for a shot period auf time your Stehlampe should change its state

Change your rule to:
It may not solve the problem but it’s tidier

rule "Stehlampe_An"
when
     Channel 'homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS_SHORT' triggered SHORT
then
    if (MQTT_Stehlampe.state != ON) {
        sendCommand(MQTT_Stehlampe, ON)
    } else {
        sendCommand(MQTT_Stehlampe, OFF)
    }
end

Damn, now you have me. I am in the office today and therefore can not deliver the log until tonight.

I see, tinkering with your openHAB code instead of working… :laughing:

1 Like

Since I have been working on it for 2 days and can not manage it, you also have to set priorities :wink:

So, i’ve tunneled now my ssh session trough our companies firewall. This - maybe work:

2018-04-19 10:56:46.922 [DEBUG] [ematic.handler.HomematicThingHandler] - Received command 'OFF'  for channel 'homematic:HG-HM-PB-2 M55:aea48cbf:LEQ0571338:1#PRESS_SHORT'
2018-04-19 10:56:47.187 [WARN ] [ommunicator.AbstractHomematicGateway] - Datapoint is readOnly, it is 
not published to the gateway with id 'aea48cbf': 'LEQ0571338:1#PRESS_SHORT'
2018-04-19 10:56:51.080 [DEBUG] [ommunicator.AbstractHomematicGateway] - Received new (String) 
value 'aea48cbf' for 'CENTRAL:0#PONG' from gateway with id 'aea48cbf'
2018-04-19 10:56:51.135 [DEBUG] [inding.mqtt.internal.MqttItemBinding] - Publishing command OFF to 
cmnd/stehlampe/POWER
2018-04-19 10:56:51.130 [DEBUG] [ematic.handler.HomematicThingHandler] - Received command 'ON' for 
channel 'homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS_SHORT'
2018-04-19 10:56:51.485 [WARN ] [ommunicator.AbstractHomematicGateway] - Datapoint is readOnly, it is not published to the gateway with id 'aea48cbf': 'LEQ0571338:1#PRESS_SHORT'
2018-04-19 10:56:51.338 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Publishing message 
136 to topic 'cmnd/stehlampe/POWER'

But I can not tell if the lamp has been started or not. My webcam is not turned on today ;-( I’ll give you a feedback tonight.

Regards, machnetz

Okay, I’ll take a look at the web interface of the sonoff floor lamp. His condition changes from OFF to ON … cool!
I will test it later at home if I have direct access to the switch.
Thanks once from the office :wink:

Without going in deep, are you sure that

Channel 'homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS_SHORT' triggered SHORT

is correct? and not

Channel 'homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS' triggered SHORT

Hi Felix,

homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS_SHORT

is what the channel has configured in the things section. But i see there is also a

homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS

found … I’ll try this at home, thank you for the hint.

Hi there,

just for correctness - i’ve got it running now. This is my rule:

rule "Schlafzimmer_TA_2"

when
Channel 'homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS'     triggered SHORT
then
if (IT_Salzlampe_SZ.state != ON) 
{
	sendCommand(IT_Salzlampe_SZ, ON)
}
else if (IT_Salzlampe_SZ.state != OFF) 
{
	sendCommand(IT_Salzlampe_SZ, OFF)
}
end

One short press on the upper button toggles the lamp state from off -> on and vice versa. The lower button switches another IT socket.

@Felix_Raetz
The usage of

Channel 'homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS_SHORT' triggered SHORT 

was wrong, the event could not be used. Thank you for the hint!

Thanks @all and kind regards - machnetz

You can simplify your rule a bit assuming there are only two states the lamp can be ON or OFF only
Also you need to use item method instead of the action for sendCommand

rule "Schlafzimmer_TA_2"

when
Channel 'homematic:HG-HM-PB-2-WM55:aea48cbf:LEQ0571338:1#PRESS'     triggered SHORT
then
    if (IT_Salzlampe_SZ.state != ON) {
        IT_Salzlampe_SZ.sendCommand(ON)
    } else {
	IT_Salzlampe_SZ.sendCommand(OFF)
    }
end