Page 1 of 1
Another noob question (toonInfo)
Posted: Saturday 28 September 2019 23:37
by OedzesG
Hallo everyone..
working a view weeks now with dzvents and thanks to you guys its going very well..
Now its time to going next level..
Today i recieved my new rooted Toon thermostat.
Every thing is working wel..
so now i can use:
http://192.168.1.61/happ_thermstat?acti ... mostatInfo
this gives my the following info
Code: Select all
result: "ok",
currentTemp: "2112",
currentSetpoint: "2100",
currentInternalBoilerSetpoint: "25",
programState: "0",
activeState: "-1",
nextProgram: "-1",
nextState: "-1",
nextTime: "0",
nextSetpoint: "0",
randomConfigId: "1804289383",
errorFound: "255",
connection: "0",
burnerInfo: "0",
otCommError: "0",
currentModulationLevel: "5"
Now i want for example bring the currentModulationLevel, to a custom sensor.
i tried everything but for me nothing then error's.
I hope one of you guys can please help me with an litle example.
thnx in advance!
Re: Another noob question (toonInfo)
Posted: Sunday 29 September 2019 20:28
by emme
did they came between { and } ?
because you have posted a json object, but the parethesis are missing....
you can work it out with a dzvents HTTP resquest and reply... but before continuing I would like to be sure about what you get in reply
Re: Another noob question (toonInfo)
Posted: Sunday 29 September 2019 21:36
by waaren
Can you execute this one first and share the output?
Code: Select all
local scriptVersion = '0.201909291100'
local scriptVar = 'ToonInfo_' .. scriptVersion
--[[
this dzVents script is used to collect data from Rooted Toon
It uses a openURL call and interprets the returned JSON.
Before activating the script:
please read the GETTING STARTED section of the dzVents wiki.
change xxx.xxx.xxx.xxx in this script to the IP of your Toon
define a dummy hardware in domoticz if not already done
define virtual sensors this dummy hardware
and change the name in the device declarations
]]--
return
{
on =
{
timer = { 'every 1 minutes' },
httpResponses = { scriptVar },
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
local toonIP = '192.168.1.125'
local function getToonInfo()
local url = 'http://' .. toonIP .. '/happ_thermstat?action=getThermostatInfo'
dz.openURL({ url = url, callback = scriptVar })
end
-- main
if item.isTimer or item.isDevice then
getToonInfo()
elseif item.ok then -- statusCode == 2xx
dz.log(item.data,dz.LOG_DEBUG)
else
dz.log('Could not get (good) data from ' .. toonIP .. '\n' .. item.data ,dz.LOG_ERROR)
end
dz.utils.dumpTable(item)
end
}
Re: Another noob question (toonInfo)
Posted: Sunday 29 September 2019 22:58
by OedzesG
Code: Select all
2019-09-29 22:56:00.284 Status: dzVents: Info: ToonInfo_0.201909291100: ------ Start internal script: Script #2:, trigger: every 1 minutes
2019-09-29 22:56:00.284 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: url = http://192.168.1.61/happ_thermstat?action=getThermostatInfo
2019-09-29 22:56:00.284 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: method = GET
2019-09-29 22:56:00.284 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: post data = nil
2019-09-29 22:56:00.284 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: headers = nil
2019-09-29 22:56:00.284 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: callback = ToonInfo_0.201909291100
2019-09-29 22:56:00.284 Status: dzVents: > isGroup: false
2019-09-29 22:56:00.284 Status: dzVents: > isVariable: false
2019-09-29 22:56:00.284 Status: dzVents: > isHTTPResponse: false
2019-09-29 22:56:00.284 Status: dzVents: > isScene: false
2019-09-29 22:56:00.284 Status: dzVents: > isSecurity: false
2019-09-29 22:56:00.284 Status: dzVents: > trigger: every 1 minutes
2019-09-29 22:56:00.284 Status: dzVents: > isTimer: true
2019-09-29 22:56:00.285 Status: dzVents: > baseType: timer
2019-09-29 22:56:00.285 Status: dzVents: > isDevice: false
2019-09-29 22:56:00.285 Status: dzVents: Info: ToonInfo_0.201909291100: ------ Finished Script #2
2019-09-29 22:56:00.285 Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
2019-09-29 22:56:00.497 Status: dzVents: Info: Handling httpResponse-events for: "ToonInfo_0.201909291100
2019-09-29 22:56:00.497 Status: dzVents: Info: ToonInfo_0.201909291100: ------ Start internal script: Script #2: HTTPResponse: "ToonInfo_0.201909291100"
2019-09-29 22:56:00.497 Status: dzVents: Debug: ToonInfo_0.201909291100: {"result":"ok", "currentTemp":"2064", "currentSetpoint":"1500", "currentInternalBoilerSetpoint":"6", "programState":"2", "activeState":"3", "nextProgram":"1", "nextState":"2", "nextTime":"1569790800","nextSetpoint":"1600","randomConfigId":"1804289383","errorFound":"255","connection":"0","burnerInfo":"0","otCommError":"0","currentModulationLevel":"0"}
2019-09-29 22:56:00.497 Status: dzVents: > isGroup: false
2019-09-29 22:56:00.497 Status: dzVents: > ok: true
2019-09-29 22:56:00.497 Status: dzVents: > isVariable: false
2019-09-29 22:56:00.497 Status: dzVents: > callback: ToonInfo_0.201909291100
2019-09-29 22:56:00.497 Status: dzVents: > isHTTPResponse: true
2019-09-29 22:56:00.497 Status: dzVents: > isScene: false
2019-09-29 22:56:00.497 Status: dzVents: > _contentType: text/javascript; charset=utf-8
2019-09-29 22:56:00.497 Status: dzVents: > trigger: ToonInfo_0.201909291100
2019-09-29 22:56:00.497 Status: dzVents: > data: {"result":"ok", "currentTemp":"2064", "currentSetpoint":"1500", "currentInternalBoilerSetpoint":"6", "programState":"2", "activeState":"3", "nextProgram":"1", "nextState":"2", "nextTime":"1569790800","nextSetpoint":"1600","randomConfigId":"1804289383","errorFound":"255","connection":"0","burnerInfo":"0","otCommError":"0","currentModulationLevel":"0"}
2019-09-29 22:56:00.497 Status: dzVents: > statusCode: 200
2019-09-29 22:56:00.497 Status: dzVents: > isSecurity: false
2019-09-29 22:56:00.497 Status: dzVents: > isDevice: false
2019-09-29 22:56:00.497 Status: dzVents: > isJSON: false
2019-09-29 22:56:00.498 Status: dzVents: > protocol: HTTP/1.1
2019-09-29 22:56:00.498 Status: dzVents: > statusText: OK
2019-09-29 22:56:00.498 Status: dzVents: > isTimer: false
2019-09-29 22:56:00.498 Status: dzVents: > baseType: httpResponse
2019-09-29 22:56:00.498 Status: dzVents: > headers:
2019-09-29 22:56:00.498 Status: dzVents: > Content-Length: 352
2019-09-29 22:56:00.498 Status: dzVents: > Date: Sun, 29 Sep 2019 20:56:00 GMT
2019-09-29 22:56:00.498 Status: dzVents: > Content-Type: text/javascript; charset=utf-8
2019-09-29 22:56:00.498 Status: dzVents: > Server: lighttpd/1.4.35
2019-09-29 22:56:00.498 Status: dzVents: Info: ToonInfo_0.201909291100: ------ Finished Script #2
2019-09-29 22:56:02.481 (Synology DS218 monitor) Light/Switch (Synology DS218 status)
2019-09-29 22:56:02.528 (Synology DS118 monitor) Light/Switch (Synology DS118 status)
2019-09-29 22:56:02.476 Status: User: Admin initiated a switch command (1/Synology DS218 status/On)
2019-09-29 22:56:02.523 Status: User: Admin initiated a switch command (9/Synology DS118 status/On)
2019-09-29 22:57:00.240 Status: dzVents: Info: ------ Start internal script: Script #1:, trigger: every minute
2019-09-29 22:57:00.294 Status: dzVents: Info: Thermostaat = 15
2019-09-29 22:57:00.294 Status: dzVents: Info: Modulatie niveau = 0
2019-09-29 22:57:00.295 Status: dzVents: Info: Huidige woonkamer temp = 20.6
2019-09-29 22:57:00.295 Status: dzVents: Info: ------ Finished Script #1
2019-09-29 22:57:00.295 Status: dzVents: Info: ToonInfo_0.201909291100: ------ Start internal script: Script #2:, trigger: every 1 minutes
2019-09-29 22:57:00.295 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: url = http://192.168.1.61/happ_thermstat?action=getThermostatInfo
2019-09-29 22:57:00.295 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: method = GET
2019-09-29 22:57:00.295 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: post data = nil
2019-09-29 22:57:00.295 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: headers = nil
2019-09-29 22:57:00.295 Status: dzVents: Debug: ToonInfo_0.201909291100: OpenURL: callback = ToonInfo_0.201909291100
2019-09-29 22:57:00.295 Status: dzVents: > baseType: timer
2019-09-29 22:57:00.295 Status: dzVents: > isTimer: true
2019-09-29 22:57:00.295 Status: dzVents: > isScene: false
2019-09-29 22:57:00.295 Status: dzVents: > isDevice: false
2019-09-29 22:57:00.295 Status: dzVents: > trigger: every 1 minutes
2019-09-29 22:57:00.295 Status: dzVents: > isSecurity: false
2019-09-29 22:57:00.295 Status: dzVents: > isGroup: false
2019-09-29 22:57:00.295 Status: dzVents: > isVariable: false
2019-09-29 22:57:00.296 Status: dzVents: > isHTTPResponse: false
2019-09-29 22:57:00.296 Status: dzVents: Info: ToonInfo_0.201909291100: ------ Finished Script #2
2019-09-29 22:57:00.296 Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
2019-09-29 22:57:00.415 Status: dzVents: Info: Handling httpResponse-events for: "ToonInfo_0.201909291100
2019-09-29 22:57:00.415 Status: dzVents: Info: ToonInfo_0.201909291100: ------ Start internal script: Script #2: HTTPResponse: "ToonInfo_0.201909291100"
2019-09-29 22:57:00.416 Status: dzVents: Debug: ToonInfo_0.201909291100: {"result":"ok", "currentTemp":"2063", "currentSetpoint":"1500", "currentInternalBoilerSetpoint":"6", "programState":"2", "activeState":"3", "nextProgram":"1", "nextState":"2", "nextTime":"1569790800","nextSetpoint":"1600","randomConfigId":"1804289383","errorFound":"255","connection":"0","burnerInfo":"0","otCommError":"0","currentModulationLevel":"0"}
2019-09-29 22:57:00.416 Status: dzVents: > headers:
2019-09-29 22:57:00.417 Status: dzVents: > Content-Length: 352
2019-09-29 22:57:00.417 Status: dzVents: > Content-Type: text/javascript; charset=utf-8
2019-09-29 22:57:00.417 Status: dzVents: > Server: lighttpd/1.4.35
2019-09-29 22:57:00.417 Status: dzVents: > Date: Sun, 29 Sep 2019 20:57:00 GMT
2019-09-29 22:57:00.417 Status: dzVents: > isTimer: false
2019-09-29 22:57:00.417 Status: dzVents: > isScene: false
2019-09-29 22:57:00.417 Status: dzVents: > isDevice: false
2019-09-29 22:57:00.417 Status: dzVents: > trigger: ToonInfo_0.201909291100
2019-09-29 22:57:00.417 Status: dzVents: > data: {"result":"ok", "currentTemp":"2063", "currentSetpoint":"1500", "currentInternalBoilerSetpoint":"6", "programState":"2", "activeState":"3", "nextProgram":"1", "nextState":"2", "nextTime":"1569790800","nextSetpoint":"1600","randomConfigId":"1804289383","errorFound":"255","connection":"0","burnerInfo":"0","otCommError":"0","currentModulationLevel":"0"}
2019-09-29 22:57:00.417 Status: dzVents: > isGroup: false
2019-09-29 22:57:00.417 Status: dzVents: > _contentType: text/javascript; charset=utf-8
2019-09-29 22:57:00.417 Status: dzVents: > baseType: httpResponse
2019-09-29 22:57:00.417 Status: dzVents: > ok: true
2019-09-29 22:57:00.417 Status: dzVents: > isHTTPResponse: true
2019-09-29 22:57:00.417 Status: dzVents: > protocol: HTTP/1.1
2019-09-29 22:57:00.417 Status: dzVents: > statusCode: 200
2019-09-29 22:57:00.417 Status: dzVents: > isVariable: false
2019-09-29 22:57:00.417 Status: dzVents: > statusText: OK
2019-09-29 22:57:00.417 Status: dzVents: > isJSON: false
2019-09-29 22:57:00.417 Status: dzVents: > callback: ToonInfo_0.201909291100
2019-09-29 22:57:00.417 Status: dzVents: > isSecurity: false
2019-09-29 22:57:00.417 Status: dzVents: Info: ToonInfo_0.201909291100: ------ Finished Script #2
Re: Another noob question (toonInfo)
Posted: Sunday 29 September 2019 23:54
by OedzesG
But today i had some time to make some test...
I thought it would be good to check if everything is working correctly by bringing the data to the domoticz logfiles.
After a lot if reading on the internet i found a solution...
This is what i have so far..
Code: Select all
return {
on = {timer = {'every minute'}},
execute = function(domoticz)
local ToonIP = '192.168.1.61'
local json = assert(loadfile "/usr/local/domoticz/var/scripts/lua/JSON.lua")()
local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
local ThermostatInfo = handle:read('*all')
handle:close()
local jsonThermostatInfo = json:decode(ThermostatInfo)
if jsonThermostatInfo == nil then
return
end
--Ingestelde programma
local hudige_programma = tonumber(jsonThermostatInfo.activeState)
if hudige_programma == -1 then domoticz.log ('Huidige programma = Handmatig')
elseif hudige_programma == 0 then domoticz.log ('Huidige programma = Comfort')
elseif hudige_programma == 1 then domoticz.log ('Huidige programma = Thuis')
elseif hudige_programma == 2 then domoticz.log ('Huidige programma = Slapen')
elseif hudige_programma == 3 then domoticz.log ('Huidige programma = Weg')
elseif hudige_programma == 4 then domoticz.log ('Huidige programma = Vakantie')
end
--Automatich programma
local automatisch_programma = tonumber(jsonThermostatInfo.programState)
if automatisch_programma == 0 then domoticz.log ('Toon programma = Handmatig')
elseif automatisch_programma == 1 then domoticz.log ('Toon programma = Automatisch')
elseif automatisch_programma == 2 then domoticz.log ('Toon programma = Automatisch met tijdelijk afwijkend programma')
elseif automatisch_programma == 8 then domoticz.log ('Toon programma = Automatisch met continu afwijkend programma')
end
--Huidige thermostaat waarde
local waarde_thermostaat = tonumber(jsonThermostatInfo.currentSetpoint) / 100
domoticz.log('Thermostaat = ' .. tostring(waarde_thermostaat), domoticz.LOG_INFO)
--Modulatie niveau
local modulatie_niveau = tonumber(jsonThermostatInfo.currentModulationLevel)
domoticz.log('Modulatie niveau = ' .. tostring(modulatie_niveau), domoticz.LOG_INFO)
--Temperatuur woonkamer
local woonkamer_temperatuur = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
domoticz.log('Huidige woonkamer temp = ' .. tostring(woonkamer_temperatuur), domoticz.LOG_INFO)
end
}
Code: Select all
2019-09-29 23:53:00.203 Status: dzVents: Info: ------ Start internal script: Script #1:, trigger: every minute
2019-09-29 23:53:00.254 Status: dzVents: Info: Huidige programma = Slapen
2019-09-29 23:53:00.254 Status: dzVents: Info: Toon programma = Automatisch
2019-09-29 23:53:00.254 Status: dzVents: Info: Thermostaat = 16
2019-09-29 23:53:00.255 Status: dzVents: Info: Modulatie niveau = 0
2019-09-29 23:53:00.255 Status: dzVents: Info: Huidige woonkamer temp = 20.3
2019-09-29 23:53:00.255 Status: dzVents: Info: ------ Finished Script #1
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 0:56
by waaren
OedzesG wrote: ↑Sunday 29 September 2019 23:54
But today i had some time to make some test...
After a lot if reading on the internet i found a solution...
Good start !
Have a look at the attached where the curl command is replaced by the async openURL command. This will prevent the domoticz event system to come to a stand still when the Toon does not react timely.
Code: Select all
local scriptVersion = '0.201909300100'
local scriptVar = 'ToonInfo_' .. scriptVersion
--[[
this dzVents script is used to collect data from Rooted Toon
It uses a openURL call and interprets the returned JSON.
Before activating the script:
please read the GETTING STARTED section of the dzVents wiki.
change xxx.xxx.xxx.xxx in this script to the IP of your Toon
define a dummy hardware in domoticz if not already done
define virtual sensors this dummy hardware
and change the name in the device declarations
]]--
return
{
on =
{
timer = { 'every 1 minutes' },
httpResponses = { scriptVar },
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
local toonIP = '192.168.1.61'
local function getToonInfo()
local url = 'http://' .. toonIP .. '/happ_thermstat?action=getThermostatInfo'
dz.openURL({ url = url, callback = scriptVar })
end
local function processResult(jsonThermostatInfo)
local domoticz = dz -- I always use dz to abbreviate domoticz
--Ingestelde programma
local hudige_programma = tonumber(jsonThermostatInfo.activeState)
if hudige_programma == -1 then domoticz.log ('Huidige programma = Handmatig')
elseif hudige_programma == 0 then domoticz.log ('Huidige programma = Comfort')
elseif hudige_programma == 1 then domoticz.log ('Huidige programma = Thuis')
elseif hudige_programma == 2 then domoticz.log ('Huidige programma = Slapen')
elseif hudige_programma == 3 then domoticz.log ('Huidige programma = Weg')
elseif hudige_programma == 4 then domoticz.log ('Huidige programma = Vakantie')
end
--Automatich programma
local automatisch_programma = tonumber(jsonThermostatInfo.programState)
if automatisch_programma == 0 then domoticz.log ('Toon programma = Handmatig')
elseif automatisch_programma == 1 then domoticz.log ('Toon programma = Automatisch')
elseif automatisch_programma == 2 then domoticz.log ('Toon programma = Automatisch met tijdelijk afwijkend programma')
elseif automatisch_programma == 8 then domoticz.log ('Toon programma = Automatisch met continu afwijkend programma')
end
--Huidige thermostaat waarde
local waarde_thermostaat = tonumber(jsonThermostatInfo.currentSetpoint) / 100
domoticz.log('Thermostaat = ' .. tostring(waarde_thermostaat), domoticz.LOG_INFO)
--Modulatie niveau
local modulatie_niveau = tonumber(jsonThermostatInfo.currentModulationLevel)
domoticz.log('Modulatie niveau = ' .. tostring(modulatie_niveau), domoticz.LOG_INFO)
--Temperatuur woonkamer
local woonkamer_temperatuur = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
domoticz.log('Huidige woonkamer temp = ' .. tostring(woonkamer_temperatuur), domoticz.LOG_INFO)
end
-- main
if item.isTimer or item.isDevice then
getToonInfo()
elseif item.ok then -- statusCode == 2xx
local toonInfo = dz.utils.fromJSON(item.data )
processResult(toonInfo)
else
dz.log('Could not get (good) data from ' .. toonIP .. '\n' .. item.data ,dz.LOG_ERROR)
end
end
}
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 9:30
by EdwinK
Thanks. So far this seems to work for me, onwards to the next step, controlling the toon

, and adding sensors/switches
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 9:44
by OedzesG
Thnx Waaren!! youre knowledge is amazing!
by EdwinK » Monday 30 September 2019 9:30
Thanks. So far this seems to work for me, onwards to the next step, controlling the toon

, and adding sensors/switches
Good to hear EdwinK... My idea is to let this script run trough Domoticz API, so youre free to call the devices whatever you want..
This morning i make a test to update my selector switch when Toon is changed.
So far.. so good..
Code: Select all
return {
on = {timer = {'every minute'}},
execute = function(domoticz)
local ToonIP = '192.168.1.61'
local DomoticzIpPoort = '192.168.1.24:8085'
local IDX_ToonProgramma = '48'
local IDX_ToonProgrammaVerloop = ''
local json = assert(loadfile "/usr/local/domoticz/var/scripts/lua/JSON.lua")()
local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
local ThermostatInfo = handle:read('*all')
handle:close()
local jsonThermostatInfo = json:decode(ThermostatInfo)
if jsonThermostatInfo == nil then
return
end
-- ACTIEVE PROGRAMMA --
local actieve_programma = tonumber(jsonThermostatInfo.activeState)
if actieve_programma == -1 then domoticz.log ('Actieve programma = Handmatig')
elseif actieve_programma == 0 then domoticz.log ('Actieve programma = Comfort')
elseif actieve_programma == 1 then domoticz.log ('Actieve programma = Thuis')
elseif actieve_programma == 2 then domoticz.log ('Actieve programma = Slapen')
elseif actieve_programma == 3 then domoticz.log ('Actieve programma = Weg')
elseif actieve_programma == 4 then domoticz.log ('Actieve programma = Vakantie')
end
if actieve_programma == -1 then actieve_programma = 0
elseif actieve_programma == 0 then actieve_programma = 10
elseif actieve_programma == 1 then actieve_programma = 20
elseif actieve_programma == 2 then actieve_programma = 30
elseif actieve_programma == 3 then actieve_programma = 40
elseif actieve_programma == 4 then actieve_programma = 50
end
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=switchlight&idx=' ..
IDX_ToonProgramma ..
'&switchcmd=Set%20Level&level=' ..
tostring(actieve_programma),
method = 'GET',
})
-- PROGRAMMA VERLOOP --
local programma_verloop = tonumber(jsonThermostatInfo.programState)
if programma_verloop == 0 then domoticz.log ('Toon programma verloop = Handmatig')
elseif programma_verloop == 1 then domoticz.log ('Toon programma verloop = Automatisch')
elseif programma_verloop == 2 then domoticz.log ('Toon programma verloop = Automatisch met tijdelijk afwijkend programma')
elseif programma_verloop == 8 then domoticz.log ('Toon programma verloop = Automatisch met continu afwijkend programma')
end
--Huidige thermostaat waarde
local waarde_thermostaat = tonumber(jsonThermostatInfo.currentSetpoint) / 100
domoticz.log('Thermostaat = ' .. tostring(waarde_thermostaat), domoticz.LOG_INFO)
--Modulatie niveau
local modulatie_niveau = tonumber(jsonThermostatInfo.currentModulationLevel)
domoticz.log('Modulatie niveau = ' .. tostring(modulatie_niveau), domoticz.LOG_INFO)
--Temperatuur woonkamer
local woonkamer_temperatuur = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
domoticz.log('Huidige woonkamer temp = ' .. tostring(woonkamer_temperatuur), domoticz.LOG_INFO)
end
}
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 12:39
by OedzesG
I think i almoast finisching my script: ToonToDomoticz.
What do you think about it?

- toon_domoticz_image.JPG (98.35 KiB) Viewed 1284 times
Code: Select all
local scriptVersion = '0.201909300100'
local scriptVar = 'ToonInfo_' .. scriptVersion
--[[
dit dzVents-script wordt gebruikt om gegevens van Rooted Toon te verzamelen
Het gebruikt een openURL-aanroep en interpreteert de geretourneerde JSON.
Voordat u het script activeert:
lees het gedeelte AAN DE SLAG van de dzVents-wiki.
wijzig xxx.xxx.xxx.xxx in dit script in het IP-adres van uw Toon
definieer een dummy hardware in domoticz als dit nog niet is gebeurd
definieer virtuele sensoren deze dummy hardware
en wijzig de naam in de apparaatverklaringen
]]--
return
{
on =
{ timer = { 'every 1 minutes' },httpResponses = { scriptVar },
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
-- INSTELLINGEN NAAR EIGEN SITUATIE --
local toonIP = '192.168.1.61' -- Toon thermostaat IP adres
local DomoticzIpPoort = '192.168.1.24:8085' -- Domoticz IP adres + poort
local IDX_ToonThermostaatProgramma = '48' -- IDX nummer Toon thermostaat programma keuze-schakelaar
local IDX_ToonAutoProgramma = '49' -- IDX nummer Toon auto programma keuze-schakelaar
local IDX_ToonThermostaat = '50' -- IDX nummer toon thermostaat
local IDX_KamerTemperatuur = '51' -- IDX nummer kamer tamperatuur
local IDX_ModulatieNiveau = '52' -- IDX nummer modulatie niveau custom sensor
local IDX_ToonActiviteit = '53' -- IDX nummer Toon activiteit keuze-schakelaar
-- HIERONDER NIETS MEER VERANDEREN !! --
local function getToonInfo()
local url = 'http://' .. toonIP .. '/happ_thermstat?action=getThermostatInfo'
dz.openURL ({ url = url, callback = scriptVar })
end
local function processResult(jsonThermostatInfo)
local domoticz = dz
-- TOON THERMOSTAAT PROGRAMMA --
local thermostaat_programma = tonumber(jsonThermostatInfo.activeState)
if thermostaat_programma == -1 then domoticz.log ('Programma Toon thermostaat = Handmatig')
elseif thermostaat_programma == 0 then domoticz.log ('Programma Toon thermostaat = Comfort')
elseif thermostaat_programma == 1 then domoticz.log ('Programma Toon thermostaat = Thuis')
elseif thermostaat_programma == 2 then domoticz.log ('Programma Toon thermostaat = Slapen')
elseif thermostaat_programma == 3 then domoticz.log ('Programma Toon thermostaat = Weg')
elseif thermostaat_programma == 4 then domoticz.log ('Programma Toon thermostaat = Vakantie')
end
if thermostaat_programma == -1 then thermostaat_programma = 0
elseif thermostaat_programma == 0 then thermostaat_programma = 10
elseif thermostaat_programma == 1 then thermostaat_programma = 20
elseif thermostaat_programma == 2 then thermostaat_programma = 30
elseif thermostaat_programma == 3 then thermostaat_programma = 40
elseif thermostaat_programma == 4 then thermostaat_programma = 50
end
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=switchlight&idx=' ..
IDX_ToonThermostaatProgramma ..
'&switchcmd=Set%20Level&level=' ..
tostring(thermostaat_programma),
method = 'GET',
})
-- TOON AUTO PROGRAMMA --
local auto_programma = tonumber(jsonThermostatInfo.programState)
if auto_programma == 0 then domoticz.log ('Toon automatisch programma = Uit')
elseif auto_programma == 1 then domoticz.log ('Toon automatisch programma = Aan')
elseif auto_programma == 2 then domoticz.log ('Toon automatisch programma = Aan met tijdelijk afwijkend programma')
elseif auto_programma == 8 then domoticz.log ('Toon automatisch programma = Aan met continu afwijkend programma')
end
if auto_programma == 0 then auto_programma = 0
elseif auto_programma == 1 then auto_programma = 10
elseif auto_programma == 2 then auto_programma = 20
elseif auto_programma == 8 then auto_programma = 30
end
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=switchlight&idx=' ..
IDX_ToonAutoProgramma ..
'&switchcmd=Set%20Level&level=' ..
tostring(auto_programma),
method = 'GET',
})
-- TOON THERMOSTAAT --
local waarde_thermostaat = tonumber(jsonThermostatInfo.currentSetpoint) / 100
domoticz.log('Thermostaat = ' .. tostring(waarde_thermostaat), domoticz.LOG_INFO)
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=setsetpoint&idx=' ..
IDX_ToonThermostaat ..
'&setpoint=' ..
tostring(waarde_thermostaat),
method = 'GET',
})
-- HUIDIGE KAMER TEMPERATUUR --
local kamer_temperatuur = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
domoticz.log('Huidige woonkamer temp. = ' .. tostring(kamer_temperatuur), domoticz.LOG_INFO)
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=udevice&idx=' ..
IDX_KamerTemperatuur ..
'&nvalue=0&svalue=' ..
tostring(kamer_temperatuur),
method = 'GET',
})
-- MODULATIE NIVEAU --
local modulatie_niveau = tonumber(jsonThermostatInfo.currentModulationLevel)
domoticz.log('Modulatie niveau = ' .. tostring(modulatie_niveau), domoticz.LOG_INFO)
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=udevice&idx=' ..
IDX_ModulatieNiveau ..
'&nvalue=0&svalue=' ..
tostring(modulatie_niveau),
method = 'GET',
})
-- TOON ACTIVITEIT --
local toon_activiteit = tonumber(jsonThermostatInfo.burnerInfo)
if toon_activiteit == 0 then domoticz.log ('Momenteel geen activiteit')
elseif toon_activiteit == 1 then domoticz.log ('Verwarmen CV')
elseif toon_activiteit == 2 then domoticz.log ('Verwarmen water')
end
if toon_activiteit == 0 then toon_activiteit = 0
elseif toon_activiteit == 1 then toon_activiteit = 10
elseif toon_activiteit == 2 then toon_activiteit = 20
end
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=switchlight&idx=' ..
IDX_ToonActiviteit ..
'&switchcmd=Set%20Level&level=' ..
tostring(toon_activiteit),
method = 'GET',
})
end
-- main
if item.isTimer or item.isDevice then
getToonInfo()
elseif item.ok then -- statusCode == 2xx
local toonInfo = dz.utils.fromJSON(item.data )
processResult(toonInfo)
else
dz.log('Could not get (good) data from ' .. toonIP .. '\n' .. item.data ,dz.LOG_ERROR)
end
end
}
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 16:51
by OedzesG
I think i needed some help guys!
I made another small script to set my setpoint:
Code: Select all
return {
on = {
devices = {'Toon thermostaat'}
},
execute = function(domoticz, device)
local ToonIp = '192.168.1.61'
local ThermostaatWaarde = device.setPoint*100
domoticz.log('Ingestelde temperatuur. = ' .. tostring(ThermostaatWaarde/100), domoticz.LOG_INFO)
domoticz.openURL({
url = 'http://'..
ToonIp ..
'/happ_thermstat?action=setSetpoint&Setpoint=' ..
tostring(ThermostaatWaarde),
method = 'GET',
})
end
}
The problem is that when my script: ToonToDomoticz is running (every minute) this script also is triggered.. so the url is send en then Toon api is thinking that the temperature is manualy changed and set the program to Manualy.
So how do i prefent that this script is triggered trough my other script?
Thnx! (hope you understand my broblem!

)
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 16:57
by OedzesG
This is my fully ToonToDomoticz script...
Code: Select all
local scriptVersion = '0.201909300100'
local scriptVar = 'ToonInfo_' .. scriptVersion
--[[
dit dzVents-script wordt gebruikt om gegevens van Rooted Toon te verzamelen
Het gebruikt een openURL-aanroep en interpreteert de geretourneerde JSON.
Voordat u het script activeert:
lees het gedeelte AAN DE SLAG van de dzVents-wiki.
wijzig: INSTELLINGEN NAAR EIGEN SITUATIE in dit script, overeenkomstig met uw
eigen Domoticz installatie.
definieer een dummy hardware in domoticz als dit nog niet is gebeurd en registreer
hun unieke IDX nummers.
]]--
return
{on =
{ timer = { 'every 1 minutes' },
httpResponses = { scriptVar },
},
logging =
{ level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
-- INSTELLINGEN NAAR EIGEN SITUATIE --
local toonIP = '192.168.1.61' -- Toon thermostaat IP adres
local DomoticzIpPoort = '192.168.1.24:8085' -- Domoticz IP adres + poort
local IDX_ToonScene = '48' -- IDX nummer Toon thermostaat scene keuze-schakelaar
local IDX_ToonAutoProgramma = '49' -- IDX nummer Toon auto programma keuze-schakelaar
local IDX_ToonThermostaat = '50' -- IDX nummer toon thermostaat
local IDX_ToonKamerTemperatuur = '51' -- IDX nummer kamer tamperatuur
local IDX_ToonModulatieNiveau = '52' -- IDX nummer modulatie niveau custom sensor
local IDX_ToonActiviteit = '53' -- IDX nummer Toon activiteit keuze-schakelaar
-- HIERONDER NIETS MEER VERANDEREN !! --
local function getToonInfo()
local url = 'http://' .. toonIP .. '/happ_thermstat?action=getThermostatInfo'
dz.openURL ({ url = url, callback = scriptVar })
end
local function processResult(jsonThermostatInfo)
local domoticz = dz
-- TOON SCENE --
local toon_scene = tonumber(jsonThermostatInfo.activeState)
if toon_scene == -1 then domoticz.log ('Programma Toon thermostaat = Handmatig')
elseif toon_scene == 0 then domoticz.log ('Programma Toon thermostaat = Comfort')
elseif toon_scene == 1 then domoticz.log ('Programma Toon thermostaat = Thuis')
elseif toon_scene == 2 then domoticz.log ('Programma Toon thermostaat = Slapen')
elseif toon_scene == 3 then domoticz.log ('Programma Toon thermostaat = Weg')
elseif toon_scene == 4 then domoticz.log ('Programma Toon thermostaat = Vakantie')
end
if toon_scene == -1 then toon_scene = 0
elseif toon_scene == 0 then toon_scene = 10
elseif toon_scene == 1 then toon_scene = 20
elseif toon_scene == 2 then toon_scene = 30
elseif toon_scene == 3 then toon_scene = 40
elseif toon_scene == 4 then toon_scene = 50
end
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=switchlight&idx=' ..
IDX_ToonScene ..
'&switchcmd=Set%20Level&level=' ..
tostring(toon_scene),
method = 'GET',
})
-- TOON AUTO PROGRAMMA --
local auto_programma = tonumber(jsonThermostatInfo.programState)
if auto_programma == 0 then domoticz.log ('Toon automatisch programma = Uit')
elseif auto_programma == 1 then domoticz.log ('Toon automatisch programma = Aan')
elseif auto_programma == 2 then domoticz.log ('Toon automatisch programma = Aan met tijdelijk afwijkend programma')
elseif auto_programma == 8 then domoticz.log ('Toon automatisch programma = Aan met continu afwijkend programma')
end
if auto_programma == 0 then auto_programma = 0
elseif auto_programma == 1 then auto_programma = 10
elseif auto_programma == 2 then auto_programma = 20
elseif auto_programma == 8 then auto_programma = 30
end
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=switchlight&idx=' ..
IDX_ToonAutoProgramma ..
'&switchcmd=Set%20Level&level=' ..
tostring(auto_programma),
method = 'GET',
})
-- TOON THERMOSTAAT --
local waarde_thermostaat = tonumber(jsonThermostatInfo.currentSetpoint) / 100
domoticz.log('Thermostaat = ' .. tostring(waarde_thermostaat), domoticz.LOG_INFO)
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=setsetpoint&idx=' ..
IDX_ToonThermostaat ..
'&setpoint=' ..
tostring(waarde_thermostaat),
method = 'GET',
})
-- HUIDIGE KAMER TEMPERATUUR --
local kamer_temperatuur = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
domoticz.log('Huidige woonkamer temp. = ' .. tostring(kamer_temperatuur), domoticz.LOG_INFO)
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=udevice&idx=' ..
IDX_ToonKamerTemperatuur ..
'&nvalue=0&svalue=' ..
tostring(kamer_temperatuur),
method = 'GET',
})
-- MODULATIE NIVEAU --
local modulatie_niveau = tonumber(jsonThermostatInfo.currentModulationLevel)
domoticz.log('Modulatie niveau = ' .. tostring(modulatie_niveau), domoticz.LOG_INFO)
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=udevice&idx=' ..
IDX_ToonModulatieNiveau ..
'&nvalue=0&svalue=' ..
tostring(modulatie_niveau),
method = 'GET',
})
-- TOON ACTIVITEIT --
local toon_activiteit = tonumber(jsonThermostatInfo.burnerInfo)
if toon_activiteit == 0 then domoticz.log ('Momenteel geen activiteit')
elseif toon_activiteit == 1 then domoticz.log ('Verwarmen CV')
elseif toon_activiteit == 2 then domoticz.log ('Verwarmen water')
end
if toon_activiteit == 0 then toon_activiteit = 0
elseif toon_activiteit == 1 then toon_activiteit = 10
elseif toon_activiteit == 2 then toon_activiteit = 20
end
domoticz.openURL({
url = 'http://'..
DomoticzIpPoort ..
'/json.htm?type=command¶m=switchlight&idx=' ..
IDX_ToonActiviteit ..
'&switchcmd=Set%20Level&level=' ..
tostring(toon_activiteit),
method = 'GET',
})
end
-- main
if item.isTimer or item.isDevice then
getToonInfo()
elseif item.ok then -- statusCode == 2xx
local toonInfo = dz.utils.fromJSON(item.data )
processResult(toonInfo)
else
dz.log('Could not get (good) data from ' .. toonIP .. '\n' .. item.data ,dz.LOG_ERROR)
end
end
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 17:00
by waaren
OedzesG wrote: ↑Monday 30 September 2019 12:39
I think i almost finished my script: ToonToDomoticz.
I am not sure I quite understand why you use the domoticz.openURL call for setting the switches in domoticz.
Is there a reason why you don't' use
Code: Select all
domoticz.devices(IDX_ToonThermostaatProgramma).setLevel(thermostaat_programma)
and similar commands in the other places where you now use domoticz openURL ?
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 19:00
by OedzesG
No special reason for URL, just becouse i know how to handle.
For now i changed everything.. but the same problem.
Domoticz triggers the ToonThermostaat script when updating the setpoint and after that when te temerature is changed by selecting a scene, Toon API is thinking that the temerature is changed manualy by setpoint.. en then changing the scene to manual..
ToonToDomoticz:
- Spoiler: show
- local scriptVersion = '0.201909300100'
local scriptVar = 'ToonInfo_' .. scriptVersion
return
{
on = {
timer = { 'every 1 minutes' },
httpResponses = { scriptVar }},
logging =
{level = domoticz.LOG_DEBUG,
marker = scriptVar,},
execute = function(dz, item, devices)
-- INSTELLINGEN NAAR EIGEN SITUATIE --
local toonIP = '192.168.1.61' -- Toon thermostaat IP adres
local IDX_ToonScene = 48 -- IDX nummer Toon thermostaat scene keuze-schakelaar
local IDX_ToonAutoProgramma = 49 -- IDX nummer Toon auto programma keuze-schakelaar
local IDX_ToonThermostaat = 50 -- IDX nummer toon thermostaat
local IDX_ToonKamerTemperatuur = 51 -- IDX nummer kamer tamperatuur
local IDX_ToonModulatieNiveau = 52 -- IDX nummer modulatie niveau custom sensor
local IDX_ToonActiviteit = 53 -- IDX nummer Toon activiteit keuze-schakelaar
-- HIERONDER NIETS MEER VERANDEREN !! --
local function getToonInfo()
local url = 'http://' .. toonIP .. '/happ_thermstat?action=getThermostatInfo'
dz.openURL ({ url = url, callback = scriptVar })
end
local function processResult(jsonThermostatInfo)
local domoticz = dz
-- TOON SCENE --
local toon_scene = tonumber(jsonThermostatInfo.activeState)
if toon_scene == -1 then domoticz.log ('Programma Toon thermostaat = Handmatig')
elseif toon_scene == 0 then domoticz.log ('Programma Toon thermostaat = Comfort')
elseif toon_scene == 1 then domoticz.log ('Programma Toon thermostaat = Thuis')
elseif toon_scene == 2 then domoticz.log ('Programma Toon thermostaat = Slapen')
elseif toon_scene == 3 then domoticz.log ('Programma Toon thermostaat = Weg')
elseif toon_scene == 4 then domoticz.log ('Programma Toon thermostaat = Vakantie')
end
if toon_scene == -1 then toon_scene = 0
elseif toon_scene == 0 then toon_scene = 10
elseif toon_scene == 1 then toon_scene = 20
elseif toon_scene == 2 then toon_scene = 30
elseif toon_scene == 3 then toon_scene = 40
elseif toon_scene == 4 then toon_scene = 50
end
domoticz.devices(IDX_ToonScene).switchSelector(toon_scene)
-- TOON AUTO PROGRAMMA --
local auto_programma = tonumber(jsonThermostatInfo.programState)
if auto_programma == 0 then domoticz.log ('Toon automatisch programma = Uit')
elseif auto_programma == 1 then domoticz.log ('Toon automatisch programma = Aan')
elseif auto_programma == 2 then domoticz.log ('Toon automatisch programma = Aan met tijdelijk afwijkend programma')
elseif auto_programma == 8 then domoticz.log ('Toon automatisch programma = Aan met continu afwijkend programma')
end
if auto_programma == 0 then auto_programma = 0
elseif auto_programma == 1 then auto_programma = 10
elseif auto_programma == 2 then auto_programma = 20
elseif auto_programma == 8 then auto_programma = 30
end
domoticz.devices(IDX_ToonAutoProgramma).switchSelector(auto_programma)
-- TOON THERMOSTAAT --
local waarde_thermostaat = tonumber(jsonThermostatInfo.currentSetpoint) / 100
domoticz.log('Thermostaat = ' .. tostring(waarde_thermostaat), domoticz.LOG_INFO)
domoticz.devices(IDX_ToonThermostaat).updateSetPoint(waarde_thermostaat)
-- HUIDIGE KAMER TEMPERATUUR --
local kamer_temperatuur = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
domoticz.log('Huidige woonkamer temp. = ' .. tostring(kamer_temperatuur), domoticz.LOG_INFO)
domoticz.devices(IDX_ToonKamerTemperatuur).updateTemperature(kamer_temperatuur)
-- MODULATIE NIVEAU --
local modulatie_niveau = tonumber(jsonThermostatInfo.currentModulationLevel)
domoticz.log('Modulatie niveau = ' .. tostring(modulatie_niveau), domoticz.LOG_INFO)
domoticz.devices(IDX_ToonModulatieNiveau).updateCustomSensor(modulatie_niveau)
-- TOON ACTIVITEIT --
local toon_activiteit = tonumber(jsonThermostatInfo.burnerInfo)
if toon_activiteit == 0 then domoticz.log ('Momenteel geen activiteit')
elseif toon_activiteit == 1 then domoticz.log ('Verwarmen CV')
elseif toon_activiteit == 2 then domoticz.log ('Verwarmen water')
end
if toon_activiteit == 0 then toon_activiteit = 0
elseif toon_activiteit == 1 then toon_activiteit = 10
elseif toon_activiteit == 2 then toon_activiteit = 20
end
domoticz.devices(IDX_ToonActiviteit).switchSelector(toon_activiteit)
end
-- main
if item.isTimer or item.isDevice then
getToonInfo()
elseif item.ok then -- statusCode == 2xx
local toonInfo = dz.utils.fromJSON(item.data )
processResult(toonInfo)
else
dz.log('Could not get (good) data from ' .. toonIP .. '\n' .. item.data ,dz.LOG_ERROR)
end
end
}
ToonThermostaat
- Spoiler: show
-
return {
on = {
devices = {'Toon thermostaat'}
},
execute = function(domoticz, device)
local ToonIp = '192.168.1.61'
local ThermostaatWaarde = device.setPoint*100
domoticz.log('Ingestelde temperatuur. = ' .. tostring(ThermostaatWaarde/100), domoticz.LOG_INFO)
domoticz.openURL({
url = 'http://'..
ToonIp ..
'/happ_thermstat?action=setSetpoint&Setpoint=' ..
tostring(ThermostaatWaarde),
method = 'GET',
})
end
}
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 19:58
by OedzesG
Code: Select all
domoticz.devices(IDX_ToonThermostaat).updateSetPoint(waarde_thermostaat).silent()
Is not working on setpoints...

is ther another way?
Re: Another noob question (toonInfo)
Posted: Monday 30 September 2019 20:01
by waaren
OedzesG wrote: ↑Monday 30 September 2019 19:58
Code: Select all
domoticz.devices(IDX_ToonThermostaat).updateSetPoint(waarde_thermostaat).silent()
Is not working on setpoints...

is ther another way?
Try to search for toon rooted in the search window of this forum. There are already quite a number of scripts (Lua end dzVents) to interact between a rooted Toon and domoticz
Re: Another noob question (toonInfo)
Posted: Wednesday 09 October 2019 11:36
by EdwinK
OedzesG wrote: ↑Monday 30 September 2019 12:39
I think i almoast finisching my script: ToonToDomoticz.
What do you think about it?
toon_domoticz_image.JPG
- Spoiler: show
Code: Select all
local scriptVersion = '0.201909300100'
local scriptVar = 'ToonInfo_' .. scriptVersion
return
{
on = {
timer = { 'every 1 minutes' },
httpResponses = { scriptVar }},
logging =
{level = domoticz.LOG_DEBUG,
marker = scriptVar,},
execute = function(dz, item, devices)
-- INSTELLINGEN NAAR EIGEN SITUATIE --
local toonIP = '192.168.0.4' -- Toon thermostaat IP adres
local IDX_ToonScene = 332 -- IDX nummer Toon thermostaat scene keuze-schakelaar
local IDX_ToonAutoProgramma = 333 -- IDX nummer Toon auto programma keuze-schakelaar
local IDX_ToonThermostaat = 334 -- IDX nummer toon thermostaat
local IDX_ToonKamerTemperatuur = 335 -- IDX nummer kamer tamperatuur
local IDX_ToonModulatieNiveau = 336 -- IDX nummer modulatie niveau custom sensor
local IDX_ToonActiviteit = 337 -- IDX nummer Toon activiteit keuze-schakelaar
-- HIERONDER NIETS MEER VERANDEREN !! --
local function getToonInfo()
local url = 'http://' .. toonIP .. '/happ_thermstat?action=getThermostatInfo'
dz.openURL ({ url = url, callback = scriptVar })
end
local function processResult(jsonThermostatInfo)
local domoticz = dz
-- TOON SCENE --
local toon_scene = tonumber(jsonThermostatInfo.activeState)
if toon_scene == -1 then domoticz.log ('Programma Toon thermostaat = Handmatig')
elseif toon_scene == 0 then domoticz.log ('Programma Toon thermostaat = Comfort')
elseif toon_scene == 1 then domoticz.log ('Programma Toon thermostaat = Thuis')
elseif toon_scene == 2 then domoticz.log ('Programma Toon thermostaat = Slapen')
elseif toon_scene == 3 then domoticz.log ('Programma Toon thermostaat = Weg')
elseif toon_scene == 4 then domoticz.log ('Programma Toon thermostaat = Vakantie')
end
if toon_scene == -1 then toon_scene = 0
elseif toon_scene == 0 then toon_scene = 10
elseif toon_scene == 1 then toon_scene = 20
elseif toon_scene == 2 then toon_scene = 30
elseif toon_scene == 3 then toon_scene = 40
elseif toon_scene == 4 then toon_scene = 50
end
domoticz.devices(IDX_ToonScene).switchSelector(toon_scene)
-- TOON AUTO PROGRAMMA --
local auto_programma = tonumber(jsonThermostatInfo.programState)
if auto_programma == 0 then domoticz.log ('Toon automatisch programma = Uit')
elseif auto_programma == 1 then domoticz.log ('Toon automatisch programma = Aan')
elseif auto_programma == 2 then domoticz.log ('Toon automatisch programma = Aan met tijdelijk afwijkend programma')
elseif auto_programma == 8 then domoticz.log ('Toon automatisch programma = Aan met continu afwijkend programma')
end
if auto_programma == 0 then auto_programma = 0
elseif auto_programma == 1 then auto_programma = 10
elseif auto_programma == 2 then auto_programma = 20
elseif auto_programma == 8 then auto_programma = 30
end
domoticz.devices(IDX_ToonAutoProgramma).switchSelector(auto_programma)
-- TOON THERMOSTAAT --
local waarde_thermostaat = tonumber(jsonThermostatInfo.currentSetpoint) / 100
domoticz.log('Thermostaat = ' .. tostring(waarde_thermostaat), domoticz.LOG_INFO)
domoticz.devices(IDX_ToonThermostaat).updateSetPoint(waarde_thermostaat)
-- HUIDIGE KAMER TEMPERATUUR --
local kamer_temperatuur = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
domoticz.log('Huidige woonkamer temp. = ' .. tostring(kamer_temperatuur), domoticz.LOG_INFO)
domoticz.devices(IDX_ToonKamerTemperatuur).updateTemperature(kamer_temperatuur)
-- MODULATIE NIVEAU --
local modulatie_niveau = tonumber(jsonThermostatInfo.currentModulationLevel)
domoticz.log('Modulatie niveau = ' .. tostring(modulatie_niveau), domoticz.LOG_INFO)
domoticz.devices(IDX_ToonModulatieNiveau).updateCustomSensor(modulatie_niveau)
-- TOON ACTIVITEIT --
local toon_activiteit = tonumber(jsonThermostatInfo.burnerInfo)
if toon_activiteit == 0 then domoticz.log ('Momenteel geen activiteit')
elseif toon_activiteit == 1 then domoticz.log ('Verwarmen CV')
elseif toon_activiteit == 2 then domoticz.log ('Verwarmen water')
end
if toon_activiteit == 0 then toon_activiteit = 0
elseif toon_activiteit == 1 then toon_activiteit = 10
elseif toon_activiteit == 2 then toon_activiteit = 20
end
domoticz.devices(IDX_ToonActiviteit).switchSelector(toon_activiteit)
end
-- main
if item.isTimer or item.isDevice then
getToonInfo()
elseif item.ok then -- statusCode == 2xx
local toonInfo = dz.utils.fromJSON(item.data )
processResult(toonInfo)
else
dz.log('Could not get (good) data from ' .. toonIP .. '\n' .. item.data ,dz.LOG_ERROR)
end
end
}
}
- Spoiler: show
Using this script now. Next to do is the make the switches giving the switches the right names and such.