Dimmer and ON command

I’m trying to understand how ON/OFF works with dimmers. I have the following rule, Garage_Occupancy is a Contact, GarageHueLight_Brightness is a dimmer and here is the weird part… Some days, the rule works perfectly fine, and yes the dimmer accepts ON and OFF. But on other days, the rule throws a null instance exception. I have converted the rule to send 0 & 100 to the dimmer now but could anyone shed some light on the dimmer and ON command?

rule "Garage door light"
    Item Garage_Occupancy changed

If you mean an Item of type Contact, then its state will either be OPEN or CLOSED.

Dimmer type Items accept 0-100 numeric as commands and ON/OFF as commands.
(What might get dealt with differently about these commands depends entirely on the bindings in use.)

There is a little trap set in rules like this.
mySwitchItem.state cold be ON or OFF, of course.
But that’s a state, not a command.
otherSwitchItem.sendCommand(mySwitchItem.state) will fail, because a state object is not a command object.
Yes, they all look like ON to us, but not to rules engine.
The easy circumvention is to send a string instead, which forces sendCommand to parse it into the form it wants.

1 Like

ALSo be careful on to a dimmer may just switch it on. So if the last value was 5% then on means turn it to 5. Vs on meaning 100 percent. Other dimmers on means 100%

The odd part is that on some days this statement did work. And my “Garage_Occupancy” is a switch actually… not a contact. My fix used to be to restart openhab :stuck_out_tongue:

Thank you that is exactly what I was looking for. I had not realized about this conversion system.