Use a rule and proxy item to display the avg of both sensors.
Here’s an example rule:
rule “Rule_Temp”
when
Item ThermoSoggiorno_T changed
or
Item ThermoBagnoPT_T changed
then
if(!(ThermoSoggiorno_T.state instanceof Number )) return; // check if ThermoSoggiorno_T.state is of type number
if(!(ThermoBagnoPT_T.state instanceof Number )) return; // check if ThermoBagnoPT_T.state is of type number
// both items have a number value, so calculate...
var t = (ThermoSoggiorno_T.state as Number) + (ThermoBagnoPT_T.state as Number) // beware the brackets!
TemperaturaPianoTerra.postUpdate(t)
end
You can try this rule with your items just change the names.
rule “RuleTemp”
when
Item LB_Temperature changed
or
Item LB1_Temperature changed
then
if(!(LB_Temperature.state instance of Number )) return; // check if LB_Temperature.state is of type number
if(!(LB1_Temperature.state instance of Number )) return; // check if LB1_Temperature.state is of type number
// both items have a number value, so calculate...
var t = (LB_Temperature.state as Number) + (LB1_Temperature.state as Number) // beware the brackets!
LilysBedroom.postUpdate(t)
end
and have created a new item
Number LilysBedroom "Lilly's Bedroom Temperature [%.1f °C]"
but i’m getting this error?
2019-12-27 16:57:06.627 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'temp.rules' has errors, therefore ignoring it: [1,6]: no viable alternative at input '?'
@matt_shepherd: Since we know the value is a number, remove the items from a group and try just this:
rule "RuleTemp"
when
Item LB_Temperature changed
or
Item LB1_Temperature changed
then
var t = ((LB_Temperature.state as Number) + (LB1_Temperature.state as Number)) / 2
LilysBedroom.postUpdate(t)
end
Edit I added the divide by 2 at the end for average as I overlooked that at first.
2019-12-27 18:35:15.976 [vent.ItemStateChangedEvent] - LB1_Temperature changed from 20.7 to 20.6
2019-12-27 18:35:16.380 [vent.ItemStateChangedEvent] - LilysBedroom changed from NULL to 32.00000000
2019-12-27 18:35:39.767 [vent.ItemStateChangedEvent] - LB_Temperature changed from 21.7 to 21.8
2019-12-27 18:35:39.798 [vent.ItemStateChangedEvent] - LilysBedroom changed from 32.00000000 to 32.10000000