- Platform information:
- Hardware: AMD Atlon 2gb
- OS: Debian 9.5
- Java Runtime Environment: (build 1.8.0_212-8u212-b03-2~deb9u1-b03)
- openHAB version: openHAB 2.4.0 Release Build
Good day.
He created a simple rule that does not change the temperature in order to report on the inclusion or disconnection of hot water:
var Number ControllerDS18B20_notifi_level = 0
rule "Records when device ControllerDS18B20 was last seen"
when
Item test_rule_switch received update or
Item Temperature_28dd2c3503000064 received update or
Item Temperature_285ef73403000076 received update or
Item Temperature_287626350300007d received update or
Item Temperature_285e0d3b010000b8 received update or
Item Temperature_28f2602402000022 received update or
Item Temperature_28ea183b010000cd received update or
Item Temperature_28e6eb340300008d received update or
Item Temperature_28a06224020000e1 received update
then
postUpdate(ControllerDS18B20_LastUpdate, new DateTimeType())
logInfo("Records when device ControllerDS18B20 was last seen", "Temperature_28a06224020000e1.state=" + Temperature_28a06224020000e1.state)
logInfo("Records when device ControllerDS18B20 was last seen", "ControllerDS18B20_notifi_level=" + ControllerDS18B20_notifi_level)
if ((ControllerDS18B20_notifi_level < 1 ) && (Temperature_28a06224020000e1.state as Number < 40)){
SendTextToUsers.apply("Отключили горячую воду: " + Temperature_28a06224020000e1.state +" градусов")
ControllerDS18B20_notifi_level=1
logInfo("Records when device ControllerDS18B20 was last seen", "ControllerDS18B20_notifi_level=" + ControllerDS18B20_notifi_level)
}
if ((ControllerDS18B20_notifi_level > 0) && (Temperature_28a06224020000e1.state as Number>45)){
SendTextToUsers.apply("Включили горячую воду: " + Temperature_28a06224020000e1.state +" градусов")
ControllerDS18B20_notifi_level=0
logInfo("Records when device ControllerDS18B20 was last seen", "ControllerDS18B20_notifi_level=" + ControllerDS18B20_notifi_level)
}
logInfo("Records when device ControllerDS18B20 was last seen", "END")
end
but in the Openhab.log log I get an error:
019-07-01 11:17:30.507 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'my.rules' has errors, therefore ignoring it: [45,94]: no viable alternative at input '40'
if replaced:
if ((ControllerDS18B20_notifi_level < 1 ) && (Temperature_28a06224020000e1.state as Number < 40)){
on
if ((ControllerDS18B20_notifi_level < 1 ) && (Temperature_28a06224020000e1.state < 40)){
no error:
2019-07-01 11:19:34.431 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘my.rules’
2019-07-01 11:19:40.391 [INFO ] [e.smarthome.model.script.Initializer] - Initialize all items …
in the logs I noticed that for this item the dimension is appended to the dimension, for others there is no such thing:
2019-07-01 11:21:29.785 [INFO ] [vice ControllerDS18B20 was last seen] - Temperature_28a06224020000e1.state=56.0 °C
2019-07-01 11:21:29.786 [INFO ] [vice ControllerDS18B20 was last seen] - ControllerDS18B20_notifi_level=0
2019-07-01 11:21:29.788 [INFO ] [vice ControllerDS18B20 was last seen] - END
I configure the items via the GUI (/var/lib/openhab2/jsondb/org.eclipse.smarthome.core.items.Item.json
):
“Temperature_28a06224020000e1”: {
“class”: “org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem”,
“value”: {
“groupNames”: [
“gHome”
],
“itemType”: “Number:Temperature”,
“tags”: [],
“label”: “Bathroom Hot Water [%.1f °C]”,
“category”: “temperature”
}
},
Where am I wrong? Why do the values of Number need to be converted into a condition again into a number?