Update switch status for RFXCom?

I recently moved from Domoticz to OpenHAB to get a bit more flexibility with the system.
I managed to setup OpenHAB using the rfxcom binding and a RFXtrx433E device. Switching on and off works from the interface.
The problem is, when manually pressing the wireless wall switches I want the status to update in OpenHAB. IE when the light is switched ON the status in OpenHAB should show ON.
This was working in Domoticz. How do I do this in OpenHAB?

You need to listen to the switch signal. I have a UI item to set the light and a dummy one that listens. I use a rule to update the status of the UI item.

Sounds like the right solution.
I’m pretty new on OpenHAB. Do you mind sharing an example from your items and rules?

Sorry for the late reply. This should work, I guess:

rfxcom.items file

/* Set switch */
Switch    Light_1    "Plafond eethoek" { rfxcom=">12345678.11:LIGHTING2.AC:Command" }

/* Get Wall switch */
Switch    Light_1_Switch { rfxcom="<12345678.11:Command" } //get

rfxcom.rules file

/* when remote switch clicked, update sitemap item*/
rule "Sync Light 1"
    Item Light_1_Switch received update
    postUpdate("Light_1", Light_1_Switch.state.toString)

sitemap file

Switch item=Light_1

Hi there,

I’m afraid I can’t get this to work. Designer gives me the following error:

Multiple markers at this line
- Couldn't resolve reference to JvmIdentifiableElement 'Light_1_Switch'.
- Incompatible types. Expected org.openhab.core.items.Item but was java.lang.String
- Couldn't resolve reference  to JvmIdentifiableElement 'state'.
- Couldn't resolve reference to JvmIdentifiableElement 'toString'.

It looks identical to a number of other rules I have, but I can’t spot what’s wrong?


I currently don’t have access to my openHAB configuration due to hardware failure, but I think that you need to add the imports at the top of your rules file.

Something like this (don’t know which you actually need) :

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*

Thank you, I was looking for this! Just started out with openhab/rfxcom and are making progress, piece by piece!

What would be the best way to do the same for dimmers?

I have dimmers that you can change the dimming level on by switching them “on”, then press “on” one more time on the wall switch. That will put the dimmer/light in a constant dimming state until you press the “on” button again when it reached the wanted light level.
The same dimmers can also be set to an absolute dim level immediately with other apps.
I’m not a native English speaker so I hope that made some sort of sense.

So there are both commands and dimming levels that can control their behavior in a few ways:

  1. On to the previous dimming level.
  2. Off
  3. On, Start dimming when on.
  4. On, Stop dimming when on (Set dim level).
  5. Set an absolute dim level no matter what last state.

Anyone has any idea?