Ds18b20 temp and relay control via openhab
Moderators: grovkillen, Stuntteam, TD-er
Ds18b20 temp and relay control via openhab
Hi everyone. I'm fairly new to espeasy and esp8266.
I have. 6 sonoff switches loaded with espeasy using mqtt with openhab. They work flawlessly with espeasy and I'm really happy with them.
Not I have switches working I would like to create a thermostat that will turn my boiler on and off.
Does anyone have settings I can steal to get the ds18b20 working with mqtt on openhab along with relay.
And also if anyone has sitemap/items examples I could look at?
Kind regards
Steven
I have. 6 sonoff switches loaded with espeasy using mqtt with openhab. They work flawlessly with espeasy and I'm really happy with them.
Not I have switches working I would like to create a thermostat that will turn my boiler on and off.
Does anyone have settings I can steal to get the ds18b20 working with mqtt on openhab along with relay.
And also if anyone has sitemap/items examples I could look at?
Kind regards
Steven
Re: Ds18b20 temp and relay control via openhab
You can even realise this rules and global sync, no need for a controller. I could help with that. Other than that I use domoticz via http, so no idea how to OpenHAB/MQTTshenery wrote: ↑06 May 2017, 11:58 Hi everyone. I'm fairly new to espeasy and esp8266.
I have. 6 sonoff switches loaded with espeasy using mqtt with openhab. They work flawlessly with espeasy and I'm really happy with them.
Not I have switches working I would like to create a thermostat that will turn my boiler on and off.
Does anyone have settings I can steal to get the ds18b20 working with mqtt on openhab along with relay.
And also if anyone has sitemap/items examples I could look at?
Kind regards
Steven
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8
Re: Ds18b20 temp and relay control via openhab
I have just altered one of my switches with the relay on to include the ds18b20 sensor and ticked global sync. I can now see temperature reading in the log. I will try and add this to my sitemap and items later and see if it works 

Re: Ds18b20 temp and relay control via openhab
Be sure to add a little difference between turn on and turn off temperature in OpenHAB as the DS18B20 readings can flick between 2 values every time they are read. A rule similar to the one below in OpenHAB should work
Rule "regulate temperature"
when Item MyTemperatureSensorChanged then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
if (MyTemperatureSensor.state > 20) {
//Do stuff like turn Heater OFF etc
}
if (MyTemperatureSensor.state < 19.8) {
//Do stuff like turn Heater ON etc
}
}
end
Rule "regulate temperature"
when Item MyTemperatureSensorChanged then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
if (MyTemperatureSensor.state > 20) {
//Do stuff like turn Heater OFF etc
}
if (MyTemperatureSensor.state < 19.8) {
//Do stuff like turn Heater ON etc
}
}
end
Re: Ds18b20 temp and relay control via openhab
Hi @sheppy thanks for getting back to me.
I was wondering if you could send me a copy if you sitemap and items so that I can compare with mines.
Kind regards
Steven
I was wondering if you could send me a copy if you sitemap and items so that I can compare with mines.
Kind regards
Steven
Re: Ds18b20 temp and relay control via openhab
Hi Steven,
in this case the Items file would read
Number MyTemperatureSensor { mqtt="<[mosquitto:TOPIC/MyTemperatureSensor:state:default]" }
Switch Heater
where "mosquitto" is the actual name of the MQTT Server set in Openhab, and "TOPIC" is the topic set in ESPEasy
The Sitemap would read
Text item=MyTemperatureSensor label="My Temperature Sensor [%.1f C]" icon="temperature"
Switch item=Heater
In this case "1" in [%.1f C" refers to the number of decimal places to be displayed, and "C" refers to the letter "C" appearing after the reading
in this case the Items file would read
Number MyTemperatureSensor { mqtt="<[mosquitto:TOPIC/MyTemperatureSensor:state:default]" }
Switch Heater
where "mosquitto" is the actual name of the MQTT Server set in Openhab, and "TOPIC" is the topic set in ESPEasy
The Sitemap would read
Text item=MyTemperatureSensor label="My Temperature Sensor [%.1f C]" icon="temperature"
Switch item=Heater
In this case "1" in [%.1f C" refers to the number of decimal places to be displayed, and "C" refers to the letter "C" appearing after the reading
Re: Ds18b20 temp and relay control via openhab
Thank you very much for your reply.
I now have my temperature with a heating switch underneath.
Do you know if it is possible to have and up down control switch of the heating temperature? As in turn the relay on or off like a thermostat depending on which temperature you see. A bit like this?
Kind regards
Steven
I now have my temperature with a heating switch underneath.
Do you know if it is possible to have and up down control switch of the heating temperature? As in turn the relay on or off like a thermostat depending on which temperature you see. A bit like this?
Kind regards
Steven
- Attachments
-
- Screenshot_20170509-072904.png (232.29 KiB) Viewed 24432 times
Re: Ds18b20 temp and relay control via openhab
Yes it's very doable, I use something similar to work my Heatpumps. I'll take a look in the morning and give you a few clues, although you might be better putting the question on community.openhab.com
Re: Ds18b20 temp and relay control via openhab
Ok, try this
Items file
Number MyTemperatureSensor { mqtt="<[mosquitto:TOPIC/MyTemperatureSensor:state:default]" }
Number WantedTemperature
Switch Heater
Sitemap file
Text item=MyTemperatureSensor label="My Temperature Sensor [%.1f C]" icon="temperature"
Setpoint item=WantedTemperature label="Heating Setpoint [%.1f C]" icon="temperature" minValue=17 maxValue=28 step=0.3] // adjust the minValue and maxValue and step to whatever makes sense to you
Switch item=Heater
Rules
"Rule set default temperature"
when System started then {
postUpdate(WantedTemperature, 21)
}
end
this sets the temperature to something sensible after the system starts and also after this rule is edited, once it has been set and persistence has been added with restore on startup this rule can be disabled
Rule "regulate temperature"
when Item MyTemperatureSensorChanged or Item WantedTemperature changed then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
var WT = WantedTemperature.state as Number
if (MyTemperatureSensor.state > WT) {
//Do stuff like turn Heater OFF etc
}
if (MyTemperatureSensor.state < WT) {
//Do stuff like turn Heater ON etc
}
}
end
Items file
Number MyTemperatureSensor { mqtt="<[mosquitto:TOPIC/MyTemperatureSensor:state:default]" }
Number WantedTemperature
Switch Heater
Sitemap file
Text item=MyTemperatureSensor label="My Temperature Sensor [%.1f C]" icon="temperature"
Setpoint item=WantedTemperature label="Heating Setpoint [%.1f C]" icon="temperature" minValue=17 maxValue=28 step=0.3] // adjust the minValue and maxValue and step to whatever makes sense to you
Switch item=Heater
Rules
"Rule set default temperature"
when System started then {
postUpdate(WantedTemperature, 21)
}
end
this sets the temperature to something sensible after the system starts and also after this rule is edited, once it has been set and persistence has been added with restore on startup this rule can be disabled
Rule "regulate temperature"
when Item MyTemperatureSensorChanged or Item WantedTemperature changed then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
var WT = WantedTemperature.state as Number
if (MyTemperatureSensor.state > WT) {
//Do stuff like turn Heater OFF etc
}
if (MyTemperatureSensor.state < WT) {
//Do stuff like turn Heater ON etc
}
}
end
Re: Ds18b20 temp and relay control via openhab
OK so I think I'm nearly there.
I have my sitemap looking not bad and can turn on off the heating but I am having trouble getting the temp to display in openhab. Its reading fine in espeasy log so is working.
I think I need to alter my code slightly.
I have my sitemap looking not bad and can turn on off the heating but I am having trouble getting the temp to display in openhab. Its reading fine in espeasy log so is working.
I think I need to alter my code slightly.
- Attachments
-
- Screenshot_20170510-172737.png (193.12 KiB) Viewed 24349 times
-
- Screenshot_20170510-172314.png (147.5 KiB) Viewed 24349 times
-
- Screenshot_20170510-172305.png (51.34 KiB) Viewed 24349 times
-
- Screenshot_20170510-172258.png (64.95 KiB) Viewed 24349 times
-
- Screenshot_20170510-172231.png (57.13 KiB) Viewed 24349 times
-
- Screenshot_20170510-172159.png (61.24 KiB) Viewed 24349 times
-
- Screenshot_20170510-075040.png (61.5 KiB) Viewed 24349 times
Re: Ds18b20 temp and relay control via openhab
Heres the rest of my settings
- Attachments
-
- Screenshot_20170510-175124.png (61.43 KiB) Viewed 22520 times
-
- Screenshot_20170510-175124.png (61.43 KiB) Viewed 22520 times
-
- Screenshot_20170510-175045.png (192.55 KiB) Viewed 22520 times
-
- Screenshot_20170510-172801.png (112.73 KiB) Viewed 22520 times
Re: Ds18b20 temp and relay control via openhab
I managed to get the temperature reading in openhab. I had the mqtt location wrong.
I have also created a .rules file in openhab which I didn't post before but still when I increase the temp in openhab my heater doesn't go on.
I have also created a .rules file in openhab which I didn't post before but still when I increase the temp in openhab my heater doesn't go on.
- Attachments
-
- Screenshot_20170510-192403.png (101.55 KiB) Viewed 22514 times
-
- Screenshot_20170510-185657.png (62.73 KiB) Viewed 22514 times
Re: Ds18b20 temp and relay control via openhab
If that's the actual rule?
"//Do stuff like turn Heater OFF etc" will need replacing with
"sendCommand(Heater, OFF)"
AND
"//Do stuff like turn Heater ON etc" will need replacing with
"sendCommand(Heater, ON)"
all without the ""
also anything after // is a comment and is for information only
"//Do stuff like turn Heater OFF etc" will need replacing with
"sendCommand(Heater, OFF)"
AND
"//Do stuff like turn Heater ON etc" will need replacing with
"sendCommand(Heater, ON)"
all without the ""
also anything after // is a comment and is for information only
Re: Ds18b20 temp and relay control via openhab
Ah I see. How do I get my power icon back? The heater has a lightbulb instead of a power icon. Is this because my heater item is set up as a light?
Thanks for all your help by the way. Much appreciated.
Steven
Thanks for all your help by the way. Much appreciated.
Steven
Re: Ds18b20 temp and relay control via openhab
Yes, see below for available icons, try using "fire" or "heating" as an icon and the icon will change between ON and OFFIs this because my heater item is set up as a light?
http://docs.openhab.org/addons/iconsets ... eadme.html
Re: Ds18b20 temp and relay control via openhab
Ok I've tidied things up a bit but I still can't get it to do what I want. When I have the heater on and decrease the temp the relay should switch off right? And switch back on when I increase the temp?
I can turn my heater on and off but now with temperature adjustment.
I can turn my heater on and off but now with temperature adjustment.
- Attachments
-
- Screenshot_20170511-074528.png (93.72 KiB) Viewed 22475 times
Re: Ds18b20 temp and relay control via openhab
Looking at it on my phone I suspect you have a missing space in the second line, it should read
"when item MyTemperatureSensor changed or item WantedTemperature changed then"
"when item MyTemperatureSensor changed or item WantedTemperature changed then"
Re: Ds18b20 temp and relay control via openhab
Its still not working. Here are my items rules and sitemap.
- Attachments
-
- Screenshot_20170511-145957.png (191.98 KiB) Viewed 22460 times
-
- Screenshot_20170511-150007.png (92.58 KiB) Viewed 22460 times
-
- Screenshot_20170511-150128.png (111.45 KiB) Viewed 22460 times
Re: Ds18b20 temp and relay control via openhab
OK, lets see what is working.
Change your rules file to read
"Rule set default temperature"
when System started then {
postUpdate(WantedTemperature, 21)
}
end
rule "test what is working"
when Item MyTemperatureSensorChanged or Item WantedTemperature changed then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
var WT = WantedTemperature.state as Number
var MT = MyTemperatureSensor.state as Number
logInfo("Testing", "Wanted Temperature is " +WT
logInfo("Testing". "Sensed Temperature is " +MT
}
end
Now open up openhab.log - if you have Raspbian Jessie and an apt-get installation it is found in /var/log/openhab2 and can be seen live by typing
tail -f /var/log/openhab2/openhab.log for other operating systems and installations please see the openhab documentation
whenever the temperature changes or when you change the requested temperature you should see 2 log entries, the first with the set temperature, and the second with the sensed temperature. If any of these aren't the values you expect then you need to check your items file, and also for the sensed temperature you need to check the device running ESPEasy
Change your rules file to read
"Rule set default temperature"
when System started then {
postUpdate(WantedTemperature, 21)
}
end
rule "test what is working"
when Item MyTemperatureSensorChanged or Item WantedTemperature changed then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
var WT = WantedTemperature.state as Number
var MT = MyTemperatureSensor.state as Number
logInfo("Testing", "Wanted Temperature is " +WT
logInfo("Testing". "Sensed Temperature is " +MT
}
end
Now open up openhab.log - if you have Raspbian Jessie and an apt-get installation it is found in /var/log/openhab2 and can be seen live by typing
tail -f /var/log/openhab2/openhab.log for other operating systems and installations please see the openhab documentation
whenever the temperature changes or when you change the requested temperature you should see 2 log entries, the first with the set temperature, and the second with the sensed temperature. If any of these aren't the values you expect then you need to check your items file, and also for the sensed temperature you need to check the device running ESPEasy
Re: Ds18b20 temp and relay control via openhab
Ok I've checked the log and it is only giving me wanted temperature when I click + or -I don't get any sensed temperature.
Re: Ds18b20 temp and relay control via openhab
Sounds like a ESPeasy or mqtt configuration problem, I'm unable to get to my PC for a day or so now, I'd recommend checking those things. When it's working you should see a valid reading in your sitemap that changes if you warm the sensor by warming it with your hand
Re: Ds18b20 temp and relay control via openhab
Ok here's where I'm at.
I have openhab log working and I can now see sensed temperature
I can see wanted temperate
I can switch my heating switch on and off manually but not with altering the setpoint in the sitemap.
In the log with original rules you sent when I change set point I get wanted temperature changed but I don't see a command for on or off to the switch.
I have attached some screenshots.
Kind regards
Steven
I have openhab log working and I can now see sensed temperature
I can see wanted temperate
I can switch my heating switch on and off manually but not with altering the setpoint in the sitemap.
In the log with original rules you sent when I change set point I get wanted temperature changed but I don't see a command for on or off to the switch.
I have attached some screenshots.
Kind regards
Steven
- Attachments
-
- Screenshot_20170512-212455.png (198.1 KiB) Viewed 22932 times
-
- Screenshot_20170512-212609.png (267.78 KiB) Viewed 22932 times
-
- Screenshot_20170512-212829.png (158.99 KiB) Viewed 22932 times
Re: Ds18b20 temp and relay control via openhab
And here's one of me switching the heating on manually.
- Attachments
-
- Screenshot_20170512-213837.png (168.89 KiB) Viewed 22931 times
Re: Ds18b20 temp and relay control via openhab
The purple writing in the screenshot suggests there is a problem with your rules file, and looking at my original rules there was a couple of missing close brackets. Usually I use smarthome designer from the openhab downloads site for my editing, whilst its not perfect, it catches most of these. I'd strongly recommend it for someone new to OpenHAB.
Now we have valid values, change the rules to read this, use copy and delete what is already there. If you get the purple cannot be parsed correctly rule there usually is a typo somewhere. Once it is working add // before each logging statement to stop it filling the logs
"Rule set default temperature"
when System started then {
postUpdate(WantedTemperature, 21)
}
end
rule "test what is working"
when Item MyTemperatureSensor Changed or Item WantedTemperature changed then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
var WT = WantedTemperature.state as Number
var MT = MyTemperatureSensor.state as Number
logInfo("Testing", "Wanted Temperature is " +WT)
logInfo("Testing", "Sensed Temperature is " +MT)
if (MT > WT) { sendCommand(Heater, OFF) }
if (MT + 0.1 < WT) {sendCommand(Heater, ON) }
}
end
Now we have valid values, change the rules to read this, use copy and delete what is already there. If you get the purple cannot be parsed correctly rule there usually is a typo somewhere. Once it is working add // before each logging statement to stop it filling the logs
"Rule set default temperature"
when System started then {
postUpdate(WantedTemperature, 21)
}
end
rule "test what is working"
when Item MyTemperatureSensor Changed or Item WantedTemperature changed then
if (MyTemperatureSensor.state !=NULL) { // add in any checks after the NULL statement to ensure the reading is valid
var WT = WantedTemperature.state as Number
var MT = MyTemperatureSensor.state as Number
logInfo("Testing", "Wanted Temperature is " +WT)
logInfo("Testing", "Sensed Temperature is " +MT)
if (MT > WT) { sendCommand(Heater, OFF) }
if (MT + 0.1 < WT) {sendCommand(Heater, ON) }
}
end
Re: Ds18b20 temp and relay control via openhab
I tried that and got the same error. I have eclipse installed but haven't really delved that deep in to it yet. Had a look last night and I can see all my files but not sure how to check syntax and stuff like that.
Also what do you mean with adding // before log entries?
Kind regards
Steven
Also what do you mean with adding // before log entries?
Kind regards
Steven
Re: Ds18b20 temp and relay control via openhab
Not even getting a decent log reading now. Don't know what I've done wrong. When I do log:tail I get endless readings and they go that fast I can hardly read them.
- Attachments
-
- Screenshot_20170514-105023.png (222.04 KiB) Viewed 22887 times
Re: Ds18b20 temp and relay control via openhab
I managed to get it working at last!
worked out how to find errors with eclipse smart home and turns out I had " in the wrong place. It was to the left of the. "Rule instead of rule " regulate temperature.
Thanks for all your help sheppy. I now have a working WiFi thermostat.
Kind regards
Steven

Thanks for all your help sheppy. I now have a working WiFi thermostat.
Kind regards
Steven
Re: Ds18b20 temp and relay control via openhab
Well done! Using the designer is a good idea as a small typo can waste much time when you are new to Openhab. It is a great system once you master it and https://community.openhab.org is a great place to search if you have a problem. ESPEasy also works very well with it
Re: Ds18b20 temp and relay control via openhab
Yeah. I'll be using eclipse a lot more, now that I know how to use it. Was pulling my hair out a bit but go there in the end. Was a good learning exercise.
Thanks again
Stevenn
Thanks again
Stevenn
Re: Ds18b20 temp and relay control via openhab
One other thing I'd recommend is working out how you see the system ending up in future and then planning your MQTT topic tree so it makes sense going forward. For example you could have
Security/ containing the status of doors and windows
Heating/ or
Climate/ for your heater items or maybe extra sub topics make sense such as
Climate/LivingRoom/
Climate/MainBedroom/
Electricity/
Home automation systems have a habit of growing and what seems over complicated now may work out better in future when you are trying to debug an obscure fault.
When debugging you can use a program such as mqtt.fx subscribe to all messages with a simple "#" or subscribe to sub topics such as "Climate/#" or even in the above example "Climate/LivingRoom/#"
The first "/" in the topic tree isn't needed btw so your topic "/StevensLamp/gpio/12" could be simplified to "StevensLamp/gpio/12" as long as both OpenHAB and ESPEasy are changed
Security/ containing the status of doors and windows
Heating/ or
Climate/ for your heater items or maybe extra sub topics make sense such as
Climate/LivingRoom/
Climate/MainBedroom/
Electricity/
Home automation systems have a habit of growing and what seems over complicated now may work out better in future when you are trying to debug an obscure fault.
When debugging you can use a program such as mqtt.fx subscribe to all messages with a simple "#" or subscribe to sub topics such as "Climate/#" or even in the above example "Climate/LivingRoom/#"
The first "/" in the topic tree isn't needed btw so your topic "/StevensLamp/gpio/12" could be simplified to "StevensLamp/gpio/12" as long as both OpenHAB and ESPEasy are changed
Re: Ds18b20 temp and relay control via openhab
I have a whole bunch of stuff done on this topic I could help you with if I had my laptop up. I'm using many esp and motorized vents to regulate temperature like zoning in every room. I use openhab as well 
The vent can be open closed or set for heat/cool. In heat or cool it opens or closes as temperature goes up or down depending on how you want it. Then, the use ac and use furnace switches affect a variable. If enough rooms want ac or heat there's another esp that'll turn on the hvav separate of the nest
Also, the readings of the Dallas are awesome, they vary very little. I used to use analog sensors and averaged them over 3 minutes using readings every 10 seconds. With the Dallas I have it send a reading every 3 minutes using a separate esp that's in deep sleep and battery powered away from the vent. The Dallas sensors are rock solid

The vent can be open closed or set for heat/cool. In heat or cool it opens or closes as temperature goes up or down depending on how you want it. Then, the use ac and use furnace switches affect a variable. If enough rooms want ac or heat there's another esp that'll turn on the hvav separate of the nest
Also, the readings of the Dallas are awesome, they vary very little. I used to use analog sensors and averaged them over 3 minutes using readings every 10 seconds. With the Dallas I have it send a reading every 3 minutes using a separate esp that's in deep sleep and battery powered away from the vent. The Dallas sensors are rock solid
Re: Ds18b20 temp and relay control via openhab
HEre are the relevant portions if you want. Any questions, just ask.
nursery items
nursery rules (the use furnace / use ac stuff isn't done yet. that's why at least one section is missing. )
sitemap
The reason i have a Vent and Vents item is one is virtual and i only want it to send a command to the actual ESP when the virtual *changes*
I don't want actuating the motor for no reason
nursery items
Code: Select all
Number Nursery_Temperature "Nursery Temp [%.1f °F]" <temperature> {mqtt="<[oh2:/NurserySensor/Nursery_Temp/NUR_TEMP:state:default]" }
Number Nursery_Volts "Nursery Volts [%.2f V]" <electric> {mqtt="<[oh2:/NurserySensor/Nursery_Volt/NUR_VOLT:state:default]" }
Number VT_Vent_Setpoint_Nursery "Nursery Setpoint [%.1f °F]" <degreesf>
Number VT_Vent_Mode_Nursery "Nursery Vent Control" <heating>
Switch FF_Nursery_Vent "Nursery Vents" <fire> {http=">[OFF:POST:http://192.168.1.151/control?cmd=event,closevent] >[ON:POST:http://192.168.1.151/control?cmd=event,openvent]"}
Number AVG_Nursery "Nursery Average Temp [%.1f °F]" <degreesf>
Switch FF_Nursery_Vents "Nursery Vents" <fan>
Number VT_Nursery_Keepwarm "Nursery Call Heat" <fire>
Number VT_Nursery_Keepcool "Nursery call cool" <fan>
Number NurseryNeedHeat "Nursery Heat Request" <fire>
nursery rules (the use furnace / use ac stuff isn't done yet. that's why at least one section is missing. )
Code: Select all
rule "Nursery OnOff"
when
Item VT_Vent_Mode_Nursery changed
then
// 0="Off", 1="On", 2="Auto"
if (VT_Vent_Mode_Nursery.state == 0) {
// heater off
FF_Nursery_Vents.sendCommand(OFF)
} else if (VT_Vent_Mode_Nursery.state == 1) {
// heater on
FF_Nursery_Vents.sendCommand(ON)
}
else{
FF_Nursery_Vents.sendCommand(ON)
}
end
rule "Nursery Vents Status"
when
Item VT_Vent_Mode_Nursery changed or
Item VT_Vent_Setpoint_Nursery changed or
Item Nursery_Temperature changed
then
if (VT_Vent_Mode_Nursery.state == 2) {
var Number setpointN = VT_Vent_Setpoint_Nursery.state as DecimalType
var Number turnOnTempN = setpointN - 0.5
var Number turnOffTempN = setpointN + 0.5
var Number tempN = Nursery_Temperature.state as DecimalType
if (tempN <= turnOnTempN) {
FF_Nursery_Vents.sendCommand(ON)
} else if (tempN >= turnOffTempN) {
FF_Nursery_Vents.sendCommand(OFF)
}
}
if (VT_Vent_Mode_Nursery.state == 3) {
var Number setpointN = VT_Vent_Setpoint_Nursery.state as DecimalType
var Number turnOnTempN = setpointN + 0.5
var Number turnOffTempN = setpointN - 1.5
var Number tempN = Nursery_Temperature.state as DecimalType
if (tempN >= turnOnTempN) {
FF_Nursery_Vents.sendCommand(ON)
} else if (tempN <= turnOffTempN) {
FF_Nursery_Vents.sendCommand(OFF)
}
}
end
rule "Nursery Vent Control"
when
Item FF_Nursery_Vents changed
then
if (FF_Nursery_Vents.state == ON){
FF_Nursery_Vent.sendCommand(ON)
} else if (FF_Nursery_Vents.state == OFF) {
FF_Nursery_Vent.sendCommand(OFF)
}
end
rule "Nursery Use Furnace"
when
Item VT_Nursery_Keepwarm changed or
Item Nursery_Temperature changed or
Item VT_Vent_Mode_Nursery changed or
Item VT_Vent_Setpoint_Nursery changed
then
if (VT_Nursery_Keepwarm.state == 1 && VT_Vent_Mode_Nursery.state == 2) {
var Number setpointN = VT_Vent_Setpoint_Nursery.state as DecimalType
var Number turnOnTempN = setpointN - 0.5
var Number turnOffTempN = setpointN + 0.5
var Number tempN = Nursery_Temperature.state as DecimalType
if (tempN <= turnOnTempN) {
postUpdate(NurseryNeedHeat,1)
} else if (tempN >= turnOffTempN) {
postUpdate(NurseryNeedHeat,0)
}
}
if (VT_Vent_Mode_Nursery.state == 0 || VT_Vent_Mode_Nursery.state == 1 || VT_Vent_Mode_Nursery.state == 3) {
postUpdate(NurseryNeedHeat,0)
}
end
Code: Select all
Text label="Nursery" icon="baby_1"{
Frame {
Switch item=VT_Vent_Mode_Nursery label="Vent Control" mappings=[0="Off", 1="On", 2="Heat", 3="Cool"]
Setpoint item=VT_Vent_Setpoint_Nursery label="Target Temperature [%.1f °F]" minValue=65 maxValue=80 step=0.5 visibility=[VT_Vent_Mode_Nursery==2, VT_Vent_Mode_Nursery==3] icon="heating-60"
Text item=FF_Nursery_Vent
Text item=Nursery_Temperature
Switch item=VT_Nursery_Keepwarm label="Use Furnace?" mappings=[0="Off", 1="On"]
Switch item=VT_Nursery_Keepcool label="User AC?" mappings=[0="Off", 1="On"]
Text item=Nursery_Volts icon="battery-90"
Chart item=Nursery_Temperature period=4h refresh=300
Chart item=Nursery_Volts period=D refresh=300
}
}
The reason i have a Vent and Vents item is one is virtual and i only want it to send a command to the actual ESP when the virtual *changes*
I don't want actuating the motor for no reason
Who is online
Users browsing this forum: No registered users and 18 guests