Controlling Toon via Domoticz
Moderators: marcelr, TheHogNL, Toonz
Re: Controlling Toon via Domoticz
As far as I can see, it looks like the file is found but something is wrong in the file?
Toon2 with 6.0.2 firmware TSC 2.1.7
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
- madpatrick
- Member
- Posts: 107
- Joined: Wed Dec 06, 2017 9:52 pm
- Location: Zuid-Holland
Re: Controlling Toon via Domoticz
I’m not using this version of the script, so cann’t you help with this.Xavier wrote:As far as I can see, it looks like the file is found but something is wrong in the file?
See previous post in this thread
Re: Controlling Toon via Domoticz
Could you point out which script is working for you?madpatrick wrote:I’m not using this version of the script, so cann’t you help with this.Xavier wrote:As far as I can see, it looks like the file is found but something is wrong in the file?
See previous post in this thread
There are so many scripts that I don't know which one to use
Toon2 with 6.0.2 firmware TSC 2.1.7
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
- madpatrick
- Member
- Posts: 107
- Joined: Wed Dec 06, 2017 9:52 pm
- Location: Zuid-Holland
Re: Controlling Toon via Domoticz
Sure,
Please be aware for the Uservariables etc..... I've changed the names to more logical names
Also i've extended the script with more functionalities. If you do not needed them you can comment them out (or delete)
Toon_script
Toon_setpoint
Please be aware for the Uservariables etc..... I've changed the names to more logical names
Also i've extended the script with more functionalities. If you do not needed them you can comment them out (or delete)
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
}
Code: Select all
UV_P1SmartMeterGasMeterStand,String,P1 Gas
UV_P1SmartMeterElectra,String,P1 Elektra
UV_ToonBoilerModulation,String,ModulationLevel
UV_ToonBoilerPressure,String,Keteldruk
UV_ToonBoilerTempOut,String,Ketel Temp UIT
UV_ToonBoilerTempIn,String,Ketel Temp IN
UV_ToonBurnerName,String,Ketelstand
UV_ToonBoilerTempSetpoint,String,Ketel Setpoint
UV_DomoticzIP,String,192.168.1.1:9200
UV_ToonProgramInformation,String,Toon Information
UV_ToonAutoProgram,String,Toon Auto Program
UV_ToonScenes,String,Toon Scenes
UV_ToonTemperature,String,Temperatuur Kamer
UV_ToonIP,String,192.168.1.200
UV_ToonThermostat,String,Toon Thermostaat
Last edited by madpatrick on Mon Jul 27, 2020 10:32 am, edited 2 times in total.
Re: Controlling Toon via Domoticz
[quote="madpatrick"]Sure,
Please be aware for the Uservariables etc..... I've changed the names to more logical names
Also i've extended the script with more functionalities. If you do not needed them you can comment them out (or delete)
Thanks
Are these DzVents script triggered by device?
Please be aware for the Uservariables etc..... I've changed the names to more logical names
Also i've extended the script with more functionalities. If you do not needed them you can comment them out (or delete)
Thanks
Are these DzVents script triggered by device?
Toon2 with 6.0.2 firmware TSC 2.1.7
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Re: Controlling Toon via Domoticz
I added the 2 scripts as DzVents--> Device.
I don't have any errors now.
But...………
The sensors arent's updated every minute...
I don't have any errors now.
But...………
The sensors arent's updated every minute...
Toon2 with 6.0.2 firmware TSC 2.1.7
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
- madpatrick
- Member
- Posts: 107
- Joined: Wed Dec 06, 2017 9:52 pm
- Location: Zuid-Holland
Re: Controlling Toon via Domoticz
Mine is running as : All. This will not make much difference.Xavier wrote:I added the 2 scripts as DzVents--> Device.
I don't have any errors now.
But...………
The sensors arent's updated every minute...
Not sure why it is not updating every minute.
Is the log file telling you anything. Change the setting of you logging to debug, so you can see more info
Re: Controlling Toon via Domoticz
This is what my log files tells about the script:madpatrick wrote:Mine is running as : All. This will not make much difference.Xavier wrote:I added the 2 scripts as DzVents--> Device.
I don't have any errors now.
But...………
The sensors arent's updated every minute...
Not sure why it is not updating every minute.
Is the log file telling you anything. Change the setting of you logging to debug, so you can see more info
2019-09-05 20:26:00.289 Status: dzVents: Debug: Event triggers:
2019-09-05 20:26:00.289 Status: dzVents: Debug: - Timer
2019-09-05 20:26:00.370 Status: dzVents: Info: -=# P1 Toon #=-: ------ Start internal script: Toon_script:, trigger: every minute
2019-09-05 20:26:00.461 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for ToonThermostat: Thermostat setpoint device adapter
2019-09-05 20:26:00.462 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for ToonTemperature: Temperature device adapter
2019-09-05 20:26:00.463 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for ToonScenes: Switch device adapter
2019-09-05 20:26:00.465 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for ToonAutoProgram: Switch device adapter
2019-09-05 20:26:00.465 Status: dzVents: Info: -=# P1 Toon #=-: ------ Finished Toon_script
So no errors and also no updates in the devices in Domoticz.
I adjusted the User variables like in the script...
Toon2 with 6.0.2 firmware TSC 2.1.7
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
- madpatrick
- Member
- Posts: 107
- Joined: Wed Dec 06, 2017 9:52 pm
- Location: Zuid-Holland
Re: Controlling Toon via Domoticz
hmmm... script is indeed running, but not all sensors are set.
Looks like it is running, but not needs to update anything. Try to change values and watch if this updates Toon or Domoticz
This how it looks at my server.
Looks like it is running, but not needs to update anything. Try to change values and watch if this updates Toon or Domoticz
This how it looks at my server.
Code: Select all
2019-09-05 20:45:00.363 Status: dzVents: Info: -=# P1 Toon #=-: ------ Start internal script: Toon_script:, trigger: every minute
2019-09-05 20:45:00.456 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for P1 Elektra: P1 smart meter energy device adapter
2019-09-05 20:45:00.456 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for P1 Gas: Gas device adapter
2019-09-05 20:45:00.457 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Ketel Temp IN: Temperature device adapter
2019-09-05 20:45:00.457 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Ketel Temp UIT: Temperature device adapter
2019-09-05 20:45:00.458 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Keteldruk: Pressure device adapter
2019-09-05 20:45:00.458 Status: dzVents: Info: -=# P1 Toon #=-: Updating Boiler Pressure to current value: 1.8
2019-09-05 20:45:00.458 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Ketelstand: Switch device adapter
2019-09-05 20:45:00.458 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for ModulationLevel: Percentage device adapter
2019-09-05 20:45:00.458 Status: dzVents: Info: -=# P1 Toon #=-: Updating the Modulation sensor to new value: 59
2019-09-05 20:45:00.459 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Ketel Setpoint: Temperature device adapter
2019-09-05 20:45:00.459 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Toon Thermostaat: Thermostat setpoint device adapter
2019-09-05 20:45:00.459 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Temperatuur Kamer: Temperature device adapter
2019-09-05 20:45:00.460 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Toon Scenes: Switch device adapter
2019-09-05 20:45:00.460 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Toon Auto Program: Switch device adapter
2019-09-05 20:45:00.460 Status: dzVents: Info: -=# P1 Toon #=-: ------ Finished Toon_script
2019-09-05 20:45:00.460 Status: dzVents: Debug: Commands sent to Domoticz:
2019-09-05 20:45:00.460 Status: dzVents: Debug: - UpdateDevice = {["sValue"]="4637934;4091792;814641;2229366;801;0", ["idx"]=302, ["nValue"]=0}
2019-09-05 20:45:00.461 Status: dzVents: Debug: - UpdateDevice = {["sValue"]="3617237", ["idx"]=300, ["nValue"]=0}
2019-09-05 20:45:00.461 Status: dzVents: Debug: - UpdateDevice = {["sValue"]="1.8", ["idx"]=262, ["nValue"]=0}
2019-09-05 20:45:00.461 Status: dzVents: Debug: - UpdateDevice = {["sValue"]="59", ["_trigger"]=true, ["idx"]=311, ["nValue"]=0}
2019-09-05 20:45:00.461 Status: dzVents: Debug: =====================================================
Re: Controlling Toon via Domoticz
Ok, I'm going to copy your entire script.madpatrick wrote:hmmm... script is indeed running, but not all sensors are set.
Looks like it is running, but not needs to update anything. Try to change values and watch if this updates Toon or Domoticz
This how it looks at my server.
Code: Select all
2019-09-05 20:45:00.363 Status: dzVents: Info: -=# P1 Toon #=-: ------ Start internal script: Toon_script:, trigger: every minute 2019-09-05 20:45:00.456 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for P1 Elektra: P1 smart meter energy device adapter 2019-09-05 20:45:00.456 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for P1 Gas: Gas device adapter 2019-09-05 20:45:00.457 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Ketel Temp IN: Temperature device adapter 2019-09-05 20:45:00.457 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Ketel Temp UIT: Temperature device adapter 2019-09-05 20:45:00.458 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Keteldruk: Pressure device adapter 2019-09-05 20:45:00.458 Status: dzVents: Info: -=# P1 Toon #=-: Updating Boiler Pressure to current value: 1.8 2019-09-05 20:45:00.458 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Ketelstand: Switch device adapter 2019-09-05 20:45:00.458 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for ModulationLevel: Percentage device adapter 2019-09-05 20:45:00.458 Status: dzVents: Info: -=# P1 Toon #=-: Updating the Modulation sensor to new value: 59 2019-09-05 20:45:00.459 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Ketel Setpoint: Temperature device adapter 2019-09-05 20:45:00.459 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Toon Thermostaat: Thermostat setpoint device adapter 2019-09-05 20:45:00.459 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Temperatuur Kamer: Temperature device adapter 2019-09-05 20:45:00.460 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Toon Scenes: Switch device adapter 2019-09-05 20:45:00.460 Status: dzVents: Debug: -=# P1 Toon #=-: Processing device-adapter for Toon Auto Program: Switch device adapter 2019-09-05 20:45:00.460 Status: dzVents: Info: -=# P1 Toon #=-: ------ Finished Toon_script 2019-09-05 20:45:00.460 Status: dzVents: Debug: Commands sent to Domoticz: 2019-09-05 20:45:00.460 Status: dzVents: Debug: - UpdateDevice = {["sValue"]="4637934;4091792;814641;2229366;801;0", ["idx"]=302, ["nValue"]=0} 2019-09-05 20:45:00.461 Status: dzVents: Debug: - UpdateDevice = {["sValue"]="3617237", ["idx"]=300, ["nValue"]=0} 2019-09-05 20:45:00.461 Status: dzVents: Debug: - UpdateDevice = {["sValue"]="1.8", ["idx"]=262, ["nValue"]=0} 2019-09-05 20:45:00.461 Status: dzVents: Debug: - UpdateDevice = {["sValue"]="59", ["_trigger"]=true, ["idx"]=311, ["nValue"]=0} 2019-09-05 20:45:00.461 Status: dzVents: Debug: =====================================================
Could you make a screenshot of your UV's? So I can exactly copy these also.
Though I'm not using al UV's or Sensors btw.
After al these UV's do I also need to create virtual devices?
Toon2 with 6.0.2 firmware TSC 2.1.7
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
- madpatrick
- Member
- Posts: 107
- Joined: Wed Dec 06, 2017 9:52 pm
- Location: Zuid-Holland
Re: Controlling Toon via Domoticz
Here there are.
Your devices needs to have the exact same names as in the UV
I have used spaces between some device names to make it better readable, but for programmers of course a "no go"
Your devices needs to have the exact same names as in the UV
I have used spaces between some device names to make it better readable, but for programmers of course a "no go"

- UV_P1SmartMeterGasMeterStand,String,P1 Gas
UV_P1SmartMeterElectra,String,P1 Elektra
UV_ToonBoilerModulation,String,ModulationLevel
UV_ToonBoilerPressure,String,Keteldruk
UV_ToonBoilerTempOut,String,Ketel Temp UIT
UV_ToonBoilerTempIn,String,Ketel Temp IN
UV_ToonBurnerName,String,Ketelstand
UV_ToonBoilerTempSetpoint,String,Ketel Setpoint
UV_DomoticzIP,String,192.168.1.1:9200
UV_ToonProgramInformation,String,Toon Information
UV_ToonAutoProgram,String,Toon Auto Program
UV_ToonScenes,String,Toon Scenes
UV_ToonTemperature,String,Temperatuur Kamer
UV_ToonIP,String,192.168.1.200
UV_ToonThermostat,String,Toon Thermostaat
Re: Controlling Toon via Domoticz
ok so these are my UV's:
Variable name Variable type Current value
UV_ToonBurnerName String Ketelstand
UV_P1SmartMeterElectra String P1 Elektra
UV_P1SmartMeterGasMeterStand String P1 Gas
UV_DomoticzIP String 192.168.0.200:8084
SendtoToon String 0
ShowDoorCamToon String 150
UV_ToonProgramInformation String Toon Information
UV_ToonAutoProgram String Toon Auto Program
UV_ToonScenes String Toon Scenes
UV_ToonTemperature String Temperatuur Kamer
UV_ToonThermostat String Toon Thermostaat
UV_ToonIP String 192.168.0.23
I skipped the boiler UV's
This is my script:
This is the error I get:
2019-09-05 22:06:00.474 Status: dzVents: Error (2.4.19): -=# P1 Toon #=-: ...cz/var/scripts/dzVents/generated_scripts/Toon_script.lua:51: attempt to index field 'dev_24' (a nil value)
and this is the export of the command http://192.168.0.23/hdrv_zwave?action=getDevices.json
And this is the export of command http://192.168.0.23/happ_thermstat?acti ... mostatInfo
and also a screenshot of my toon devices
Variable name Variable type Current value
UV_ToonBurnerName String Ketelstand
UV_P1SmartMeterElectra String P1 Elektra
UV_P1SmartMeterGasMeterStand String P1 Gas
UV_DomoticzIP String 192.168.0.200:8084
SendtoToon String 0
ShowDoorCamToon String 150
UV_ToonProgramInformation String Toon Information
UV_ToonAutoProgram String Toon Auto Program
UV_ToonScenes String Toon Scenes
UV_ToonTemperature String Temperatuur Kamer
UV_ToonThermostat String Toon Thermostaat
UV_ToonIP String 192.168.0.23
I skipped the boiler UV's
This is my 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 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
-- Handle json
local json = assert(loadfile "/usr/local/domoticz/var/scripts/lua/JSON.lua")() -- For Linux
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
-- 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_32.CurrentElectricityFlow ) --stroomverbruik momenteel hoogtarief
local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_33.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_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 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 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
}
2019-09-05 22:06:00.474 Status: dzVents: Error (2.4.19): -=# P1 Toon #=-: ...cz/var/scripts/dzVents/generated_scripts/Toon_script.lua:51: attempt to index field 'dev_24' (a nil value)
and this is the export of the command http://192.168.0.23/hdrv_zwave?action=getDevices.json
Code: Select all
{"dev_settings_device": {"uuid": "eneco-001-033034:hdrv_zwave_68323C61D44", "name": "settings_device", "internalAddress": "settings_device", "type": "settings_device"}, "dev_3": {"uuid": "47d46ba4-6431-4fc7-afb1-abae68a34e0b", "name": "HAE_METER_v3", "internalAddress": "3", "type": "HAE_METER_v3", "supportsCrc": "1", "ccList": "5e 86 72 32 56 5a 59 85 73 7a 60 8e 22 70 8b 3c 3d 3e", "supportedCC": "5e 86 72 32 56 5a 59 85 73 7a 60 8e 22 70 8b 3c 3d 3e", "nodeFlags": [], "IsConnected": "1", "HealthValue": "10", "DeviceName": "HAE_METER_v3", "CurrentSensorStatus": "UNKNOWN"}, "dev_3.1": {"uuid": "7b3dbdf2-b5f9-4000-a7ac-351d1c9158a0", "name": "HAE_METER_v3_1", "internalAddress": "3.1", "type": "HAE_METER_v3_1", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentGasFlow": "0.00", "CurrentGasQuantity": "7701224.00", "DeviceName": "HAE_METER_v3_1", "CurrentSensorStatus": "OPERATIONAL"}, "dev_3.2": {"uuid": "63fe0cac-580e-4180-a280-0223f0a920ca", "name": "HAE_METER_v3_2", "internalAddress": "3.2", "type": "HAE_METER_v3_2", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "DeviceName": "HAE_METER_v3_2", "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "NaN", "CurrentSensorStatus": "UNKNOWN"}, "dev_3.3": {"uuid": "4408c198-7278-4e71-bee6-fbd7c57cb1cc", "name": "HAE_METER_v3_3", "internalAddress": "3.3", "type": "HAE_METER_v3_3", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "DeviceName": "HAE_METER_v3_3", "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "NaN", "CurrentSensorStatus": "UNKNOWN"}, "dev_3.4": {"uuid": "478dde7d-3a02-48f9-a0ee-8d942cdc4817", "name": "HAE_METER_v3_4", "internalAddress": "3.4", "type": "HAE_METER_v3_4", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "DeviceName": "HAE_METER_v3_4", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "20296879.00", "CurrentSensorStatus": "OPERATIONAL"}, "dev_3.5": {"uuid": "0e4cbf58-e007-4ae9-8609-05126f820d52", "name": "HAE_METER_v3_5", "internalAddress": "3.5", "type": "HAE_METER_v3_5", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "DeviceName": "HAE_METER_v3_5", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "0.00", "CurrentSensorStatus": "OPERATIONAL"}, "dev_3.6": {"uuid": "38392b4b-1539-4dba-a941-7b7a3939062d", "name": "HAE_METER_v3_6", "internalAddress": "3.6", "type": "HAE_METER_v3_6", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "DeviceName": "HAE_METER_v3_6", "CurrentElectricityFlow": "680.00", "CurrentElectricityQuantity": "25484213.00", "CurrentSensorStatus": "OPERATIONAL"}, "dev_3.7": {"uuid": "751d5db8-cde3-4ca2-b523-89b803d658ac", "name": "HAE_METER_v3_7", "internalAddress": "3.7", "type": "HAE_METER_v3_7", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "DeviceName": "HAE_METER_v3_7", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "0.00", "CurrentSensorStatus": "OPERATIONAL"}, "dev_3.8": {"uuid": "e175060d-1387-487f-b2b3-eb3042f6afcc", "name": "HAE_METER_v3_8", "internalAddress": "3.8", "type": "HAE_METER_v3_8", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "DeviceName": "HAE_METER_v3_8", "CurrentHeatQuantity": "NaN", "CurrentSensorStatus": "UNKNOWN"}}
Code: Select all
{"result":"ok", "currentTemp":"2389", "currentSetpoint":"1000", "currentInternalBoilerSetpoint":"6", "programState":"1", "activeState":"2", "nextProgram":"1", "nextState":"3", "nextTime":"1567740600","nextSetpoint":"1000","randomConfigId":"1804289383","errorFound":"255","connection":"0","burnerInfo":"0","otCommError":"0","currentModulationLevel":"0"}
- Attachments
-
- domoticz-toon-devices (1).png (82.1 KiB) Viewed 12536 times
Toon2 with 6.0.2 firmware TSC 2.1.7
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Re: Controlling Toon via Domoticz
After modifying the the Variable value in the User Variable, I got it fixed.
Also seeying that the updates are set in the devices.
So now everything is ok.
Thanks @madpatrick for all your information and patience with me!
Also seeying that the updates are set in the devices.
So now everything is ok.
Thanks @madpatrick for all your information and patience with me!
Toon2 with 6.0.2 firmware TSC 2.1.7
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
Apps: Sonos, Calender, garbagecalender, webcam, doorcam, Onkyo, Domoticzboard, Solar and weather app.
- madpatrick
- Member
- Posts: 107
- Joined: Wed Dec 06, 2017 9:52 pm
- Location: Zuid-Holland
Re: Controlling Toon via Domoticz
I'm glad it is workingXavier wrote:After modifying the the Variable value in the User Variable, I got it fixed.
Also seeying that the updates are set in the devices.
So now everything is ok.
Thanks @madpatrick for all your information and patience with me!

Re: Controlling Toon via Domoticz
I have followed the manual and added the changed scripts of MadPatrick, however I am getting the following errors in my Log:
Any help would be appreciated , I did update the variables to match the script.
Code: Select all
2019-10-16 22:33:03.133 Error: EventSystem: in Toon: [string "return { ..."]:3: attempt to index global 'domoticz' (a nil value)
2019-10-16 22:33:03.141 Error: EventSystem: Lua script ToonSetpoint did not return a commandArray
2019-10-16 22:33:03.146 Error: EventSystem: in Toon: [string "return { ..."]:3: attempt to index global 'domoticz' (a nil value)
2019-10-16 22:33:03.152 Error: EventSystem: Lua script ToonSetpoint did not return a commandArray