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.
Post Reply
JuanUil
Posts: 291
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi
Domoticz version: 2.xx
Location: Asten NB Nederland
Contact:

script for controlling Essent (ICY) Thermostat

Post by JuanUil » Sunday 08 November 2015 13:36

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!

User avatar
Siewert308SW
Posts: 607
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by Siewert308SW » Thursday 12 November 2015 20:45

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:
- RPi3 - PIco HV3.0A / Domo Beta 3.9XXX / RFXtrx433E / Aeotec Gen5
- RPi3 - PIco HV3.0A / PiHole / PiVPN / NAS / Print Server
- Youless Elec&Gas
- FI9803P Cams
- KD101 detectors
- Zwave & KaKu

MyDomoticz scripts: @GitHub
PIco UPS Toolkit: @GitHub

JuanUil
Posts: 291
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi
Domoticz version: 2.xx
Location: Asten NB Nederland
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by JuanUil » Friday 13 November 2015 9:51

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!

djgodlike
Posts: 30
Joined: Wednesday 27 January 2016 17:37
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by djgodlike » Wednesday 09 March 2016 1:31

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: 291
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi
Domoticz version: 2.xx
Location: Asten NB Nederland
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by JuanUil » Wednesday 06 April 2016 11:19

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!

sander
Posts: 12
Joined: Monday 22 December 2014 23:28
Target OS: Raspberry Pi
Domoticz version: latest..
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by sander » Wednesday 27 December 2017 4:17

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: 10
Joined: Friday 08 September 2017 8:27
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Dordrecht, The Netherlands
Contact:

Re: script for controlling Essent (ICY) Thermostat

Post by g00fy » Wednesday 03 January 2018 11:32

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>?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests