Rule for automatic loading

  • Hardware: RPI 4, 4GB RAM
  • OS: Raspian lite, Bullseye x64
  • Java Runtime Environment: 11 Zulu
  • openHAB version: 3.3.0

I want to turn on a WiFi socket when the tablet’s battery level is less than 6%.
I followed the instructions in the documentation (Rules - Basic | openHAB), but when I test the rule, the socket is always switched on, no matter what the charge level of the battery is.

I don’t know what the problem is.

Thanks already

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Akku_Lenovo_Tab
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: Akku_Lenovo_Tab
      state: 6 %
      operator: <
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      command: ON
      itemName: TabletSteckdose_Betrieb
    type: core.ItemCommandAction

What time of Item is Akku_Lenovo_Tab?

What are the states of Akky_Lenovo_Tab (see events.log)?

Hello @rlkoshak,

thank you for your quick response. Sorry i dont know realy what you mean with “time of item”.

What I found in events.log:

2022-11-10 19:14:02.696 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘Akku_Lenovo_Tab’ received command 92
2022-11-10 19:14:02.699 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘Akku_Lenovo_Tab’ changed from 33 to 92

The item gets an update on the battery level as it should. But I think the condition “but only if” is not observed by the rule.
But I can’t find anything about the rule in any log.

Typo and I didn’t have my glasses. “time” and “type” look the same when your vision is blurry.

I meant “what type of Item”.

Is it a Number or a Number:Dimensionless or something else?

What on earth is sending this battery level sensor a command? That is not normal.

@rlkoshak, i tried it with different Number Items and now use Number:Dimensionless.

@rossko57, that’s what I asked myself at the moment I saw it. I get the status of the battery via the openHAB app from the tablet.

Send device information → Battery status

Well if that is acting in “the usual GUI way”, it is normal for UI to send commands as they represent user instructions / clicks etc.

It’s not very appropriate for sensor info. (I didn’t even know the app could do this)
On the other hand, it’s not usually appropriate for a UI to be sending state updates either. Exceptional case I think.

Don’t do that unless your sensor (app) is sending a quantity with units like %
If you update a Number:Dimensionless with only numerics it will “work” without error but not give the results that you expect.

When you have a Number Item, don’t compare it to a quantity with % in your rule.

1 Like

Everything that @rossko57 said with one addition. I think in versions of OH before 3.4 M3 the conditions in UI rules had a bug causing it to fail when trying to use percents. So for now just use a Number and get rid of that %.

Hello,
I have found the error. The rule works as it should, the problem is the openHAB app itself.
Logically, if you put it in battery-saving mode, it can’t send updates when the Tablet switches to power-saving mode. :man_facepalming: