Controlling Toon [HACKED] from Domoticz
Moderator: leecollings
-
- Posts: 451
- Joined: Friday 16 October 2015 7:58
- Target OS: Windows
- Domoticz version:
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Is the first post of this thread being updated if needed? Or should I go through the whole thread to find updates?
-
- Posts: 15
- Joined: Wednesday 11 June 2014 11:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Anyone else having issues with crashing Domoticz on latest version with Toon Sync enabled?
When i enable the LUA for the Toon Sync, Domoticz crashes with a fatal error. When i disable the Toon sync, domoticz keeps working.
The previous stable (2018) was working stable for 6 months+
When i enable the LUA for the Toon Sync, Domoticz crashes with a fatal error. When i disable the Toon sync, domoticz keeps working.
The previous stable (2018) was working stable for 6 months+
-
- Posts: 62
- Joined: Monday 28 August 2017 16:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
hi, i have rooted my ton, now i have a little problem within domoticz en virtual thermostat. if i change the temperatur on toon itself, that wil be fine updated inndomoticz, but everytime domoticz update the temp sets on toon, it triggers it also to toon back.
so if i switch on toon from away to home, the temp wil be set to 21 degrees,
now the values are updated in domoticz and domoticz send after update the virtual thermostat 21 to toon, now on toon is the scene changed from home to "tijdelijk"
thats my scritps.
toon.
and setpoint
Ok, i solved it.
Abother queation is it possible to run dzVent script every 15 ssconds?
so if i switch on toon from away to home, the temp wil be set to 21 degrees,
now the values are updated in domoticz and domoticz send after update the virtual thermostat 21 to toon, now on toon is the scene changed from home to "tijdelijk"
thats my scritps.
toon.
- Spoiler: show
and setpoint
- Spoiler: show
Ok, i solved it.
Abother queation is it possible to run dzVent script every 15 ssconds?
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
What is the latest version of the script? Going through this site (and another) I see several scripts for a rooted/hacked Toon, and I'm getting a bit (loads) confused.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
-
- Posts: 62
- Joined: Monday 28 August 2017 16:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
make an new integer user variable
UV_ToonChangedByDomoticz
set 0 on the variable
in the domoticz script add following
delete yout setpoint scritp
add a lua script triggered by device
your done, now if your change the setpoint on toon itself it update the status in domoticz, but dont trigger it
UV_ToonChangedByDomoticz
set 0 on the variable
in the domoticz script add following
change it to-- Update the thermostat sensor to current setpoint
if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then
-- domoticz.log('Updating thermostat sensor to new set point: ' ..currentSetpoint)
domoticz.devices(ToonThermostat).updateSetPoint(currentSetpoint).silent()
end
-- Update the thermostat sensor to current setpoint
if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then
-- domoticz.log('Updating thermostat sensor to new set point: ' ..currentSetpoint)
domoticz.variables('UV_ToonChangedByDomoticz').set(1)
domoticz.devices(ToonThermostat).updateSetPoint(currentSetpoint).silent()
end
delete yout setpoint scritp
add a lua script triggered by device
-- Script used for Toon Thermostaat utility device, upon changing temp in Domoticz, temperature is sent to Toon.
--
commandArray = {}
ToonThermostatSensorName = uservariables['UV_ToonThermostatSensorName'] -- Sensor showing current setpoint
ToonIP = uservariables['UV_ToonIP']
for deviceName,deviceValue in pairs(devicechanged) do
if (deviceName == ToonThermostatSensorName) then
if uservariables['UV_ToonChangedByDomoticz'] == 1 then
commandArray['Variable:UV_ToonChangedByDomoticz'] = '0'
else
SetPoint = otherdevices_svalues[ToonThermostatSensorName]
ToonCommand = string.format('http://%s/happ_thermstat?action=setSetpoint&Setpoint=%s', ToonIP, SetPoint*100)
print('Setting Toon setpoint to '.. SetPoint)
commandArray['OpenURL'] = ToonCommand
end
end
end
return commandArray
your done, now if your change the setpoint on toon itself it update the status in domoticz, but dont trigger it
- madpatrick
- Posts: 667
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
This is my latest script with a lot of functionalities. Just comment out what you do not need and adjust to your own system settings
Toon_script
Code: Select all
return {
logging = {
level = domoticz.LOG_FORCE, -- Select one of LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE to override system log level
marker = "-=# P1 Toon #=-"
},
on = {
timer = {
'every minute'
}
},
execute = function(domoticz)
local ToonThermostat = domoticz.variables('UV_ToonThermostat').value -- Sensor showing current setpoint
local ToonTemperature = domoticz.variables('UV_ToonTemperature').value -- Sensor showing current room temperature
local ToonBoilerTempIn = domoticz.variables('UV_ToonBoilerTempIn').value -- Sensor showing water temp return
local ToonBoilerTempOut = domoticz.variables('UV_ToonBoilerTempOut').value -- Sensor showing current water temp out
local ToonBoilerPressure = domoticz.variables('UV_ToonBoilerPressure').value -- Sensor showing current room temperature
local ToonBoilerModulation = domoticz.variables('UV_ToonBoilerModulation').value -- Sensor showing current Boiler Modulation
local ToonScenes = domoticz.variables('UV_ToonScenes').value -- Sensor showing current program
local ToonAutoProgram = domoticz.variables('UV_ToonAutoProgram').value -- Sensor showing current auto program status
local ToonProgramInformation = domoticz.variables('UV_ToonProgramInformation').value -- Sensor showing displaying program information status
local ToonIP = domoticz.variables('UV_ToonIP').value
local DomoticzIP = domoticz.variables('UV_DomoticzIP').value
local ToonBurnerName = domoticz.variables('UV_ToonBurnerName').value
local P1SmartMeterPower = domoticz.variables('UV_P1SmartMeterElectra').value
local P1SmartMeterGas1 = domoticz.variables('UV_P1SmartMeterGasMeterStand').value
local ToonBoilerSetpoint = domoticz.variables('UV_ToonBoilerTempSetpoint').value -- Sensor showing current boiler set point water temp out
-- Handle json
-- local json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
local json = assert(loadfile "/var/domoticz/scripts/lua/JSON.lua")() -- For Linux (ClearOS)
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
local handle2 = assert(io.popen(string.format('curl http://%s/boilerstatus/boilervalues.txt', ToonIP)))
local BoilerInfo = handle2:read('*all')
handle2:close()
-- JSON data from Toon contains a extra "," which should not be there.
BoilerInfo = string.gsub(BoilerInfo, ",}", "}")
jsonBoilerInfo = json:decode(BoilerInfo)
-- http://IP_TOON/hdrv_zwave?action=getDevices.json
local handle4 = assert(io.popen(string.format('curl http://%s/hdrv_zwave?action=getDevices.json', ToonIP)))
local GasPowerInfo = handle4:read('*all')
handle4:close()
-- JSON data from Toon contains a extra "." which should not be there.
GasPowerInfo = string.gsub(GasPowerInfo, "dev_2.", "dev_2")
GasPowerInfo = string.gsub(GasPowerInfo, "dev_2:", "dev_2\":")
local jsonGasPower = json:decode(GasPowerInfo)
-- Update the powerconsumption
local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_24.CurrentElectricityFlow ) --stroomverbruik momenteel hoogtarief
local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_26.CurrentElectricityFlow ) --stroomverbruik momenteel laagtarief
local CurrentElectricityQuantityHoog = tonumber(jsonGasPower.dev_24.CurrentElectricityQuantity) --stroomverbruik totaal hoogtarief
local CurrentElectricityQuantityLaag = tonumber(jsonGasPower.dev_26.CurrentElectricityQuantity) --stroomverbruik totaal laagtarief
local CurrentElectricityDeliveredHoog = tonumber(jsonGasPower.dev_25.CurrentElectricityQuantity) --stroomgeleverd momenteel hoogtarief
local CurrentElectricityDeliveredLaag = tonumber(jsonGasPower.dev_27.CurrentElectricityQuantity) --stroomgeleverd momenteel laagtarief
local CurrentElectricityQuantity = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag --stroomverbruik totaal aktueel
local totalDeliveredPower = 0
local totalDeliveredPower2 = CurrentElectricityDeliveredHoog/1000 + CurrentElectricityDeliveredLaag/1000 --stroomverbruik totaal geleverd
local CurrentGasFlow = tonumber(jsonGasPower.dev_21.CurrentGasFlow)
local CurrentGasQuantity = tonumber(jsonGasPower.dev_21.CurrentGasQuantity)
domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, CurrentElectricityQuantity, totalDeliveredPower).silent()
domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()
--domoticz.log('*** P1 from toon: ' .. CurrentElectricityQuantityLaag/1000 .. 'kwh USAGE1 | ' ..CurrentElectricityQuantityHoog/1000 .. 'kwh USAGE2 | ' .. CurrentElectricityDeliveredLaag/1000 .. 'kwh RETURN1 | ' .. CurrentElectricityDeliveredHoog/1000 .. 'kwh RETURN2 | ' .. CurrentElectricityQuantity .. 'w consumed | '.. totalDeliveredPower2 .. 'w produced', domoticz.LOG_FORCE)
-- Update the Boiler Water In to current value
local currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
currentboilerInTemp = tonumber(string.format("%.0f", currentboilerInTemp)) -- afgeronde getallen is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerTempIn).temperature,0) ~= domoticz.utils.round(currentboilerInTemp,0) then
domoticz.log('Updating Boiler Water In to current value: ' ..currentboilerInTemp)
domoticz.devices(ToonBoilerTempIn).updateTemperature(currentboilerInTemp).silent()
end
-- Update the Boiler water Out to current value
local currentboilerOutTemp = tonumber(jsonBoilerInfo.boilerOutTemp)
currentboilerOutTemp = tonumber(string.format("%.0f", currentboilerOutTemp)) -- afgeronde getallen is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerTempOut).temperature,0) ~= domoticz.utils.round(currentboilerOutTemp,0) then
domoticz.log('Updating Boiler Water Out to current value: ' ..currentboilerOutTemp)
domoticz.devices(ToonBoilerTempOut).updateTemperature(currentboilerOutTemp).silent()
end
-- Update the Boiler water Pressure to current value
local currentBoilerPressure = tonumber(jsonBoilerInfo.boilerPressure)
-- currentBoilerPressure = tonumber(string.format("%.1f", currentBoilerPressure)) -- 1 decimaal is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerPressure)._nValue,0) ~= domoticz.utils.round(currentBoilerPressure,0) then
domoticz.log('Updating Boiler Pressure to current value: ' ..currentBoilerPressure, domoticz.LOG_INFO)
domoticz.devices(ToonBoilerPressure).updatePressure(currentBoilerPressure).silent()
end
-- Update the current temperature setpoint
local currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
currentTemperature = tonumber(string.format("%.1f", currentTemperature)) -- 1 decimaal is voldoende [PdB]
-- Update the current auto program
local currentProgramState = tonumber(jsonThermostatInfo.programState)
if currentProgramState == 0 then currentProgramState = 10 -- No
elseif currentProgramState == 1 then currentProgramState = 20 -- Yes
elseif currentProgramState == 2 then currentProgramState = 30 -- Temporary
end
-- Update the current scene by state
local currentActiveState = tonumber(jsonThermostatInfo.activeState)
if currentActiveState == -1 then currentActiveState = 50 -- Manual
elseif currentActiveState == 0 then currentActiveState = 40 -- Comfort
elseif currentActiveState == 1 then currentActiveState = 30 -- Home
elseif currentActiveState == 2 then currentActiveState = 20 -- Sleep
elseif currentActiveState == 3 then currentActiveState = 10 -- Away
end
-- Update the current scene by temperature
local currentActiveTemp = tonumber(jsonThermostatInfo.currentSetpoint) / 100
if currentActiveTemp == 20.5 then currentActiveState = 40 -- Comfort
elseif currentActiveTemp == 19.5 then currentActiveState = 30 -- Home
elseif currentActiveTemp == 17 then currentActiveState = 20 -- Sleep
elseif currentActiveTemp == 18.5 then currentActiveState = 10 -- Away
else currentActiveState = 50 -- Manual
end
-- Update the toon burner selector to current program state
local currentBurnerInfo = tonumber(jsonThermostatInfo.burnerInfo)
local CurrentToonBurnerValue = domoticz.devices(ToonBurnerName).level
if currentBurnerInfo == 0 then currentBurnerInfo = 0 -- uit
elseif currentBurnerInfo == 1 then currentBurnerInfo = 10 -- cv aan
elseif currentBurnerInfo == 2 then currentBurnerInfo = 20 -- warmwater aan
elseif currentBurnerInfo == 3 then currentBurnerInfo = 30 -- voorverwarmen volgend setpoint
end
-- Update toon burner selector if it has changed
if CurrentToonBurnerValue ~= currentBurnerInfo then
domoticz.log('Updating Toon burner info:')
domoticz.devices(ToonBurnerName).switchSelector(currentBurnerInfo)
end
-- Update the modulation level of the burner
local currentModulationLevel = tonumber(jsonThermostatInfo.currentModulationLevel)
if domoticz.devices(ToonBoilerModulation).percentage + 1 ~= currentModulationLevel + 1 then
domoticz.log('Updating the Modulation sensor to new value: ' ..currentModulationLevel)
domoticz.devices(ToonBoilerModulation).updatePercentage(currentModulationLevel)
end
-- Update the temperature Boiler setpoint to current boiler set point
local currentInternalBoilerSetpoint = jsonThermostatInfo.currentInternalBoilerSetpoint+1
if domoticz.utils.round(domoticz.devices(ToonBoilerSetpoint).temperature, 1) ~= domoticz.utils.round(currentInternalBoilerSetpoint, 1) then
domoticz.log('Updating the Boiler internal temperature setpoint to new value: ' ..currentInternalBoilerSetpoint)
domoticz.devices(ToonBoilerSetpoint).updateTemperature(currentInternalBoilerSetpoint)
end
-- Update the thermostat sensor to current setpoint
if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then
domoticz.log('Updating thermostat sensor to new set point: ' ..currentSetpoint)
domoticz.devices(ToonThermostat).updateSetPoint(currentSetpoint).silent()
end
-- Update the temperature sensor to current room temperature
if domoticz.utils.round(domoticz.devices(ToonTemperature).temperature, 1) ~= domoticz.utils.round(currentTemperature, 1) then
domoticz.log('Updating the temperature sensor to new value: ' ..currentTemperature)
domoticz.devices(ToonTemperature).updateTemperature(currentTemperature)
end
-- Update the toon scene selector sensor to current program state
if domoticz.devices(ToonScenes).level ~= currentActiveState then -- Update toon selector if it has changed
domoticz.log('Updating Toon Scenes selector to: '..currentActiveState)
domoticz.devices(ToonScenes).switchSelector(currentActiveState).silent()
end
-- Updates the toon auto program switch
if domoticz.devices(ToonAutoProgram).level ~= currentProgramState then -- Update toon auto program selector if it has changed
domoticz.log('Updating Toon Auto Program selector to: '..currentProgramState)
domoticz.devices(ToonAutoProgram).switchSelector(currentProgramState).silent()
end
-- Updates the toon program information text box
local currentNextTime = jsonThermostatInfo.nextTime
local currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
if currentNextTime == 0 or currentNextSetPoint == 0 then
ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
else
ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
end
if domoticz.devices(ToonProgramInformation).text ~= ToonProgramInformationSensorValue then
domoticz.log('Updating Toon Program Information to: '..ToonProgramInformationSensorValue)
domoticz.devices(ToonProgramInformation).updateText(ToonProgramInformationSensorValue)
end
end
}
Code: Select all
return {
on = {
devices = {
'Toon Thermostaat'
}
},
execute = function(domoticz, device)
domoticz.openURL(string.format('http://%s/happ_thermstat?action=setSetpoint&Setpoint=%s', domoticz.variables('UV_ToonIP').value, device.setPoint*100))
domoticz.log('Setting Toon setpoint to '.. device.setPoint)
end
}
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Going to work on it this weekend.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
-
- Posts: 147
- Joined: Thursday 13 August 2015 13:36
- Target OS: NAS (Synology & others)
- Domoticz version: beta
- Location: Netherlands
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
madpatrick wrote: ↑Friday 04 October 2019 21:01 This is my latest script with a lot of functionalities.
Just comment out what you do not need and adjust to your own system settings
Toon_scriptCode: Select all
CODE STARTS -- JSON data from Toon contains a extra "." which should not be there. GasPowerInfo = string.gsub(GasPowerInfo, "dev_2.", "dev_2") GasPowerInfo = string.gsub(GasPowerInfo, "dev_2:", "dev_2\":") local jsonGasPower = json:decode(GasPowerInfo) -- Update the powerconsumption local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_24.CurrentElectricityFlow ) --stroomverbruik momenteel hoogtarief local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_26.CurrentElectricityFlow ) --stroomverbruik momenteel laagtarief local CurrentElectricityQuantityHoog = tonumber(jsonGasPower.dev_24.CurrentElectricityQuantity) --stroomverbruik totaal hoogtarief local CurrentElectricityQuantityLaag = tonumber(jsonGasPower.dev_26.CurrentElectricityQuantity) --stroomverbruik totaal laagtarief local CurrentElectricityDeliveredHoog = tonumber(jsonGasPower.dev_25.CurrentElectricityQuantity) --stroomgeleverd momenteel hoogtarief local CurrentElectricityDeliveredLaag = tonumber(jsonGasPower.dev_27.CurrentElectricityQuantity) --stroomgeleverd momenteel laagtarief local CurrentElectricityQuantity = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag --stroomverbruik totaal aktueel local totalDeliveredPower = 0 local totalDeliveredPower2 = CurrentElectricityDeliveredHoog/1000 + CurrentElectricityDeliveredLaag/1000 --stroomverbruik totaal geleverd local CurrentGasFlow = tonumber(jsonGasPower.dev_21.CurrentGasFlow) local CurrentGasQuantity = tonumber(jsonGasPower.dev_21.CurrentGasQuantity) MORE CODE }
Hi All,
I used this script from madpatrick
and I get the following error:
-=# P1 Toon #=-: ...moticz/scripts/dzVents/generated_scripts/Toon_Script.lua:64: attempt to index field 'dev_24' (a nil value)
What can I do to get this error message away? What are these dev_24, dev_25 and so on?
I hope someone can help me.
Best regards Bert
Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
- madpatrick
- Posts: 667
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
You need to check your dev_##
Go to [url]http://TOON_IP/hdrv_zwave?action=getDevices.json[/url] and check which number your Toon is having.
You can also disable these lines in the script if you do need/use them
Go to [url]http://TOON_IP/hdrv_zwave?action=getDevices.json[/url] and check which number your Toon is having.
You can also disable these lines in the script if you do need/use them
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
-
- Posts: 147
- Joined: Thursday 13 August 2015 13:36
- Target OS: NAS (Synology & others)
- Domoticz version: beta
- Location: Netherlands
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Hi,
Thanks for your help.
I asked the url and it tells me:
And now everything is fine.
I thought to do good to explain it what I did so if someone runs into the same problem he/she knows how to solve also.
Thanks for helping me!
Thanks for your help.
I asked the url and it tells me:
- Spoiler: show
Code: Select all
-- JSON data from Toon contains a extra "." which should not be there.
GasPowerInfo = string.gsub(GasPowerInfo, "dev_5.", "dev_5")
GasPowerInfo = string.gsub(GasPowerInfo, "dev_5:", "dev_5\":")
local jsonGasPower = json:decode(GasPowerInfo)
-- Update the powerconsumption
local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_52.CurrentElectricityFlow ) --stroomverbruik momenteel hoogtarief
I thought to do good to explain it what I did so if someone runs into the same problem he/she knows how to solve also.
Thanks for helping me!
Best regards Bert
Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
Synology DS1517+ - DSM 6.2
Raspberry PI2-B, Raspberry Nano - Raspberry PI3 - model B
Xiaomi Gateway - Philips HUE Lights - Zwave - RFXCom(E) with KaKu and other 433MHz devices - Yeelight Lights - Toon
- madpatrick
- Posts: 667
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
The problem is that every Toon is a little bit different somehow.
Also not everybody is using all the options provided, so need to tweak the script which is applicable.
The best way is to add some comments in the script, since searching in the forum post is difficult (they are to long at a certain point or split up)
I've added already some comments, but there is always room for improvement
Also not everybody is using all the options provided, so need to tweak the script which is applicable.
The best way is to add some comments in the script, since searching in the forum post is difficult (they are to long at a certain point or split up)
I've added already some comments, but there is always room for improvement

-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
-
- Posts: 6
- Joined: Thursday 10 October 2019 8:03
- Target OS: Windows
- Domoticz version: 4.1071
- Location: NL
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Hi, Im new here but managed with all the great instructions here to get my toon to work with Domoticz.
However, Im running domoticz on a windows PC thats always on as a mediacenter and I have the impression that the lua script doesnt work properly on windows as the values it retrieves from the Toon are not copied to the user variables in Domoticz.
I do have the json.lua file and I’ve modified the script to change the path to it, and the script executes without any errors in my domoticz log file.
Just was just wondering does anyone have the script of @madpatrick working on a windows machine? If so any pointer in the right direction you could give me?
Is there a way to modify the script to write more details into the log? After reading the thermostat info, json is used to decode the information and update the user variables. Can I add the option to write the “ThermostatInfo” to the log before and after json:decode?
Thanks!
However, Im running domoticz on a windows PC thats always on as a mediacenter and I have the impression that the lua script doesnt work properly on windows as the values it retrieves from the Toon are not copied to the user variables in Domoticz.
I do have the json.lua file and I’ve modified the script to change the path to it, and the script executes without any errors in my domoticz log file.
Just was just wondering does anyone have the script of @madpatrick working on a windows machine? If so any pointer in the right direction you could give me?
Is there a way to modify the script to write more details into the log? After reading the thermostat info, json is used to decode the information and update the user variables. Can I add the option to write the “ThermostatInfo” to the log before and after json:decode?
Thanks!
-
- Posts: 6
- Joined: Thursday 10 October 2019 8:03
- Target OS: Windows
- Domoticz version: 4.1071
- Location: NL
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
found my mistake, I didnt have curl.exe in my PATH .... making some progress
- madpatrick
- Posts: 667
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
You can set the logging on DEBUG level in the script.Peebee01 wrote: ↑Thursday 10 October 2019 8:14 s there a way to modify the script to write more details into the log? After reading the thermostat info, json is used to decode the information and update the user variables. Can I add the option to write the “ThermostatInfo” to the log before and after json:decode?
Thanks!
Code: Select all
level = domoticz.LOG_FORCE, -- Select one of LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE to override system log level
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
-
- Posts: 6
- Joined: Thursday 10 October 2019 8:03
- Target OS: Windows
- Domoticz version: 4.1071
- Location: NL
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Thanks but it doesnt provide a lot more info.
Keep getting every function to return an error message “...can not index a nil value”
Ive use madpatricks scripts on a windows pc
The error message I get is:
I created the script in Domoticz using: dzVents -> Timer. Is that correct or should this be a Lua script?
If I comment out the function on row 75, the same error occurs for the P1 gas meter, but in order to eliminate that the device ID I also commented out that one only to get the next function to complain about indexing a nil value.
So I feel there is something more fundamentally wrong. I did install curl.exe and placed it in the windows path. Is there perhaps another program needed? Starting to get lost on what is wrong so I hope someone could point me in the right direction
Thanks
Keep getting every function to return an error message “...can not index a nil value”
Ive use madpatricks scripts on a windows pc
Code: Select all
return {
logging = {
level = domoticz.LOG_INFO, -- Select one of LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE to override system log level
marker = "-=# P1 Toon #=-"
},
on = {
timer = {
'every minute'
}
},
execute = function(domoticz)
local ToonThermostat = domoticz.variables('UV_ToonThermostat').value -- Sensor showing current setpoint
local ToonTemperature = domoticz.variables('UV_ToonTemperature').value -- Sensor showing current room temperature
local ToonBoilerTempIn = domoticz.variables('UV_ToonBoilerTempIn').value -- Sensor showing water temp return
local ToonBoilerTempOut = domoticz.variables('UV_ToonBoilerTempOut').value -- Sensor showing current water temp out
local ToonBoilerPressure = domoticz.variables('UV_ToonBoilerPressure').value -- Sensor showing current room temperature
local ToonBoilerModulation = domoticz.variables('UV_ToonBoilerModulation').value -- Sensor showing current Boiler Modulation
local ToonScenes = domoticz.variables('UV_ToonScenes').value -- Sensor showing current program
local ToonAutoProgram = domoticz.variables('UV_ToonAutoProgram').value -- Sensor showing current auto program status
local ToonProgramInformation = domoticz.variables('UV_ToonProgramInformation').value -- Sensor showing displaying program information status
local ToonIP = domoticz.variables('UV_ToonIP').value
local DomoticzIP = domoticz.variables('UV_DomoticzIP').value
local ToonBurnerName = domoticz.variables('UV_ToonBurnerName').value
local P1SmartMeterPower = domoticz.variables('UV_P1SmartMeterElectra').value
local P1SmartMeterGas1 = domoticz.variables('UV_P1SmartMeterGasMeterStand').value
local ToonBoilerSetpoint = domoticz.variables('UV_ToonBoilerTempSetpoint').value -- Sensor showing current boiler set point water temp out
-- Handle json
-- local json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
-- local json = assert(loadfile "/var/domoticz/scripts/lua/JSON.lua")() -- For Linux (ClearOS)
json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")() -- For Windows
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
local handle2 = assert(io.popen(string.format('curl http://%s/boilerstatus/boilervalues.txt', ToonIP)))
local BoilerInfo = handle2:read('*all')
handle2:close()
-- JSON data from Toon contains a extra "," which should not be there.
BoilerInfo = string.gsub(BoilerInfo, ",}", "}")
jsonBoilerInfo = json:decode(BoilerInfo)
-- http://IP_TOON/hdrv_zwave?action=getDevices.json
local handle4 = assert(io.popen(string.format('curl http://%s/hdrv_zwave?action=getDevices.json', ToonIP)))
local GasPowerInfo = handle4:read('*all')
handle4:close()
-- JSON data from Toon contains a extra "." which should not be there.
GasPowerInfo = string.gsub(GasPowerInfo, "dev_3.", "dev_3")
GasPowerInfo = string.gsub(GasPowerInfo, "dev_3:", "dev_3\":")
local jsonGasPower = json:decode(GasPowerInfo)
-- Update the powerconsumption
local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_34.CurrentElectricityFlow ) --stroomverbruik momenteel hoogtarief
local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_36.CurrentElectricityFlow ) --stroomverbruik momenteel laagtarief
local CurrentElectricityQuantityHoog = tonumber(jsonGasPower.dev_34.CurrentElectricityQuantity) --stroomverbruik totaal hoogtarief
local CurrentElectricityQuantityLaag = tonumber(jsonGasPower.dev_36.CurrentElectricityQuantity) --stroomverbruik totaal laagtarief
local CurrentElectricityDeliveredHoog = tonumber(jsonGasPower.dev_35.CurrentElectricityQuantity) --stroomgeleverd momenteel hoogtarief
local CurrentElectricityDeliveredLaag = tonumber(jsonGasPower.dev_37.CurrentElectricityQuantity) --stroomgeleverd momenteel laagtarief
local CurrentElectricityQuantity = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag --stroomverbruik totaal aktueel
local totalDeliveredPower = 0
local totalDeliveredPower2 = CurrentElectricityDeliveredHoog/1000 + CurrentElectricityDeliveredLaag/1000 --stroomverbruik totaal geleverd
local CurrentGasFlow = tonumber(jsonGasPower.dev_31.CurrentGasFlow)
local CurrentGasQuantity = tonumber(jsonGasPower.dev_31.CurrentGasQuantity)
domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, CurrentElectricityQuantity, totalDeliveredPower).silent()
domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()
--domoticz.log('*** P1 from toon: ' .. CurrentElectricityQuantityLaag/1000 .. 'kwh USAGE1 | ' ..CurrentElectricityQuantityHoog/1000 .. 'kwh USAGE2 | ' .. CurrentElectricityDeliveredLaag/1000 .. 'kwh RETURN1 | ' .. CurrentElectricityDeliveredHoog/1000 .. 'kwh RETURN2 | ' .. CurrentElectricityQuantity .. 'w consumed | '.. totalDeliveredPower2 .. 'w produced', domoticz.LOG_FORCE)
-- Update the Boiler Water In to current value
local currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
currentboilerInTemp = tonumber(string.format("%.0f", currentboilerInTemp)) -- afgeronde getallen is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerTempIn).temperature,0) ~= domoticz.utils.round(currentboilerInTemp,0) then
domoticz.log('Updating Boiler Water In to current value: ' ..currentboilerInTemp)
domoticz.devices(ToonBoilerTempIn).updateTemperature(currentboilerInTemp).silent()
end
-- Update the Boiler water Out to current value
local currentboilerOutTemp = tonumber(jsonBoilerInfo.boilerOutTemp)
currentboilerOutTemp = tonumber(string.format("%.0f", currentboilerOutTemp)) -- afgeronde getallen is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerTempOut).temperature,0) ~= domoticz.utils.round(currentboilerOutTemp,0) then
domoticz.log('Updating Boiler Water Out to current value: ' ..currentboilerOutTemp)
domoticz.devices(ToonBoilerTempOut).updateTemperature(currentboilerOutTemp).silent()
end
-- Update the Boiler water Pressure to current value
local currentBoilerPressure = tonumber(jsonBoilerInfo.boilerPressure)
-- currentBoilerPressure = tonumber(string.format("%.1f", currentBoilerPressure)) -- 1 decimaal is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerPressure)._nValue,0) ~= domoticz.utils.round(currentBoilerPressure,0) then
domoticz.log('Updating Boiler Pressure to current value: ' ..currentBoilerPressure, domoticz.LOG_INFO)
domoticz.devices(ToonBoilerPressure).updatePressure(currentBoilerPressure).silent()
end
-- Update the current temperature setpoint
local currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
currentTemperature = tonumber(string.format("%.1f", currentTemperature)) -- 1 decimaal is voldoende [PdB]
-- Update the current auto program
local currentProgramState = tonumber(jsonThermostatInfo.programState)
if currentProgramState == 0 then currentProgramState = 10 -- No
elseif currentProgramState == 1 then currentProgramState = 20 -- Yes
elseif currentProgramState == 2 then currentProgramState = 30 -- Temporary
end
-- Update the current scene by state
local currentActiveState = tonumber(jsonThermostatInfo.activeState)
if currentActiveState == -1 then currentActiveState = 50 -- Manual
elseif currentActiveState == 0 then currentActiveState = 40 -- Comfort
elseif currentActiveState == 1 then currentActiveState = 30 -- Home
elseif currentActiveState == 2 then currentActiveState = 20 -- Sleep
elseif currentActiveState == 3 then currentActiveState = 10 -- Away
end
-- Update the current scene by temperature
local currentActiveTemp = tonumber(jsonThermostatInfo.currentSetpoint) / 100
if currentActiveTemp == 20.5 then currentActiveState = 40 -- Comfort
elseif currentActiveTemp == 19.5 then currentActiveState = 30 -- Home
elseif currentActiveTemp == 17 then currentActiveState = 20 -- Sleep
elseif currentActiveTemp == 18.5 then currentActiveState = 10 -- Away
else currentActiveState = 50 -- Manual
end
-- Update the toon burner selector to current program state
local currentBurnerInfo = tonumber(jsonThermostatInfo.burnerInfo)
local CurrentToonBurnerValue = domoticz.devices(ToonBurnerName).level
if currentBurnerInfo == 0 then currentBurnerInfo = 0 -- uit
elseif currentBurnerInfo == 1 then currentBurnerInfo = 10 -- cv aan
elseif currentBurnerInfo == 2 then currentBurnerInfo = 20 -- warmwater aan
elseif currentBurnerInfo == 3 then currentBurnerInfo = 30 -- voorverwarmen volgend setpoint
end
-- Update toon burner selector if it has changed
if CurrentToonBurnerValue ~= currentBurnerInfo then
domoticz.log('Updating Toon burner info:')
domoticz.devices(ToonBurnerName).switchSelector(currentBurnerInfo)
end
-- Update the modulation level of the burner
local currentModulationLevel = tonumber(jsonThermostatInfo.currentModulationLevel)
if domoticz.devices(ToonBoilerModulation).percentage + 1 ~= currentModulationLevel + 1 then
domoticz.log('Updating the Modulation sensor to new value: ' ..currentModulationLevel)
domoticz.devices(ToonBoilerModulation).updatePercentage(currentModulationLevel)
end
-- Update the temperature Boiler setpoint to current boiler set point
local currentInternalBoilerSetpoint = jsonThermostatInfo.currentInternalBoilerSetpoint+1
if domoticz.utils.round(domoticz.devices(ToonBoilerSetpoint).temperature, 1) ~= domoticz.utils.round(currentInternalBoilerSetpoint, 1) then
domoticz.log('Updating the Boiler internal temperature setpoint to new value: ' ..currentInternalBoilerSetpoint)
domoticz.devices(ToonBoilerSetpoint).updateTemperature(currentInternalBoilerSetpoint)
end
-- Update the thermostat sensor to current setpoint
if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then
domoticz.log('Updating thermostat sensor to new set point: ' ..currentSetpoint)
domoticz.devices(ToonThermostat).updateSetPoint(currentSetpoint).silent()
end
-- Update the temperature sensor to current room temperature
if domoticz.utils.round(domoticz.devices(ToonTemperature).temperature, 1) ~= domoticz.utils.round(currentTemperature, 1) then
domoticz.log('Updating the temperature sensor to new value: ' ..currentTemperature)
domoticz.devices(ToonTemperature).updateTemperature(currentTemperature)
end
-- Update the toon scene selector sensor to current program state
if domoticz.devices(ToonScenes).level ~= currentActiveState then -- Update toon selector if it has changed
domoticz.log('Updating Toon Scenes selector to: '..currentActiveState)
domoticz.devices(ToonScenes).switchSelector(currentActiveState).silent()
end
-- Updates the toon auto program switch
if domoticz.devices(ToonAutoProgram).level ~= currentProgramState then -- Update toon auto program selector if it has changed
domoticz.log('Updating Toon Auto Program selector to: '..currentProgramState)
domoticz.devices(ToonAutoProgram).switchSelector(currentProgramState).silent()
end
-- Updates the toon program information text box
local currentNextTime = jsonThermostatInfo.nextTime
local currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
if currentNextTime == 0 or currentNextSetPoint == 0 then
ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
else
ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
end
if domoticz.devices(ToonProgramInformation).text ~= ToonProgramInformationSensorValue then
domoticz.log('Updating Toon Program Information to: '..ToonProgramInformationSensorValue)
domoticz.devices(ToonProgramInformation).updateText(ToonProgramInformationSensorValue)
end
end
}
Code: Select all
2019-10-11 20:52:00.147 Status: dzVents: Debug: Dumping domoticz data to C:\Program Files (x86)\Domoticz\scripts\dzVents\domoticzData.lua
2019-10-11 20:52:00.149 Status: dzVents: Debug: Event triggers:
2019-10-11 20:52:00.149 Status: dzVents: Debug: - Timer
2019-10-11 20:52:00.169 Status: dzVents: Info: -=# P1 Toon #=-: ------ Start internal script: Script #6:, trigger: every minute
2019-10-11 20:52:00.307 Status: dzVents: Error (2.4.19): -=# P1 Toon #=-: There is no device with that name or id:
2019-10-11 20:52:00.307 Status: dzVents: Error (2.4.19): -=# P1 Toon #=-: An error occured when calling event handler Script #6
2019-10-11 20:52:00.307 Status: dzVents: Error (2.4.19): -=# P1 Toon #=-: ...Domoticz\scripts\dzVents\generated_scripts/Script #6.lua:75: attempt to index a nil value
2019-10-11 20:52:00.307 Status: dzVents: Info: -=# P1 Toon #=-: ------ Finished Script #6
If I comment out the function on row 75, the same error occurs for the P1 gas meter, but in order to eliminate that the device ID I also commented out that one only to get the next function to complain about indexing a nil value.
So I feel there is something more fundamentally wrong. I did install curl.exe and placed it in the windows path. Is there perhaps another program needed? Starting to get lost on what is wrong so I hope someone could point me in the right direction
Thanks
- madpatrick
- Posts: 667
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Do you have also created the Uservariables with the same names and also de devices ?
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
-
- Posts: 6
- Joined: Thursday 10 October 2019 8:03
- Target OS: Windows
- Domoticz version: 4.1071
- Location: NL
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Hi madpatrick,
Would you mind posting your user variables? I’ve got all I believe, but could be worth checking.
Regarding the devices, I did not understand how the devices and the user variables are linked in domoticz. The names arent identical in all cases, right? So how does a user variables update a device?
Would you mind posting your user variables? I’ve got all I believe, but could be worth checking.
Regarding the devices, I did not understand how the devices and the user variables are linked in domoticz. The names arent identical in all cases, right? So how does a user variables update a device?
- madpatrick
- Posts: 667
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
20 UV_P1SmartMeterGasMeterStand String P1 GasPeebee01 wrote: ↑Friday 11 October 2019 21:03 Hi madpatrick,
Would you mind posting your user variables? I’ve got all I believe, but could be worth checking.
Regarding the devices, I did not understand how the devices and the user variables are linked in domoticz. The names arent identical in all cases, right? So how does a user variables update a device?
19 UV_P1SmartMeterElectra String P1 Elektra
18 UV_ToonBoilerModulation String ModulationLevel
13 UV_ToonBoilerPressure String Keteldruk
12 UV_ToonBoilerTempOut String Ketel Temp UIT
11 UV_ToonBoilerTempIn String Ketel Temp IN
10 UV_ToonBurnerName String Ketelstand
9 UV_ToonBoilerTempSetpoint String Ketel Setpoint
8 UV_DomoticzIP String 192.168.1.1:9200
7 UV_ToonProgramInformation String Toon Information
6 UV_ToonAutoProgram String Toon Auto Program
4 UV_ToonScenes String Toon Scenes
3 UV_ToonTemperature String Temperatuur Kamer
2 UV_ToonIP String 192.168.1.200
1 UV_ToonThermostat String Toon Thermostaat
Sorry for the layout....
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
-
- Posts: 6
- Joined: Thursday 10 October 2019 8:03
- Target OS: Windows
- Domoticz version: 4.1071
- Location: NL
- Contact:
Re: Controlling Toon [HACKED] from Domoticz
Deleted all my user variables and recreated them based on your list.
Could you also share your devices?
Finally; the scripts are dzVents and not LUA scripts when creating them in Domoticz, right?
Could you also share your devices?
Finally; the scripts are dzVents and not LUA scripts when creating them in Domoticz, right?
Who is online
Users browsing this forum: No registered users and 1 guest