I’m cleaning up my OH1.x for further usage in OH2.2. VS is reporting an error that I don’t understand
Ambiguous binary operation.The operator declarations operator_equals(Number, Number) in NumberExtensions and operator_equals(Type, Number) in NumberExtensions both match.
for the following rule
rule "Status Meldung"
when
System started
or
Item Lueftung_Fehlermeldung changed
or
Item Lueftung_FilterfehlerI changed
or
Item Lueftung_FilterfehlerE changed
then
var String msg = ""
if( (Lueftung_FilterfehlerI.state instanceof DecimalType) && (Lueftung_FilterfehlerE.state instanceof DecimalType) && (Lueftung_Fehlermeldung.state instanceof StringType) ){
if( (Lueftung_FilterfehlerI.state as DecimalType) == 1 || (Lueftung_FilterfehlerE.state as DecimalType) == 1 ){
if( msg.length > 0 ) msg = msg + ", "
msg = msg + "Filter: "
if( (Lueftung_FilterfehlerI.state as DecimalType) == 1 ) msg = msg + "I"
if( (Lueftung_FilterfehlerI.state as DecimalType) == 1 && (Lueftung_FilterfehlerE.state as DecimalType) == 1) msg = msg + " & "
if( (Lueftung_FilterfehlerE.state as DecimalType) == 1 ) msg = msg + "E"
}
if( (Lueftung_Fehlermeldung.state as StringType) != "Ok" ){
if( msg.length > 0 ) msg = msg + ", "
msg = msg + "Error: " + (Lueftung_Fehlermeldung.state as StringType)
}
}
if( msg.length == 0 ){
msg = "Alles in Ordnung"
}
postUpdate(Lueftung_Status_Message,msg)
end
in particular for this part, everywhere I’m using the ==
Any idea on this one: I 'm getting an error with these 3 lines?
if (Washingmachine_Power.averageSince(now.minusMinutes(2)) < 0.2) Washingmachine_OpState.postUpdate(MODE_OFF)
else if (Washingmachine_Power.averageSince(now.minusMinutes(2))> 10) Washingmachine_OpState.postUpdate(MODE_ACTIVE)
else if (Washingmachine_Power.averageSince(now.minusMinutes(2))< 5) {
Ambiguous binary operation.
The operator declarations
operator_lessThan(Number, Number) in NumberExtensions and
operator_lessThan(Type, Number) in NumberExtensions
both match.```
I just restarted the OH service and I got the following errors:???
018-12-12 10:05:39.530 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Washingmachine Consumption State Machine': The name 'tplinksmarthome_hs110_B16E5F_power' cannot be resolved to an item or type; line 39, column 24, length 34
2018-12-12 10:05:39.532 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Dryer Consumption State Machine': The name 'tplinksmarthome_hs110_B1AFF9_power' cannot be resolved to an item or type; line 124, column 24, length 34
To be honest, I’m a bit confused by the MODE_OFF (and the others) status, as this is no status. Either use a Number (0 Off, 1 Standby, 2 active, 3 finished)or use a String Item. I don’t know if this error will have impact to the trailing line. I would do it like this:
items:
Number Washingmachine_OpState "Washing Machine State [MAP(wmachine.map):%s]"
wmachine.map
0 = OFF
1 = Standby
2 = Active
3 = finished
NULL = -
rule "Washingmachine Consumption State Machine"
when
Item tplinksmarthome_hs110_B16E5F_power changed
then
val Number WnAvg = tplinksmarthome_hs110_B16E5F_power.averageSince(now.minusMinutes(2)) as Number
if(WnAvg < 2)
Washingmachine_OpState.postUpdate(0)
else if(WnAvg > 10)
Washingmachine_OpState.postUpdate(2)
else if(WnAvg < 5) {
if ((Washingmachine_OpState.state as Number) == 0)
Washingmachine_OpState.postUpdate(1)
else if ((Washingmachine_OpState.state as Number) == 2) {
Washingmachine_OpState.postUpdate(3)
sendBroadcastNotification("Washingmachine finished")
logInfo("wmachine ", "Washingmachine finished!")
}
}
end
Which persistence service did you use? Is it the default persistence service?
So I did a couple of loads yesterday and I didn’t have any errors, but I never got a notification when the load was finished? Any Ideas?
rule "Washingmachine Consumption State Machine"
when
Item tplinksmarthome_hs110_B16E5F_power changed
then
val Number WnAvg = tplinksmarthome_hs110_B16E5F_power.averageSince(now.minusMinutes(2)) as Number
if(WnAvg < 2)
Washingmachine_OpState.postUpdate(0)
else if(WnAvg > 10)
Washingmachine_OpState.postUpdate(2)
else if(WnAvg < 5) {
if ((Washingmachine_OpState.state as Number) == 0)
Washingmachine_OpState.postUpdate(1)
else if ((Washingmachine_OpState.state as Number) == 2) {
Washingmachine_OpState.postUpdate(3)
sendBroadcastNotification("Washingmachine finished")
logInfo("wmachine ", "Washingmachine finished!")
}
}
end
thanksssss a lot !! i learn but still have issue whith syntax as you can see, again thanks ! Also if u have a link or anything can help to learn java and or python especialy for openhab scripting a take it !