This is my first stab at a JavaScript Rule, and I’m also setting up a new installation managing 14 air conditioners, with more to come later.
I am pulling in a calendar, and am seeing events update from that, and I want to schedule rooms to be cooled some time before the event starts, and then revert to a different condition after the event is over. The question is how to best define my group memberships.
Three classrooms, D1, D2 and D3.
Group gOC_D1 "d1/108" (gOC,gHVACZONE_OC_D1)["Room"]
Group gOC_D2 "d2/107" (gOC,gHVACZONE_OC_D2)["Room"]
Group gOC_D3 "d3/106" (gOC,gHVACZONE_OC_D3)["Room"]
three thermostats, and one setpoint as example:
Group gHVAC_OC_D1 "Thermostat D1" (gOC_D1) ["HVAC"] {synonyms="Thermostats" }
Group gHVAC_OC_D2 "Thermostat D2" (gOC_D2) ["HVAC"] {synonyms="Thermostats" }
Group gHVAC_OC_D3 "Thermostat D3" (gOC_D3) ["HVAC"] {synonyms="Thermostats" }
Number Room106_ControlsCoolsetpoint "Cool setpoint" <temperature> (gHVAC_OC_D3) ["Setpoint","Temperature"] {channel="mqtt:homie300:a40be34a38:somecomfort4778499:controls#coolsetpoint",stateDescription=""[min="72",max="100",step="1"],widget="oh-stepper-card",listWidget="oh-stepper-item",cellWidget="oh-stepper-cell"}
Calendar feed:
DateTime FeedD3Result0Begin "Start of result" (gCalendarTstat,gHVACZONE_OC_D3){channel="icalendar:eventfilter:feed_d3:result_0#begin"}
Is this the correct approach, or is there a better way? In JavaScript I would:
Rule is triggered when member of gCalendarTstat is updated.
From the triggering item, get the groups it belongs to. From that group, get the one group whose name contains HVACZONE.
From that group, get the members, filtered by the item whose name contains setpoint, and that item should be the cooling setpoint I need to set for the duration of the event.
I havent found any group operation examples for JavaScript, so pointers there would be helpful.
Oh, and I’m new to JavaScript. I know Java, but not JavaScript. I’m doing this new system without Rules DSL.