Heating valve control childs

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Heating valve control childs

Post by EdddieN »

Hello,

I have 2 x TRVs in a room and a thermostat. I like to control both of the TRVs radiator valves from the thermostat. For example, if I set the wall thermostat to 20*C, then the value to be passed to the TRVs as well.

This is my first attempt to dzVents so still getting used to it:

Code: Select all

return {
    on = {
        devices = { 'Study Thermostat'}
    },
    execute = function(domoticz, updateSetPoint)
        domoticz.devices('ZTRV Study').updateSetPoint = domoticz.devices('Study Thermostat').setPoint
        domoticz.devices('ZTRV Study2').updateSetPoint = domoticz.devices('Study Thermostat').setPoint
        -- setPoint
    end
}
I know the code probably is a bit too simplistic... any ideas how to achieve this?
11101101 - www.machinon.com
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Heating valve control childs

Post by waaren »

Can you please give me the output of

domoticz.devices('ZTRV Study').dump()
domoticz.devices('Study Thermostat').dump()

That will make it easier for me to be of any help to you
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

Thanks!

Code: Select all

2018-03-30 15:46:29.370 dzVents: > sec: 16
2018-03-30 15:46:29.370 dzVents: > utils:
2018-03-30 15:46:29.370 dzVents: > LOG_MODULE_EXEC_INFO: 2
2018-03-30 15:46:29.370 dzVents: > log()
2018-03-30 15:46:29.370 dzVents: > LOG_FORCE: 0.5
2018-03-30 15:46:29.370 dzVents: > LOG_ERROR: 1
2018-03-30 15:46:29.370 dzVents: > print()
2018-03-30 15:46:29.370 dzVents: > fileExists()
2018-03-30 15:46:29.371 dzVents: > LOG_DEBUG: 4
2018-03-30 15:46:29.371 dzVents: > LOG_INFO: 3
2018-03-30 15:46:29.371 dzVents: > osExecute()
2018-03-30 15:46:29.371 dzVents: > urlEncode()
2018-03-30 15:46:29.371 dzVents: > ruleIsAfterSunrise()
2018-03-30 15:46:29.371 dzVents: > ruleIsBeforeSunset()
2018-03-30 15:46:29.371 dzVents: > matchesRule()
2018-03-30 15:46:29.371 dzVents: > ruleMatchesTimeRange()
2018-03-30 15:46:29.371 dzVents: > ruleIsAtSunrise()
2018-03-30 15:46:29.371 dzVents: > ruleIsBeforeSunrise()
2018-03-30 15:46:29.371 dzVents: > ruleMatchesHourSpecification()
2018-03-30 15:46:29.371 dzVents: > ruleMatchesMinuteSpecification()
2018-03-30 15:46:29.371 dzVents: > ruleIsAfterSunset()
2018-03-30 15:46:29.371 dzVents: > ruleIsAtNight()
2018-03-30 15:46:29.371 dzVents: > secondsSinceMidnight: 50836
2018-03-30 15:46:29.371 dzVents: > rawDate: 2018-3-30
2018-03-30 15:46:29.371 dzVents: > min: 7
2018-03-30 15:46:29.371 dzVents: > isdst: true
2018-03-30 15:46:29.371 dzVents: > ruleMatchesTime()
2018-03-30 15:46:29.371 dzVents: > hour: 14
2018-03-30 15:46:29.372 dzVents: > updatePercentage()
2018-03-30 15:46:29.372 dzVents: > updateWeight()
2018-03-30 15:46:29.372 dzVents: > updateCustomSensor()
2018-03-30 15:46:29.372 dzVents: > hardwareID: 1906388464
2018-03-30 15:46:29.372 dzVents: > close()
2018-03-30 15:46:29.372 dzVents: > open()
2018-03-30 15:46:29.372 dzVents: > updateCounter()
2018-03-30 15:46:29.372 dzVents: > armHome()
2018-03-30 15:46:29.372 dzVents: > SetPoint: 12.00
2018-03-30 15:46:29.372 dzVents: > updateBarometer()
2018-03-30 15:46:29.372 dzVents: > deviceSubType: SetPoint
2018-03-30 15:46:29.372 dzVents: > rawData:
2018-03-30 15:46:29.372 dzVents: > 1: 12.00
2018-03-30 15:46:29.372 dzVents: > kodiSwitchOff()
2018-03-30 15:46:29.372 dzVents: > kodiExecuteAddOn()
2018-03-30 15:46:29.372 dzVents: > armAway()
2018-03-30 15:46:29.372 dzVents: > switchOff()
2018-03-30 15:46:29.372 dzVents: > updateElectricity()
2018-03-30 15:46:29.372 dzVents: > updateAirQuality()
2018-03-30 15:46:29.372 dzVents: > changed: true
2018-03-30 15:46:29.372 dzVents: > kodiPlay()
2018-03-30 15:46:29.373 dzVents: > kodiPlayPlaylist()
2018-03-30 15:46:29.373 dzVents: > kodiPlayFavorites()
2018-03-30 15:46:29.373 dzVents: > kodiStop()
2018-03-30 15:46:29.373 dzVents: > updateMode()
2018-03-30 15:46:29.373 dzVents: > updateWetness()
2018-03-30 15:46:29.373 dzVents: > description:
2018-03-30 15:46:29.373 dzVents: > updateWind()
2018-03-30 15:46:29.373 dzVents: > updateTempHum()
2018-03-30 15:46:29.373 dzVents: > updateVisibility()
2018-03-30 15:46:29.373 dzVents: > updateSoilMoisture()
2018-03-30 15:46:29.373 dzVents: > updateUV()
2018-03-30 15:46:29.373 dzVents: > updateText()
2018-03-30 15:46:29.373 dzVents: > updateTempHumBaro()
2018-03-30 15:46:29.373 dzVents: > hardwareTypeValue: 21
2018-03-30 15:46:29.373 dzVents: > updateWaterflow()
2018-03-30 15:46:29.373 dzVents: > bState: false
2018-03-30 15:46:29.373 dzVents: > _state: 12.00
2018-03-30 15:46:29.373 dzVents: > switchTypeValue: 0
2018-03-30 15:46:29.373 dzVents: > dimTo()
2018-03-30 15:46:29.373 dzVents: > updateLux()
2018-03-30 15:46:29.373 dzVents: > stop()
2018-03-30 15:46:29.374 dzVents: > hardwareName: RazzBerry card
2018-03-30 15:46:29.374 dzVents: > updateGas()
2018-03-30 15:46:29.374 dzVents: > switchType: On/Off
2018-03-30 15:46:29.374 dzVents: > updateAlertSensor()
2018-03-30 15:46:29.374 dzVents: > dump()
2018-03-30 15:46:29.374 dzVents: > nValue: 0
2018-03-30 15:46:29.374 dzVents: > deviceType: Thermostat
2018-03-30 15:46:29.374 dzVents: > id: 681
2018-03-30 15:46:29.374 dzVents: > state: 12.00
2018-03-30 15:46:29.374 dzVents: > _adapters:
2018-03-30 15:46:29.374 dzVents: > 1: Thermostat setpoint device adapter
2018-03-30 15:46:29.374 dzVents: > updateHumidity()
2018-03-30 15:46:29.374 dzVents: > name: Study Thermostat
2018-03-30 15:46:29.374 dzVents: > updateRain()
2018-03-30 15:46:29.374 dzVents: > switchOn()
2018-03-30 15:46:29.374 dzVents: > hardwareType: OpenZWave USB
2018-03-30 15:46:29.374 dzVents: > icon: override_mini
2018-03-30 15:46:29.374 dzVents: > updateP1()
2018-03-30 15:46:29.374 dzVents: > unit: 1
2018-03-30 15:46:29.374 dzVents: > hardwareId: 1906388464
2018-03-30 15:46:29.374 dzVents: > timedOut: false
2018-03-30 15:46:29.375 dzVents: Info: ------ Finished StudyThermo
11101101 - www.machinon.com
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Heating valve control childs

Post by waaren »

I think that is only part of the output of the dump() commands.
You could try

Code: Select all

return {
    on = {
        devices = { 'Study Thermostat'}
    },
    execute = function(domoticz, Thermostat)
        domoticz.devices('ZTRV Study').updateSetPoint(Thermostat.setPoint)
        domoticz.devices('ZTRV Study2').updateSetPoint(Thermostat.setPoint)
        -- setPoint
    end
} 
or if you get a faillure

Code: Select all

return {
    on = {
        devices = { 'Study Thermostat'}
    },
    execute = function(domoticz, Thermostat)
        domoticz.devices('ZTRV Study').updateSetPoint(Thermostat.setPoint,"TemporaryOverride",'2018-04-05T22:00:00-01:00')
        domoticz.devices('ZTRV Study2').updateSetPoint(Thermostat.setPoint,"TemporaryOverride",'2018-04-05T22:00:00-01:00')
        -- setPoint with 
    end
} 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

Brilliant! This did the trick!

Code: Select all

return {
    on = {
        devices = { 'Study Thermostat'}
    },
    execute = function(domoticz, Thermostat)
        domoticz.devices('ZTRV Study').updateSetPoint(Thermostat.setPoint)
        domoticz.devices('ZTRV Study2').updateSetPoint(Thermostat.setPoint)
        -- setPoint
    end
} 
11101101 - www.machinon.com
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Heating valve control childs

Post by waaren »

Thx, but the brilliance is from Danny. I'm just following the wiki. :D
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

So I understand:

Whenever devices "Study Thermostat" changes, the execute happens.
Now, the function Thermostat, how is it link Study Thermostat to the Thermostat? Is it just passing all its values to "Thermostat" and then copied to the TRVs?

I'm trying to get my head around how the basics of dzVents work

- I did try following the Wiki too, but the above escaped to me :)
11101101 - www.machinon.com
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Heating valve control childs

Post by waaren »

"Whenever devices "Study Thermostat" changes, the execute happens." yes

Thermostat is not a function. It is the item passed by the "on =" section to the execute function. In this case the "Study Thermostat" device with all of it's attributes (data) You can see this if you do a dump() of it:

Code: Select all

Thermostat.dump()
So Thermostat.setPoint is the current value of the setpoint of your 'Study Thermostat'.
This value is passed to the method updateSetPoint of 'ZTRV Study'

hope this clarifies it for you.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

It does! thank you, time to play :D
11101101 - www.machinon.com
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Heating valve control childs

Post by dannybloe »

:)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

Hi again,

I'm trying to do the same for an Evohome zone.

Code: Select all

return {
    on = {
        devices = { 'Downstairs Thermostat'}
    },
    execute = function(domoticz, Thermostat)
        domoticz.devices('Downstairs').updateSetPoint(Thermostat.setPoint)
       -- the above is an Evohome zone
    end
} 
According to https://www.domoticz.com/wiki/DzVents:_ ... ng#Evohome it should work? The only thing I notice is that in Domoticz, Evohome zones are not seen as thermostats but as Temperature so probably this is why the above is not working?

Also
You can provide an until date (in ISO 8601 format e.g.: os.date("!%Y-%m-%dT%TZ"))
Does it mean we always have to give it a time in the future? Cannot we just say for 2 hours?

By the way, I just started playing yesterday with dzVents and this is fantastic! so much easy :D
11101101 - www.machinon.com
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Heating valve control childs

Post by waaren »

You have to do the calculation in dzVents.

maybe the post http://www.domoticz.com/forum/viewtopic ... me#p173601 will get you a bit further.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

Ok, This is what I get
return {
on = { devices = {'TriggerDevice' } },

execute = function(domoticz,_)
local myZone = domoticz.devices('Slaapkamer')
myZone.updateSetPoint(TriggerDevice)
end
}
And I get

Code: Select all

2018-03-31 10:53:46.024 dzVents: Info: ------ Start internal script: DownstairsThermo: Device: "Downstairs Thermostat (Virtual switches)", Index: 689
2018-03-31 10:53:46.026 Error: dzVents: Error: An error occured when calling event handler DownstairsThermo
2018-03-31 10:53:46.026 Error: dzVents: Error: ...ripts/dzVents/runtime/device-adapters/evohome_device.lua:22: attempt to concatenate local 'setPoint' (a nil value)
2018-03-31 10:53:46.026 dzVents: Info: ------ Finished DownstairsThermo
11101101 - www.machinon.com
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

I should have added that what I’m trying to do is try have a virtual thermostat that overrides Evohome zone. This is because on other apps like ImperiHome I cannot change the zone setpoint as Domoticz does not present it as such.

Makes sense?


Sent from my iPhone using Tapatalk
11101101 - www.machinon.com
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Heating valve control childs

Post by waaren »

This works for me.

Can you try this and report back ?

Code: Select all

--[[ 
	Evotest (dzVents 2.4.1)
 ]]--
 
return {
	on = { devices = { 'Evohome device name  that wil act as setpoint device'} },    -- EvoHome trigger
	
	execute = function(domoticz, Thermostat)
		local myZone = domoticz.devices('Evohome zone name that will follow the setpoint of Evohome trigger')   -- EvoHome Slave
		local untilDateTime = os.date("!%Y-%m-%dT%TZ",os.time()+7200)  -- current time + 2 hours
		myZone.updateSetPoint(Thermostat.setPoint,"TemporaryOverride",untilDateTime)
		print ("Setpoint of Evohome zone " .. myZone.name .. " set to: " .. Thermostat.setPoint .. " degrees, until Date Time: " .. untilDateTime)
	end
} 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

WoW! I was not expecting the whole thing done!

Code: Select all

2018-03-31 12:18:15.264 dzVents: Setpoint of Evohome zone Downstairs set to: 16.5 degrees, until Date Time: 2018-03-31T13:18:15Z
It works.

This is the part that got my attention:

Code: Select all

myZone.updateSetPoint(Thermostat.setPoint,"TemporaryOverride",untilDateTime)
The linking between zones and updateSetPoint, etc.. everyday is a school day :D
11101101 - www.machinon.com
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

Right, I'm now playing a bit more with dzVents.
I have a wall tablet that I use to change the temperature, but sometimes I also use the Evohome display, or other times the Evohome goes back to normal after the temporary 2h override. My intention is to update also the target temperature on the wall tablet.

So far I have managed to get it like this:

Code: Select all

--[[ 
Cocina override, this uses the wall tablet to override the Evohome
 ]]--
 
return {
	on = { devices = { 'Downstairs Thermostat'} },    -- EvoHome trigger
	
	execute = function(domoticz, Thermostat)
	   local DownTRV = domoticz.devices('Downstairs Thermostat')
	   local DownTRV = DownTRV.setPoint
	   local DownEV = domoticz.devices('Downstairs')
	   local DownEV = DownEV.setPoint
	   print ("THIS IS THE SETPOING NOW = " .. DownTRV)  
	   print ("THIS IS THE SETPOING NOW = " .. DownEV)  
	   if DownEV ~= DownTRV then    -- only apply if setPoints are different

		local myZone = domoticz.devices('Downstairs')   -- EvoHome Slave
		local untilDateTime = os.date("!%Y-%m-%dT%TZ",os.time()+7200)  -- current time + 2 hours
		myZone.updateSetPoint(Thermostat.setPoint,"TemporaryOverride",untilDateTime)
		print ("Setpoint of Evohome zone " .. myZone.name .. " set to: " .. Thermostat.setPoint .. " degrees, until Date Time: " .. untilDateTime)
		end
	end
} 
and then I have another script that looks for changes of the Evohome as above:

Code: Select all


--[[ 
Wall tablet update from Evohome
 ]]--
 
return {
	on = { devices = { 'Downstairs'} },    -- EvoHome trigger
		
	execute = function(domoticz, Thermostat)
	   local DownTRV = domoticz.devices('Downstairs Thermostat')
	   local DownTRV = DownTRV.setPoint
	   local DownEV = domoticz.devices('Downstairs')
	   local DownEV = DownEV.setPoint
	   print ("THIS IS THE SETPOING NOW = " .. DownTRV)  
	   print ("THIS IS THE SETPOING NOW = " .. DownEV)  
	   if DownEV ~= DownTRV then
	       print ("TRV DISPLAY UPDATED")
         domoticz.devices('Downstairs Thermostat').updateSetPoint(Thermostat.setPoint)
        end
	end
} 
This works but it seems to be triggered 3-4 times every time really fast:
2018-03-31 21:35:29.629 dzVents: Info: Handling events for: "Downstairs", value: "19.10;16.00;TemporaryOverride;2018-03-31T22:31:00"
2018-03-31 21:35:29.629 dzVents: Info: ------ Start internal script: DownstairsThermoUpdate: Device: "Downstairs (Evohome)", Index: 630
2018-03-31 21:35:29.631 dzVents: THIS IS THE SETPOING NOW = 16
2018-03-31 21:35:29.631 dzVents: THIS IS THE SETPOING NOW = 16
2018-03-31 21:35:29.631 dzVents: Info: ------ Finished DownstairsThermoUpdate
2018-03-31 21:35:29.658 (Evohome) Heating (Downstairs)
2018-03-31 21:35:29.835 (Evohome) Heating (Upstairs)
2018-03-31 21:35:29.986 dzVents: Info: Handling events for: "Downstairs", value: "19.10;16.00;TemporaryOverride;2018-03-31T22:31:00"
2018-03-31 21:35:29.987 dzVents: Info: ------ Start internal script: DownstairsThermoUpdate: Device: "Downstairs (Evohome)", Index: 630
2018-03-31 21:35:29.988 dzVents: THIS IS THE SETPOING NOW = 16
2018-03-31 21:35:29.988 dzVents: THIS IS THE SETPOING NOW = 16
2018-03-31 21:35:29.988 dzVents: Info: ------ Finished DownstairsThermoUpdate
2018-03-31 21:35:30.012 (Evohome) Heating (Downstairs)
2018-03-31 21:35:30.187 (Evohome) Heating (Upstairs)
2018-03-31 21:35:30.339 dzVents: Info: Handling events for: "Downstairs", value: "19.10;16.00;TemporaryOverride;2018-03-31T22:31:00"
2018-03-31 21:35:30.339 dzVents: Info: ------ Start internal script: DownstairsThermoUpdate: Device: "Downstairs (Evohome)", Index: 630
2018-03-31 21:35:30.340 dzVents: THIS IS THE SETPOING NOW = 16
2018-03-31 21:35:30.340 dzVents: THIS IS THE SETPOING NOW = 16
2018-03-31 21:35:30.340 dzVents: Info: ------ Finished DownstairsThermoUpdate
If fact, it seems to trigger every 3 minutes
11101101 - www.machinon.com
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Heating valve control childs

Post by waaren »

The scripts are now triggered by any update of the devices in the on = section
if you don't want that, you can change the on section so that the script will be triggered by a timer event
change

Code: Select all

on = { devices = { 'Downstairs Thermostat'} },    -- EvoHome trigger 
to

Code: Select all

on = {  timer = { 'every minute' }  },  -- Time based trigger
or something like

Code: Select all

on = {  timer = { 'every 5 minutes at daytime' }  },
See the wiki for all timer trigger rules
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Heating valve control childs

Post by EdddieN »

Thanks!

After a bit of playing I think I got it the way I wanted. I do not want the event to trigger every minute or so, only when something changes.

I have created a user variable "recordTemp" to keep track of the last temperature change done. The challenge is that I have two interfaces to change the temperature of the zone: via the TRV on a wall tablet and via the Evohome display console. What I wanted to for them to keep in sync and display the same information. This is what I have done (in case someone finds it useful):

1.- Create a user variable "recordTemp" float number as we will need decimal points.
2.- Create two dzVents scripts, one to handle the changes via the TRV interface and one to handle the changes via the Evohome display.

Code for the TRV handler:

Code: Select all

--[[ 
TRV handler
 ]]--
 
return {
	on = { devices = { 'Downstairs Thermostat'} },    -- EvoHome trigger
	
	execute = function(domoticz, Thermostat)

	   local DownTRV = Thermostat.setPoint
	   local oldTemp = domoticz.variables('recordTempDown').value

	   if DownTRV ~= oldTemp and domoticz.variables('updateBusy').value == 0 then
	       domoticz.variables('updateBusy').set(1) -- I'm busy

		local myZone = domoticz.devices('Downstairs')   -- EvoHome Slave
		local untilDateTime = os.date("!%Y-%m-%dT%TZ",os.time()+7200)  -- current time + 2 hours
		
		myZone.updateSetPoint(DownTRV,"TemporaryOverride",untilDateTime)
		domoticz.variables('recordTempDown').set(DownTRV)
		print ("************ SETPOINT Evohome zone " .. myZone.name .. " to: " .. DownTRV .. " , until: " .. untilDateTime .. " *******")
        domoticz.variables('updateBusy').set(0) -- Not busy anymore
	    end
	end
} 
and code for the Evohome display hadler:

Code: Select all


--[[ 
Evohome handler
 ]]--
return {
	on = { devices = { 'Downstairs'} },    -- EvoHome trigger
		
	execute = function(domoticz, Thermostat)
	   local DownEV = Thermostat.setPoint
	   local oldTemp1 = domoticz.variables('recordTempDown').value
	   
	   if DownEV ~= oldTemp1 and domoticz.variables('updateBusy').value == 0 then
	       domoticz.variables('updateBusy').set(1) -- I'm busy

         domoticz.devices('Downstairs Thermostat').updateSetPoint(DownEV)
         domoticz.variables('recordTempDown').set(DownEV)  
         print ("***************** TRV Down UPDATED!! to: " ..DownEV.." ********************")

         domoticz.variables('updateBusy').set(0) -- Not busy anymmore
        end
	end
} 
This way, it stops the scripts chasing each other. I also had to create a integer variable "updateBusy" as I noticed that both scripts were launched almost at the same time; and it created some conflicts while one was working on it by having the other doing changes at the same time.
So far so good!

The only thing I notice is that from time to time without any kind of action I get this (maybe once, twice or even three times in a row):
2018-04-01 18:00:57.983 dzVents: Info: Handling events for: "Downstairs", value: "15.50;16.50;TemporaryOverride;2018-04-01T18:56:00"
2018-04-01 18:00:57.983 dzVents: Info: ------ Start internal script: DownstairsThermoUpdate: Device: "Downstairs (Evohome)", Index: 630
2018-04-01 18:00:57.984 dzVents: Info: ------ Finished DownstairsThermoUpdate
2018-04-01 18:00:57.984 dzVents: Info: ------ Start internal script: VirtulaHallTemp: Device: "Downstairs (Evohome)", Index: 630
2018-04-01 18:00:57.986 dzVents: Info: ------ Finished VirtulaHallTemp
2018-04-01 18:00:57.994 EventSystem: Script event triggered: /home/pi/domosense/scripts/dzVents/runtime/dzVents.lua
I think it probably has to do with messages arriving from the Evohome as I have it connected via USB which trigger the check. I need to check the wiki if there's a way to run the script only on changes rather than anything happening. -- Pretty powerful dzVents!
11101101 - www.machinon.com
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest