script for controlling Essent (ICY) Thermostat

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
JuanUil
Posts: 497
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

script for controlling Essent (ICY) Thermostat

Post by JuanUil »

Hi there,

I have made a script to controll my Essent Thermostat.
It controlls the temperature on time for weekdays and weekends.
But it also switches to nighttemperature after 1.5 hour as we are away.
and back to daytemperature when we come home between certain hours
The dummyswitch Thuis is controlled by pinging both mine and my wifes telephone.
You have to set your thermostat to vaste temperatuur, it then overrides the program of the thermostat itself.
Any comment is welcome!
Enjoy...

Code: Select all

-- ~/domoticz/scripts/lua/script_device_Thermostaat.lua
 -- deze functie berekend de verstreken tijd
function timedifference(s)
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
   difference = os.difftime (t1, t2)
   return difference
end

-- bepalen dag, tijd, setpoint en kamertemperatuur
dag = tostring(os.date("%a"));
uur = tonumber(os.date("%H"));
min = tonumber(os.date("%M"));
setpoint = tonumber(otherdevices_svalues['Room Setpoint'])
werkelijk= tonumber(otherdevices_svalues['Room Temperature'])
-- Temperatuur instellingen
dagtemperatuur   = uservariables["dagtemperatuur"]
nachttemperatuur = uservariables["nachttemperatuur"]
vorstbeveiliging = uservariables["vorstbeveiliging"]

commandArray = {}

-- Bepaling werkweek of weekend
if (dag=='Sun' or dag=='Mon' or dag=='Tue' or dag=='Wed' or dag=='Thu') then
	werkweek = true; weekend = false
elseif (dag=='Fri' or dag=='Sat') then
	werkweek = false ; weekend = true 
end

-- Als we thuis zijn temperatuur instellen volgens een schema
if (otherdevices['Thuis']=='On') then

-- Dagtemperatuur instellen voor werkdagen en weekend
	if (werkweek and dag ~= 'Sun'and uur==7 and min>=0 and min<2 and setpoint<dagtemperatuur) then
		setpoint=dagtemperatuur
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	elseif ((weekend or dag=='Sun')and uur==8 and min>=0 and min<2 and setpoint<dagtemperatuur) then
		setpoint=dagtemperatuur
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	end

-- Nachttemperatuur instellen voor werkdagen en weekend
	if (werkweek and uur==22 and min>=30 and min<32 and setpoint>nachttemperatuur) then
		setpoint=nachttemperatuur
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	elseif (weekend and uur==23 and min>=30 and min<32 and setpoint>nachttemperatuur) then
		setpoint=nachttemperatuur
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	end
	
end

-- Als we thuiskomen temp aanpassen
-- Thuis = dagtemperatuur

if (devicechanged['Thuis']=='On' and uur >8 and uur<24 and setpoint<dagtemperatuur) then
	setpoint=dagtemperatuur
	set = "6|0|" .. setpoint
	commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	commandArray ['Vaste temperatuur']= 'Off'
end

-- om 1 uur 's-nachts controleren of nachttempteratuur daadwerkelijk is ingeschakeld
if (uur==1 and setpoint~=nachttemperatuur) then
	setpoint=nachttemperatuur
	set = "6|0|" .. setpoint
	commandArray ['UpdateDevice']= '6|0|' .. setpoint  
end

-- Thermostaat naar nachttemperatuur als 1,5 uur niemand thuis is
-- tijdsduur voor schakelen van de thermostaat (tijd in seconden)
   timeon2 = 5400
if (otherdevices['Thuis']=='Off') then
		difference = timedifference(otherdevices_lastupdate['Thuis'])
		if (difference > timeon2 and difference < (timeon2 + 60) and setpoint~=nachttemperatuur) then
			setpoint=nachttemperatuur
			set = "6|0|" .. setpoint
			commandArray ['UpdateDevice']= '6|0|' .. setpoint  
			commandArray ['Vaste temperatuur']= 'On'
		end
end	

return commandArray


Grtz Jan
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
User avatar
Siewert308SW
Posts: 290
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by Siewert308SW »

JuanUil wrote:Hi there,

I have made a script to controll my Essent Thermostat.
It controlls the temperature on time for weekdays and weekends.
But it also switches to nighttemperature after 1.5 hour as we are away.
and back to daytemperature when we come home between certain hours
The dummyswitch Thuis is controlled by pinging both mine and my wifes telephone.
You have to set your thermostat to vaste temperatuur, it then overrides the program of the thermostat itself.
Any comment is welcome!
Enjoy...

Code: Select all

-- ~/domoticz/scripts/lua/script_device_Thermostaat.lua
 -- deze functie berekend de verstreken tijd
function timedifference(s)
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
   difference = os.difftime (t1, t2)
   return difference
end

-- bepalen dag, tijd, setpoint en kamertemperatuur
dag = tostring(os.date("%a"));
uur = tonumber(os.date("%H"));
min = tonumber(os.date("%M"));
setpoint = tonumber(otherdevices_svalues['Room Setpoint'])
werkelijk= tonumber(otherdevices_svalues['Room Temperature'])
-- Temperatuur instellingen
dagtemperatuur   = uservariables["dagtemperatuur"]
nachttemperatuur = uservariables["nachttemperatuur"]
vorstbeveiliging = uservariables["vorstbeveiliging"]

commandArray = {}

-- Bepaling werkweek of weekend
if (dag=='Sun' or dag=='Mon' or dag=='Tue' or dag=='Wed' or dag=='Thu') then
	werkweek = true; weekend = false
elseif (dag=='Fri' or dag=='Sat') then
	werkweek = false ; weekend = true 
end

-- Als we thuis zijn temperatuur instellen volgens een schema
if (otherdevices['Thuis']=='On') then

-- Dagtemperatuur instellen voor werkdagen en weekend
	if (werkweek and dag ~= 'Sun'and uur==7 and min>=0 and min<2 and setpoint<dagtemperatuur) then
		setpoint=dagtemperatuur
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	elseif ((weekend or dag=='Sun')and uur==8 and min>=0 and min<2 and setpoint<dagtemperatuur) then
		setpoint=dagtemperatuur
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	end

-- Nachttemperatuur instellen voor werkdagen en weekend
	if (werkweek and uur==22 and min>=30 and min<32 and setpoint>nachttemperatuur) then
		setpoint=nachttemperatuur
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	elseif (weekend and uur==23 and min>=30 and min<32 and setpoint>nachttemperatuur) then
		setpoint=nachttemperatuur
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	end
	
end

-- Als we thuiskomen temp aanpassen
-- Thuis = dagtemperatuur

if (devicechanged['Thuis']=='On' and uur >8 and uur<24 and setpoint<dagtemperatuur) then
	setpoint=dagtemperatuur
	set = "6|0|" .. setpoint
	commandArray ['UpdateDevice']= '6|0|' .. setpoint  
	commandArray ['Vaste temperatuur']= 'Off'
end

-- om 1 uur 's-nachts controleren of nachttempteratuur daadwerkelijk is ingeschakeld
if (uur==1 and setpoint~=nachttemperatuur) then
	setpoint=nachttemperatuur
	set = "6|0|" .. setpoint
	commandArray ['UpdateDevice']= '6|0|' .. setpoint  
end

-- Thermostaat naar nachttemperatuur als 1,5 uur niemand thuis is
-- tijdsduur voor schakelen van de thermostaat (tijd in seconden)
   timeon2 = 5400
if (otherdevices['Thuis']=='Off') then
		difference = timedifference(otherdevices_lastupdate['Thuis'])
		if (difference > timeon2 and difference < (timeon2 + 60) and setpoint~=nachttemperatuur) then
			setpoint=nachttemperatuur
			set = "6|0|" .. setpoint
			commandArray ['UpdateDevice']= '6|0|' .. setpoint  
			commandArray ['Vaste temperatuur']= 'On'
		end
end	

return commandArray


Grtz Jan
Script look great but are you sure it works?
I mean, the script when i use it isn't setting the new setpoint if needed.
Amended a little bit and now it does set a new setpoint when needed.

Just a little tip, some more information/details on what to change or create for users who don't have the knowledge would be handy.
Had to look how you wrote it and what i needed to create.

Compare my amended script to yours...

Code: Select all

    -- ~/domoticz/scripts/lua/script_device_Thermostaat.lua
     -- deze functie berekend de verstreken tijd
    function timedifference(s)
       year = string.sub(s, 1, 4)
       month = string.sub(s, 6, 7)
       day = string.sub(s, 9, 10)
       hour = string.sub(s, 12, 13)
       minutes = string.sub(s, 15, 16)
       seconds = string.sub(s, 18, 19)
       t1 = os.time()
       t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
       difference = os.difftime (t1, t2)
       return difference
    end

    -- bepalen dag, tijd, setpoint en kamertemperatuur
    dag = tostring(os.date("%a"));
    uur = tonumber(os.date("%H"));
    min = tonumber(os.date("%M"));
    setpoint = tonumber(otherdevices_svalues['Thermostaat Setpoint'])
    werkelijk = tonumber(otherdevices_svalues['Kamer Temperatuur'])
    -- Temperatuur instellingen
    dagtemperatuur   = uservariables["dagtemperatuur"]
    nachttemperatuur = uservariables["nachttemperatuur"]
    vorstbeveiliging = uservariables["vorstbeveiliging"]
	local idx = 95 --IDX is de idx van je E-Thermostaat device
    commandArray = {}

    -- Bepaling werkweek of weekend
    if (dag=='Sun' or dag=='Mon' or dag=='Tue' or dag=='Wed' or dag=='Thu') then
       werkweek = true; weekend = false
    elseif (dag=='Fri' or dag=='Sat') then
       werkweek = false ; weekend = true
    end

    -- Als we thuis zijn temperatuur instellen volgens een schema
    if (otherdevices['Iemand Thuis']=='On') then

    -- Dagtemperatuur instellen voor werkdagen en weekend
       if (werkweek and dag ~= 'Sun'and uur==7 and min>=0 and min<2 and setpoint<dagtemperatuur) then
          setpoint=dagtemperatuur
	commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(setpoint)
       elseif ((weekend or dag=='Sun')and uur==8 and min>=0 and min<2 and setpoint<dagtemperatuur) then
          setpoint=dagtemperatuur
	commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(setpoint)
       end

    -- Nachttemperatuur instellen voor werkdagen en weekend
       if (werkweek and uur==22 and min>=30 and min<32 and setpoint>nachttemperatuur) then
          setpoint=nachttemperatuur
	commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(setpoint)
       elseif (weekend and uur==23 and min>=30 and min<32 and setpoint>nachttemperatuur) then
          setpoint=nachttemperatuur
	commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(setpoint)
       end
       
    end

    -- Als we thuiskomen temp aanpassen
    -- Thuis = dagtemperatuur

    if (devicechanged['Iemand Thuis']=='On' and uur >8 and uur<24 and setpoint<dagtemperatuur) then
       setpoint=dagtemperatuur
	commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(setpoint)
       commandArray ['Thermostaat Dummy Switch']= 'Off'
    end

    -- om 1 uur 's-nachts controleren of nachttempteratuur daadwerkelijk is ingeschakeld
    if (uur==1 and setpoint~=nachttemperatuur) then
       setpoint=nachttemperatuur
	commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(setpoint)
    end

    -- Thermostaat naar nachttemperatuur als 1,5 uur niemand thuis is
    -- tijdsduur voor schakelen van de thermostaat (tijd in seconden)
       timeon2 = 5400
    if (otherdevices['Iemand Thuis']=='Off') then
          difference = timedifference(otherdevices_lastupdate['Iemand Thuis'])
          if (difference > timeon2 and difference < (timeon2 + 60) and setpoint~=nachttemperatuur) then
             setpoint=nachttemperatuur
	commandArray['UpdateDevice'] = idx .. '|0|' .. tostring(setpoint)
             commandArray ['Thermostaat Dummy Switch']= 'On'
          end
    end   

    return commandArray



Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
JuanUil
Posts: 497
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by JuanUil »

Yes script is working fine with me at home.
But I admid I could have and should have pointed out where users have to put their own data in.
Thnx for adjusting the script.

Jan
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
djgodlike
Posts: 32
Joined: Wednesday 27 January 2016 16:37
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by djgodlike »

Sorry for my ignorance but i made a dummy 'Vaste Temperatuur' and have a correct working dummy 'IemandThuis'.
Is the dummy 'Vaste Temperatuur' or 'Thermostaat Dummy Switch' needed for the script to work? I dont see an IDX of this dummy in the script.. ?

Can someone explain the exact dummy's connected to this script, and how they are called?

Ive marked my uncertainties.. Sorry i'm new to lua..

Code: Select all

   
       setpoint = tonumber(otherdevices_svalues['E-thermostaat'])
    werkelijk = tonumber(otherdevices_svalues['Kamer Temperatuur'])
   
       commandArray ['Vaste Temperatuur']= 'Off'                                   No IDX?
 
       commandArray ['Vaste Temperatuur']= 'On'
 
Update: The script seems to work fine to 20C and when away to 15C! What does the dummy 'Vaste Temperatuur' or 'Thermostaat Dummy Switch' do?

An error occurs: 2016-03-09 11:02:00.453 Error: EventSystem: in script_device_Thermostaat.lua: [string " -- ~/domoticz/scripts/lua/script_device_Ther..."]:62: attempt to index global 'devicechanged' (a nil value)
Aeon Labs Gen5 USB
Greenwave Powernode 6 NS310
2x Greenwave Powernode 1 NS310
Philips Hue
Logitech media Server
Plugwise Smile P1
JuanUil
Posts: 497
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by JuanUil »

Hi There,

the dummy switch vaste temp is ment to prevent the thermostat to go to nighttemp when he sees no movement for 2 hours
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
sander
Posts: 8
Joined: Monday 22 December 2014 22:28
Target OS: Raspberry Pi / ODroid
Domoticz version: latest..
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by sander »

Hello, anyone, is there a Json command to set ''vaste temperatuur'' on a icy thermostat? I am not handy with Lua yet and would just like to enforce this setting in some cases.
Thanks in advance.
Raspberry Pi 2B+
connected: klik aan klik uit switches, dimmers, weather station, water meter (pulse)
Automation use: Blocky
g00fy
Posts: 16
Joined: Friday 08 September 2017 8:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Dordrecht, The Netherlands
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by g00fy »

I think everything you need is in here: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s.

Something like json.htm?type=command&param=udevice&idx=<idx>&nvalue=0&svalue=<temperatuur>?
eevolute
Posts: 3
Joined: Sunday 26 November 2017 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by eevolute »

Hello,

I have implemented this script and it seems to work, however i'm wondering something: The value 'setpoint' that is read from and written to the thermostat idx. This idx in my case is the hardware device type 'icy thermostat' i created in hardware setiings and this polls from the icy-e online server using login/password. However, ICY has announced that this service will stop (or continue as a paid service) on 1-2-2019. Am I missing something here or will this mean the script will stop functioning then as the value cannot be polled anymore?
eevolute
Posts: 3
Joined: Sunday 26 November 2017 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by eevolute »

Hello,

I have implemented this script with some schedule changes, and it seems to work, but i'm wondering something: the value 'setpoint' that is read from and written to the thermostat idx. This idx in my case is the hardware device of type 'icy thermostat' i created in hardware setiings, and this polls from the icy-e online server using login/password. However, ICY has announced that this service will stop (or continue as a paid service) on 1-2-2019. Am I missing something here or will this mean the script will stop functioning then as the value cannot be polled anymore?
User avatar
jvdz
Posts: 2267
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by jvdz »

New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
eevolute
Posts: 3
Joined: Sunday 26 November 2017 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by eevolute »

Ah, thank you Jos. That is unfortunate, as you pointed out there is no known way of connecting to the thermostat locally at this point. Maybe we should ask ICY..
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest