Well, what can I say. The rule was running - but wrongly again, i.e. if I replaced > with <, the rule would still “fire”, i.e. charge mode changed.
Here’s what I did. First, since I couldn’t change the original channel from Dimmer to Number, I created a new channel plus a corresponding item:
UID: mqtt:topic:30198930b0:7288900f1f
label: OpenWG MQTT Thing
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:30198930b0
channels:
- id: OpenWB_Lademodus
channelTypeUID: mqtt:number
label: OpenWB Lademodus
description: ""
configuration:
commandTopic: openWB/set/ChargeMode
stateTopic: openWB/global/ChargeMode
- id: OpenWB_charge_W
channelTypeUID: mqtt:number
label: OpenWB aktuelle Ladeleistung
description: ""
configuration:
stateTopic: openWB/lp/1/W
unit: W
- id: SOC_Status
channelTypeUID: mqtt:dimmer
label: SOC Status
description: ""
configuration:
stateTopic: openWB/lp/1/%Soc
- id: openWB_BatterieProzent
channelTypeUID: mqtt:number
label: openWB_BatterieProzent
description: ""
configuration:
postCommand: true
unit: "%"
min: 0
max: 100
commandTopic: openWB/config/set/sofort/lp/1/socToChargeTo
step: 5
stateTopic: openWB/config/get/sofort/lp/1/socToChargeTo
transformationPattern: JS:openwb_percent.js
- id: SOCStatus
channelTypeUID: mqtt:number
label: SOCStatus
description: ""
configuration:
stateTopic: openWB/lp/1/%Soc
max: 100
min: 0
(Note, the old channel is still in there, but not linked to an item). So, theoretically, creating the rule with just using UI should work - it doesn’t. Here’s the rule:
configuration: {}
triggers:
- id: "1"
configuration:
itemName: OpenWGMQTTThing_SOC_Status
type: core.ItemStateChangeTrigger
conditions:
- id: "3"
configuration:
itemName: OpenWGMQTTThing_SOC_Status
operator: <
state: "90"
type: core.ItemStateCondition
actions:
- inputs: {}
id: "2"
configuration:
itemName: GenericMQTTThing_OpenWBLademodus
command: "2"
type: core.ItemCommandAction
- inputs: {}
id: "4"
configuration:
message: SOC > 90?
userId: xxxx
type: notification.SendNotification
Also, this time around, when I use the scripts suggested by @binderth, it also doesn’t work, i.e. with the state being 100, it also fires when I set the condition to < 90
Also, looking at the logs and what happens with the OpenWBLademodus
, if the rule changes the charge mode, the log reads:
2022-10-19 15:50:33.364 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'GenericMQTTThing_OpenWBLademodus' received command 2
2022-10-19 15:50:33.364 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'GenericMQTTThing_OpenWBLademodus' predicted to become 2
2022-10-19 15:59:43.324 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GenericMQTTThing_OpenWBLademodus' changed from 0 to 2
When I change the charge mode manually, the log only reads:
2022-10-19 16:01:10.418 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'GenericMQTTThing_OpenWBLademodus' changed from 2 to 0
So, no “predicted” here.
As for the numbers: as the logs state, SOC_Status is an integer number, no decimals, no unit. MQTT Explorer shows the same