Hello everyone,
I am new at Openhab and this is my first post. So please bare with me the explanation of my query.
This might be quiet simple but I am trying to figure out a way to link an item value to another item using rules.
As you can see, I have a Day mode and a automatic mode and respective set temperatures for 2 rooms viz. Meeting and Laboratory.
Rules Files:
rule "Initialise system values for all variables"
when
System started
then
Set_Room_Temp_Day_Meeting.sendCommand(21)
Set_Room_Temp_Day_Laboratory.sendCommand(21)
end
/* Rule for Selection of Operating Mode */
rule "Operating Mode Activate"
when
Item Operating_Mode received command
then
if(Operating_Mode.state=="Day_Mode") {
Day_Mode.sendCommand(ON)
}
if(Operating_Mode.state=="Automatic") {
Automatic.sendCommand(ON)
}
end
/* Rule for Day Mode */
rule "Day Mode"
when
Item Day_Mode received command
then
Set_Room_Temp_Day_Meeting.sendCommand(22)
Set_Room_Temp_Day_Laboratory.sendCommand(22)
end
/* Rule for Day Room Temp */
rule "Day Room Temp"
when
Item Set_Room_Temp_Day_Meeting received command or
Item Set_Room_Temp_Day_Laboratory received command
then
if(Day_Mode.state==ON) {
Set_Room_Temp_Meeting.postUpdate(22)
Set_Room_Temp_Laboratory.postUpdate(22)
}
end
/* Rule for Automatic Mode */
rule "Automatic Mode"
when
Item Automatic received command
then
Set_Room_Temp_Day_Meeting.sendCommand(26)
Set_Room_Temp_Day_Laboratory.sendCommand(26)
end
/* Rule for Automatic Room Temp */
rule "Automatic Room Temp"
when
Item Set_Room_Temp_Day_Meeting received command or
Item Set_Room_Temp_Day_Laboratory received command
then
if(Automatic.state==ON) {
Set_Room_Temp_Meeting.postUpdate(26)
Set_Room_Temp_Laboratory.postUpdate(26)
}
end
Items file:
/* Operating Modes */
String Operating_Mode "[MAP(op.map):%s]" <settings>
Switch Day_Mode "Operating Mode is [MAP(day.map):%s]" (All)
Switch Automatic "Operating Mode is [MAP(automatic.map):%s]" (All)
/* Room Temperature Data */
Number Set_Room_Temp_Meeting "Meeting Room Temperature [%.1f Ā°C]" <temperature> (Area_Meeting)
Number Set_Room_Temp_Laboratory "Laboratory Room Temperature [%.1f Ā°C]" <temperature> (Area_Laboratory)
Number Set_Room_Temp_Day_Meeting "Set Temperature Day - Meeting [%.1f Ā°C]" <temperature> (Area_Meeting)
Number Set_Room_Temp_Day_Laboratory "Set Temperature Day - Laboratory [%.1f Ā°C]" <temperature> (Area_Laboratory)
What I want to achieve is when the Set_Room_Temp_Day_Meeting receives command for the respective mode of operation, automatically the Temp_Meeting (display temp) should get updated with the respective value.
The same applies for the Temp_Laboratory.
But since I have used the rule twice for the respective room temperature values, the temperature values get mixed up for the different modes (since both have same names). Also when I independently change the set temperature of the room, I want the display temperature to change as well.
I end up clicking the mode twice to achieve this temperature to be displayed.
Hope I have made myself clear.
Is there a way to get the display temperature get automatically āupdatedā when the set temperature changes irrespective of the mode of operation? I dont want to include the postUpdate rule.
This would be a very useful rule for me.
Thank you.
I would suggest simplifying your rules. I donāt see where you are turning off the Automatic or Day mode if it switches between modes so it could be running in both modes which is what is likely mixing up your temperatures. Why not do something along the lines of.
. consolidating down to a single rule by setting the value of a setpoint variable and using it to set your actual set points. So something along the lines of:
//Global Variables
var tSet = 0
rule "Initialise system values for all variables"
when
System started
then
Set_Room_Temp_Day_Meeting.sendCommand(21)
Set_Room_Temp_Day_Laboratory.sendCommand(21)
end
/* Rule for Selection of Operating Mode */
rule "Operating Mode Activate"
when
Item Operating_Mode received command
then
if(Operating_Mode.state=="Day_Mode") {
tSet = 22
} elseif (Operating_Mode.state=="Automatic") {
tSet = 26
}
Set_Room_Temp_Day_Meeting.sendCommand(tSet)
Set_Room_Temp_Day_Laboratory.sendCommand(tSet)
Set_Room_Temp_Meeting.postUpdate(tSet)
Set_Room_Temp_Laboratory.postUpdate(tSet)
end
Sorry for the late reply.
Thank you for providing your solution. Something new I learnt from the usage of āvarā.
I used your solution but then I had other operation modes such as Automatic,Emergency, Manual, etc. which would have increased the number of variables. But soon I found what I required.
I was looking for this command.
rule "Set Night Meeting room temperature"
when
Item Set_Room_Temp_HC1_Night_Meeting received command
then
Set_Room_Temp_HC1_Meeting.sendCommand(Set_Room_Temp_HC1_Night_Meeting.state.toString)
end
But now I am ending up with atleast 12 rules (2 each for 6 operating modes).
I saw in the other topics abt the use of
MyGroup.members.foreach[i| <condition>]
how can I use this for my benefit?
Here I am attaching all my .items and operating modes for the temperatures.
Group Temperature_HC1 (All)
Group Temperature_HC2 (All)
/* Operating Modes */
String Operating_Mode "Mode [MAP(op.map):%s]" <settings>
Switch Automatic "Operating Mode is [MAP(automatic.map):%s]" (All)
Switch Standby "Operating Mode is [MAP(standby.map):%s]" (All)
Switch Day_Mode "Operating Mode is [MAP(day.map):%s]" (All)
Switch Setback "Operating Mode is [MAP(setback.map):%s]" (All)
Switch Manual "Operating Mode is [MAP(manual.map):%s]" (All)
Switch Emergency "Operating Mode is [MAP(emergency.map):%s]" (All)
// Room Temperature Data //
Number Set_Room_Temp_HC1_Meeting "Set Meeting Room Temperature [%.1f Ā°C]" <temperature> (Area_Meeting)
Number Set_Room_Temp_HC2_Laboratory "Set Laboratory Room Temperature [%.1f Ā°C]" <temperature> (Area_Laboratory)
Number Set_Room_Temp_HC1_Day_Meeting "Set Temperature Day - Meeting [%.1f Ā°C]" <temperature> (Temperature_HC1)
Number Set_Room_Temp_HC1_Night_Meeting "Set Temperature Night - Meeting [%.1f Ā°C]" <temperature> (Temperature_HC1)
Number Set_Room_Temp_HC1_Standby_Meeting "Set Temperature Standby - Meeting [%.1f Ā°C]" <temperature> (Temperature_HC1)
Number Set_Flow_Temp_HC1_Manual_Meeting "Set Flow Temperature Manual - Meeting [%.1f Ā°C]" <temperature> (Temperature_HC1)
Number Set_Room_Temp_HC2_Day_Laboratory "Set Temperature Day - Laboratory [%.1f Ā°C]" <temperature> (Temperature_HC2)
Number Set_Room_Temp_HC2_Night_Laboratory "Set Temperature Night - Laboratory [%.1f Ā°C]" <temperature> (Temperature_HC2)
Number Set_Room_Temp_HC2_Standby_Laboratory "Set Temperature Standby - Laboratory [%.1f Ā°C]" <temperature> (Temperature_HC2)
Number Set_Flow_Temp_HC2_Manual_Laboratory "Set Flow Temperature Manual - Laboratory [%.1f Ā°C]" <temperature> (Temperature_HC2)
My sitemap
Frame label="Heat Pump" {
Text item=Outside_Temp_Sensor
Text item=Set_Room_Temp_Meeting label="Set Meeting Room Temperature [%.1f Ā°C]"
Text item=Set_Room_Temp_Laboratory label="Set Laboratory Room Temperature [%.1f Ā°C]"
Text label="Room Temperatures" icon="temperature" {
Setpoint item=Set_Room_Temp_HC1_Day_Meeting step=1 minValue=15 maxValue=30 // Standard value 21 //
Setpoint item=Set_Room_Temp_HC2_Day_Laboratory step=1 minValue=15 maxValue=30 // Standard value 21 //
Setpoint item=Set_Room_Temp_HC1_Night_Meeting step=1 minValue=15 maxValue=30 // Standard value 21 //
Setpoint item=Set_Room_Temp_HC2_Night_Laboratory step=1 minValue=15 maxValue=30 // Standard value 21 //
Setpoint item=Set_Room_Temp_HC1_Standby_Meeting step=1 minValue=15 maxValue=30 // Standard value 10 //
Setpoint item=Set_Room_Temp_HC2_Standby_Laboratory step=1 minValue=15 maxValue=30 // Standard value 10 //
Setpoint item=Set_Flow_Temp_HC1_Manual_Meeting step=1 minValue=15 maxValue=30 // Standard value 35 //
Setpoint item=Set_Flow_Temp_HC2_Manual_Laboratory step=1 minValue=15 maxValue=30 // Standard value 35 //
}
Frame label="Mode of Operation" {
Switch item=Operating_Mode mappings=[EMERGENCY=Emergency, AUTOMATIC=Automatic, STANDBY=Standby, Day_Mode=Day, SETBACK=Setback, MANUAL=Manual]
}
So for each and every updated temperature of the respective mode or manually changed value of the temperature, I want that last updated temperature to be reflected for the respective display temperature on the sitemap āSet Meeting Room Temperatureā and āSet Laboratory Room Temperatureā using MyGroup.members.
and how can I make use of persistence in this case, if at all possible?