Page 1 of 1
Regulating temperature
Posted: Saturday 09 March 2019 7:59
by ulfh2018
I have started on a prpject helping my twin brother to replace his old heat controling system, which is VERY expensive to replace using the vendors components. I plan to use DS18b20 as sensors, connected to ESP8266 running ESPEasy. I have already tested with DTH22, and it works fine, but the DTH22 is draining too much power, so I cannot use batteries (though I use Deep Sleep mode on in ESPEasy). I suppose there will not be any problems changing to DS18b20, but I would like to implement something like what is shown in
https://www.youtube.com/watch?v=1ef6tRinOQ4
I know the ESPEasy part, but I'm not very used to Domoticz, since I have been using Node-Red most of the time. Now I find the interface on Domoticz better, so I want to try, though it would not be difficult for me to implent in Node-Red.
I would like to implement the symbol he is using for regulating temperatures up and down, but I have no clue to how this is done. Can someone please help me?
Best regards
Ulf

- image.jpg (10.6 KiB) Viewed 5687 times
Re: Regulating temperature
Posted: Saturday 09 March 2019 9:13
by freijn
Ulf
In the ESP you define the "idx" which is the number of the sensor in your domoticz.
"behind" the symbol you show there is also an "idx". You do need to write a script taking the change of the temp set and compare to the current
room temp.
But.........
Have a look in the forum there is a topic with a complete script where you only have to change the "idx" settings and get it going!!
Cheers,
Frank
Re: Regulating temperature
Posted: Monday 11 March 2019 12:25
by ulfh2018
Thank you so much for answering!
I know about the idx-stuff etc, Frank, but dont understand how to set up the Utility Sensor and where to find the icon that is regulating the temperature. If you can give me a hint where to find the example among the myriades of helpful information, I would be really happy. Have been playing around for a some time, but have not found what you are talking about so far
Cheers,
Ulf
Re: Regulating temperature
Posted: Monday 11 March 2019 14:49
by waaren
ulfh2018 wrote: āMonday 11 March 2019 12:25
I dont understand how to set up the Utility Sensor and where to find the icon that is regulating the temperature. If you can give me a hint where to find the example among the myriades of helpful information
First you need add virtual hardware. You do that on the hardware tab by adding a Type "Dummy (Does nothing, use for virtual switches only)"
After that on the same tab you click the "create Virtual Sensors" button just below the newly created virtual hardware.
Create a virtual sensor named "ESPeasyThermostat" type Thermostat setpoint
Create a virtual sensor named "ESPeasyTemperature" type Temperature
You will find the setpoint Icon on the utility tab and the temperature on the temperature tab.
Below an example dzVents script that will react on changes to the setPoint and Temperature and send MQTT commands to a topic using mosquitto.
Please feel free to ask clarification where / when needed.
Code: Select all
-- mqqt
return {
on = { devices =
{
"ESPeasyThermostat", -- name of your virtual setPoint device
"ESPeasyTemperature",
}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "MQTT setpoint"
},
data = { MQTTCommand = { initial = { "notSet" }
}
},
execute = function(dz, item)
local MQTTTopic = "espeasy/setPoint"
local temperature = dz.devices("ESPeasyTemperature").temperature
local setpoint = dz.devices("ESPeasyThermostat").setPoint
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
local function osExecute(cmd)
logWrite("Executing command: " .. cmd)
local fileHandle = assert(io.popen(cmd, 'r'))
assert(fileHandle:read('*a'))
fileHandle:close()
end
local action = "close"
if temperature <= setpoint then action = "open" end
if dz.data.MQTTCommand ~= action then
local mqttCommand = "mosquitto_pub -t " .. MQTTTopic .. " -m '" .. action .. "'"
osExecute(mqttCommand)
logWrite("Sent " .. action .. " to MQTT topic " .. MQTTTopic)
logWrite("Temperature: " .. temperature .. ", setpoint: " .. setpoint)
dz.data.MQTTCommand = action
else
logWrite("Temperature: " .. temperature .. ", setpoint: ".. setpoint)
logWrite("No action needed; " .. action .. " already send to MQTT topic " .. MQTTTopic)
end
end
}
Re: Regulating temperature
Posted: Tuesday 12 March 2019 9:19
by ulfh2018
Hello Waaren
I was sure I had replied, but for some reason it does not show, so I have to do it again.
Thanks a lot for your help! It made my day. It's so easy when you know where to look, and I have been playing with Domoticz for just a few weeks. I get the fundamental stuff, and I have been looking at C# and a couple of other languages, so I'm able to get the syntax without struggelig too hard.
I'll keep in touch - especially if there is something I don't understand, but I think the road should not be so hard to find now.
All the best from
Ulf
Re: Regulating temperature
Posted: Tuesday 12 March 2019 15:25
by ulfh2018
Hello Waaren
Well, was not as easy as I thought.
Have done the following:
1. Installed local MQTT - no password (testing only)
2. Created the two virtual sensors, using the same name as you have
3. Copied the code
4. Activated the event
When I try to change the valu in the Setpoint, this is not reflected to temperature.
Logfile shows the following:
2019-03-12 15:20:37.882 Status: dzVents: Info: Handling events for: "ESPeasyThermostat", value: "2.00"
2019-03-12 15:20:37.883 Status: dzVents: Info: MQTT setpoint: ------ Start internal script: Test: Device: "ESPeasyThermostat (ESP8266)", Index: 17
2019-03-12 15:20:37.884 Status: dzVents: Debug: MQTT setpoint: Processing device-adapter for ESPeasyTemperature: Temperature device adapter
2019-03-12 15:20:37.884 Status: dzVents: Debug: MQTT setpoint: Temperature: 0, setpoint: 2
2019-03-12 15:20:37.884 Status: dzVents: Debug: MQTT setpoint: No action needed; open already send to MQTT topic espeasy/setPoint
2019-03-12 15:20:37.884 Status: dzVents: Info: MQTT setpoint: ------ Finished Test
What am I missing?
Re: Regulating temperature
Posted: Tuesday 12 March 2019 17:08
by waaren
ulfh2018 wrote: āTuesday 12 March 2019 15:25
Hello Waaren
Well, was not as easy as I thought.
Have done the following:
1. Installed local MQTT - no password (testing only)
2. Created the two virtual sensors, using the same name as you have
3. Copied the code
4. Activated the event
When I try to change the valu in the Setpoint, this is not reflected to temperature.
Logfile shows the following:
2019-03-12 15:20:37.882 Status: dzVents: Info: Handling events for: "ESPeasyThermostat", value: "2.00"
2019-03-12 15:20:37.883 Status: dzVents: Info: MQTT setpoint: ------ Start internal script: Test: Device: "ESPeasyThermostat (ESP8266)", Index: 17
2019-03-12 15:20:37.884 Status: dzVents: Debug: MQTT setpoint: Processing device-adapter for ESPeasyTemperature: Temperature device adapter
2019-03-12 15:20:37.884 Status: dzVents: Debug: MQTT setpoint: Temperature: 0, setpoint: 2
2019-03-12 15:20:37.884 Status: dzVents: Debug: MQTT setpoint: No action needed; open already send to MQTT topic espeasy/setPoint
2019-03-12 15:20:37.884 Status: dzVents: Info: MQTT setpoint: ------ Finished Test
What am I missing?
the setPoint will send the command once and that should trigger the espEasy to open the radiator valve.
The temperature sensor connected to the espEasy should send the measured temperature to domoticz using the payload
Code: Select all
{ "idx" : idx of your virtual temperature sensor in domoticz, "nvalue" : 0, "svalue" : "temp in celsius" }
to topic domoticz/in
You will find more relevant info
here
Re: Regulating temperature
Posted: Saturday 16 March 2019 15:06
by kimot
@ulfh2018
The mentioned video is my solution for floor el. heating.
Domoticz device is Dummy Thermostat Setpoint, but I changed its icon in "/domoticz/www/images".
It not regulate temperature ( this is done by ESPeasy rules ), only defines setpoint and by script sends it to ESPeasy.
Its value is send to ESPeasy when changed and then every minute.
Complete ESPeasy rules end DzVents script example for sending Setpoint value are in discussion below video.
And this rules works only with _dev13 and v2.0 vesrsions of ESPeasy, not in "mega" versions.
And for ESPeasy with DS18B20.
I am running one outdoor temperature sensor with DS18B20 and powerbank 2500mAh.
Send temperature every 5 min and then deepsleep.
Working time for one battery charge is about 7 days. ( Nodemcu board )
Re: Regulating temperature
Posted: Saturday 16 March 2019 19:09
by ulfh2018
Then I get the picture. I'm running the Mega version! I'll try with another version.
Re: Regulating temperature
Posted: Saturday 16 March 2019 20:45
by kimot
"mega" versions have problem to work with my rules from V2.0 and _dev versions.
My actual working version is v2.0-20180322
I write about it on ESPeasy forum here:
https://www.letscontrolit.com/forum/vie ... f=4&t=6536
DzVents script which runs every minute to send values to my nodes:
Code: Select all
-- Check the wiki at
-- http://www.domoticz.com/wiki/%27dzVents%27:_next_generation_LUA_scripting
return {
-- 'active' controls if this entire script is considered or not
active = true, -- set to false to disable this script
-- trigger
-- can be a combination:
on = {
timer = {
-- timer triggers.. if one matches with the current time then the script is executed
'every minute',
}
},
-- actual event code
-- in case of a timer event or security event, device == nil
execute = function(domoticz)
--[[
The domoticz object holds all information about your Domoticz system. E.g.:
local myDevice = domoticz.devices('myDevice')
local myVariable = domoticz.variables('myUserVariable')
local myGroup = domoticz.groups('myGroup')
local myScene = domoticz.sceneds('myScene')
The device object is the device that was triggered due to the device in the 'on' section above.
]] --
-- example
-- HDO
local HDO_PV = domoticz.devices('HDO-PV')
-- Kacka
local urlHDO = 'http://192.168.1.102/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Filip
local urlHDO = 'http://192.168.1.105/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
--Kuchyne
local urlHDO = 'http://192.168.1.103/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
--Obyvak
local urlHDO = 'http://192.168.1.104/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Koupelna
local urlHDO = 'http://192.168.1.107/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- WC
local urlHDO = 'http://192.168.1.109/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Koupelna_WC
local urlHDO = 'http://192.168.1.108/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Loznice
local urlHDO = 'http://192.168.1.110/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Hala
local urlHDO = 'http://192.168.1.106/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Chodba
local urlHDO = 'http://192.168.1.111/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Technicka
local urlHDO = 'http://192.168.1.112/control?cmd=event,HDO='..(HDO_PV.nValue)..''
print(urlHDO)
domoticz.openURL(urlHDO)
--Outdoor
local outdoor = domoticz.devices('Outdoor')
-- Kacka
local urlHDO = 'http://192.168.1.102/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Filip
local urlHDO = 'http://192.168.1.105/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
--Kuchyne
local urlHDO = 'http://192.168.1.103/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Koupelna
local urlHDO = 'http://192.168.1.107/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- WC
local urlHDO = 'http://192.168.1.109/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Koupelna_WC
local urlHDO = 'http://192.168.1.108/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Loznice
local urlHDO = 'http://192.168.1.110/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Hala
local urlHDO = 'http://192.168.1.106/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Chodba
local urlHDO = 'http://192.168.1.111/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
-- Technicka
local urlHDO = 'http://192.168.1.112/control?cmd=event,Outdoor='..(outdoor.temperature)..''
print(urlHDO)
domoticz.openURL(urlHDO)
--Setpoint
-- Kacka
local setpoint = domoticz.devices('Kacka_Setpoint')
local url= 'http://192.168.1.102/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Filip
local setpoint = domoticz.devices('Filip_Setpoint')
local url= 'http://192.168.1.105/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Kuchyne
local setpoint = domoticz.devices('Kuchyne_Setpoint')
local url= 'http://192.168.1.103/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Obyvak nastaveni stejne jako pro kuchyn, nema vlastni ovladani
local setpoint = domoticz.devices('Kuchyne_Setpoint')
local url= 'http://192.168.1.104/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Koupelna
local setpoint = domoticz.devices('Koupelna_Setpoint')
local url= 'http://192.168.1.107/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- WC
local setpoint = domoticz.devices('WC_Setpoint')
local url= 'http://192.168.1.109/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Koupelna_WC
local setpoint = domoticz.devices('Koupelna_WC_Setpoint')
local url= 'http://192.168.1.108/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Loznice
local setpoint = domoticz.devices('Loznice_Setpoint')
local url= 'http://192.168.1.110/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Hala
local setpoint = domoticz.devices('Hala_Setpoint')
local url= 'http://192.168.1.106/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Chodba
local setpoint = domoticz.devices('Chodba_Setpoint')
local url= 'http://192.168.1.111/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- Technicka
local setpoint = domoticz.devices('Technicka_Setpoint')
local url= 'http://192.168.1.112/control?cmd=event,HeatSetpoint='..(setpoint.state)..''
print(url)
domoticz.openURL(url)
-- mode
-- Kacka
local mode = domoticz.devices('Kacka_Control')
local url2= 'http://192.168.1.102/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Filip
local mode = domoticz.devices('Filip_Control')
local url2= 'http://192.168.1.105/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Kuchyne
local mode = domoticz.devices('Kuchyne_Obyvak_Control')
local url2= 'http://192.168.1.103/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Obyvak nastaveni stejne jako pro kuchyn, nema vlastni ovladani
local mode = domoticz.devices('Kuchyne_Obyvak_Control')
local url2= 'http://192.168.1.104/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Koupelna
local mode = domoticz.devices('Koupelna_Control')
local url2= 'http://192.168.1.107/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- WC
local mode = domoticz.devices('WC_Control')
local url2= 'http://192.168.1.109/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Koupelna_WC
local mode = domoticz.devices('Koupelna_WC_Control')
local url2= 'http://192.168.1.108/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Loznice
local mode = domoticz.devices('Loznice_Control')
local url2= 'http://192.168.1.110/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Hala
local mode = domoticz.devices('Hala_Control')
local url2= 'http://192.168.1.106/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Chodba
local mode = domoticz.devices('Chodba_Control')
local url2= 'http://192.168.1.111/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- Technicka
local mode = domoticz.devices('Technicka_Control')
local url2= 'http://192.168.1.112/control?cmd=event,modeSet='..(mode.level)..''
print(url2)
domoticz.openURL(url2)
-- do something
end
}
Re: Regulating temperature
Posted: Saturday 16 March 2019 22:14
by ulfh2018
Thanks a lot my friend. Just flashed, and seems to work. I still have to do some changes, but Iām starting to build the rules one by one.
Re: Regulating temperature
Posted: Tuesday 07 May 2019 1:36
by HvdW
What about the ready to use thermostat plugin for Domoticz?
It installs within minutes.
[URL]
https://www.domoticz.com/wiki/Plugins/S ... ostat.html [URL]
Re: Regulating temperature
Posted: Tuesday 28 May 2019 21:38
by kimot
It is different philosophy.
ESPeasy works like stand alone thermostat, Domoticz only set parameters and receives data for statistics, energy consumption etc.
When Domoticz crashes or network connection to sensors is lost - they still regulate temperature to last set temperature.
What happens with this Domoticz plugin thermostat if Domoticz crashes in Heatswitch ON state.
I am worried, then heating stays in ON state forever.
With el. floor heating it can be fatal...