"Dummy" switch item - unable to change state via UI

Dear oH Community,

I hope You will be able to point me in a good direction with the following issue:
=> How to change state of a “dummy” item switch via UI?

I have an “alarm” rule that is triggered with a change of state of one of my items (contacts) and then this rule should do something but only if this dummy switch is ON (this rule works and it is not my issue).

This is my “dummy” item in a *.item file:

Switch Test_Alarm "Alarm" <siren>

This is my sitemap entry in a *.sitemap file:


Switch item=Test_Alarm icon="siren" label="Alarm"

My first issue was that the state of Test_Alarm switch was always NULL - no matter how many times I pressed it in the UI.
I was able to solve this by:

when
    System started
then
   postUpdate(Test_Alarm, ON)
end

Still, state does not change when I click on it and I am unable to make it OFF.

There is not a single trace of it in both events and openhab.log.

This is mine platform information:

  • Hardware: Raspberry Pi 2B+
  • OS: Raspbian Stretch (updated)
  • Java Runtime Environment: Oracle Java:
    • Java™ SE Runtime Environment (build 1.8.0_131-b11)
    • Java HotSpot™ Client VM (build 25.131-b11, mixed mode)
  • openHAB version: 2.5.0.M1

This is probably a simple thing but somehow I am unable to find a solution :-/

Thank You in advance!

UI clicking never ever changes Item state. It causes a command to be sent to the Item.

Step one for you is looking in events.log to make sure your UI is sending commands, and what to.

So how does the state usually get changed?
An openHAB feauture called autoupdate acts a bit like a psuedo-binding. It listens for commands to each Item, makes a guess/prediction about the likely outcome of that command, and generates its own state update to that effect.
Since OH2.4 the predictions are reported in events.log

In the case of a nonsense command e.g. sending 100% to a Switch type Item, the prediction will fail.

Autoupdate can be turned off for individual Items, resulting in exactly the behaviour you observe.

Some bindings are able to overrule autoupdate, effectively veto its predictions. That wouldn’t apply where you have no links of course.

1 Like

Hi,
I also have a similar rule but the item and sitemap differ.
My dummy item:
Switch Alarm “Alarm” < switch >
Sitemap:
Switch item=Alarm label=“Alarm”

Hello and thank You for Your reply!
You are right - I have found those predictions in the event.log:

2019-07-13 18:01:59.948 [ome.event.ItemCommandEvent] - Item 'Test_Alarm' received command OFF
2019-07-13 18:01:59.967 [nt.ItemStatePredictedEvent] - Test_Alarm predicted to become ON
2019-07-13 18:02:19.013 [ome.event.ItemCommandEvent] - Item 'Test_Alarm' received command OFF
2019-07-13 18:02:19.029 [nt.ItemStatePredictedEvent] - Test_Alarm predicted to become ON

So when I click it it receives a command OFF and couple of milliseconds later it becomes ON again basing on the prediction. My item had no {autoupdate=“false”} and no {autoupdate=“true”} as I red over the forums that the “true” is default .

Nevertheless I just modified my dummy item to:

Switch Test_Alarm "Alarm" <siren> {autoupdate="true"}

… and it worked! I can see state changes in

openhab> smarthome:items list

Thank You very much for Your help!

I would suspect something left in cache associated with this Item name from previous experiments, perhaps even from demo. Anyway, sorted out :smiley:

1 Like