I’ve spent some time this weekend installing room-assistant as clusters to use ble to determine room presence. So far so good, with a bit of help from google managed to get into openhab the room in which the ble device was in.
rule "Presence based Room Heating"
when
Member of gRoomPresence changed
then
// KitchenPresenceCount.postUpdate=(gRoomPresence?.members.filter[i|i.state.toString == "kitchen"].size)
// LivingRoomPresenceCount.postUpdate=(gRoomPresence?.members.filter[i|i.state.toString == "livingroom"].size)
// FirstFloorPresenceCount.postUpdate=(gRoomPresence?.members.filter[i|i.state.toString == "firstfloor"].size)
if (Heating_Type.state == "Home"){
if (triggeringItem.state.toString == "kitchen"){
ZWave59DiningRoomTRV_Setpointheating.sendCommand(Heat_Mode_Home_Temp.state as Number)
// KitchenPresenceCount.postUpdate=(gRoomPresence?.members.filter[i|i.state.toString == "kitchen"].size)
}
if (triggeringItem.state == "livingroom"){
gLIvingRoomTemp.sendCommand(Heat_Mode_Home_Temp.state as Number)
// LivingRoomPresenceCount.postUpdate=(gRoomPresence?.members.filter[i|i.state == "livingroom"].size)
}
if (triggeringItem.state == "firstfloor"){
gFFHeating.sendCommand(Heat_Mode_Home_Temp.state as Number)
}
// if (KitchenPresenceCount == 0)
// ZWave59DiningRoomTRV_Setpointheating.sendCommand(Heat_Mode_Away_Temp.state as Number)
// if (LivingRoomPresenceCount == 0)
// gLIvingRoomTemp.sendCommand(Heat_Mode_Away_Temp.state as Number)
// if (FirstFloorPresenceCount == 0)
// gFFHeating.sendCommand(Heat_Mode_Away_Temp.state as Number)
//
}
end
What works is not commented out - oddly, but perhaps not state and state.toString both work
So I can now change the temp based on when a ble device is in the room
What I haven’t been able to do is determine when room presence changes is there still someone in the room
I’ve tried here using a count of people in a room and then if noone is change the heating setpoint for that zone.
Basically throws an error of unable update Null value. I have assumed members.filter.size is a number and I have defined 3 presence counts as number type items.
Any help or a different approach to lack of presence…I did think use expire but room-assistant detect new and reports that not continual polling.
You can get a count of those Items that are on pretty close to what you tried in the commented out part of the code.
But the problem is two-fold.
KitchenPresenceCount is an Item. An Item has all sorts of stuff like a label, tags, metadata, links, etc. An Item can never == 0 because it is so much more than just it’s state. You need to compare the Item’s state instead. KitchenPresenceCount.state == 0. Sometimes that won’t work and you have to help it understand that the state is actually a number: KitchenPresenceCount.state as Number == 0.
Calling postUpdate() generates and event that says “update the Item”. It doesn’t wait around for that event to be processed. If you then turn around a few milliseconds later and check the state of the Item, it almost certainly will not have yet processed that update from a few milliseconds before and it will still have the old state. So don’t do that. You’ve calculated the new presence count already, so put that into a variable and use that in your rule.
An alternative solution would be to create a Group:Number:COUNT for each room (you’ve already got the Count Items so just change those to a Group with COUNT as the aggregation function. Use kitchen as the expression to count for KitchenPresenceCount (and so on) and make all the presence Items be members of all these Groups. The Groups will calculate their own count and you don’t have to do anything in your rule at all except check the state of the count Group Item.
Should know that lol. Always helps to have second pair eyes
That’s what I was thinking
I did see Group:Number:COUNT but was trying to get away from using files for items at least and using UI. Count isnt yest available in UI for group items
rule "Presence based Room Heating"
when
Member of gRoomPresence changed
then
if (Heating_Type.state == "Home"){
val Number kitchenpresencecount=(gRoomPresence?.members.filter[i|i.state.toString == "kitchen"].size)
val Number livingroompresencecount=(gRoomPresence?.members.filter[i|i.state.toString == "livingroom"].size)
val Number firstfloorpresencecount=(gRoomPresence?.members.filter[i|i.state.toString == "firstfloor"].size)
if (triggeringItem.state.toString == "kitchen"){
ZWave59DiningRoomTRV_Setpointheating.sendCommand(Heat_Mode_Home_Temp.state as Number)
KitchenPresenceCount.postUpdate(kitchenpresencecount)
}
if (triggeringItem.state == "livingroom"){
gLIvingRoomTemp.sendCommand(Heat_Mode_Home_Temp.state as Number)
LivingRoomPresenceCount.postUpdate(livingroompresencecount)
}
if (triggeringItem.state == "firstfloor"){
gFFHeating.sendCommand(Heat_Mode_Home_Temp.state as Number)
FirstFloorPresenceCount.postUpdate(firstfloorpresencecount)
}
if (kitchenpresencecount == 0)
KitchenPresenceSwitch.sendCommand(ON)
if (livingroompresencecount == 0)
LivingRoomPresenceSwitch.sendCommand(ON)
if (firstfloorpresencecount == 0)
FirstFloorPresenceSwitch.sendCommand(ON)
}
end
rule "Reduce Heating Temp"
when
Member of gPresenceSwitch changed to OFF
then
if (triggeringItemName == "KitchenPresenceSwitch")
ZWave59DiningRoomTRV_Setpointheating.sendCommand(Heat_Mode_Away_Temp.state as Number)
if (triggeringItemName == "LivingRoomPresenceSwitch")
gLIvingRoomTemp.sendCommand(Heat_Mode_Away_Temp.state as Number)
if (triggeringItemName == "FirstFloorPresenceSwitch")
gFFHeating.sendCommand(Heat_Mode_Away_Temp.state as Number)
end
What I did in the end
1st rule changes the occupation of the room - on or off
2nd rule - allows a period of time until heating switches to unoccupied room temp
Now Im struggling to set the value for checking the heating to come on whichever occupied room temp has the lowest value