Page 19 of 22
Re: Controlling Toon [HACKED] from Domoticz
Posted: Wednesday 29 July 2020 13:59
by Jasper79
Then I might be doing something wrong again.
The energy usage is much more than I really did.

- Screenshot_20200729-135703_Chrome.png (319.31 KiB) Viewed 1835 times

- Screenshot_20200729-135653_Chrome.png (399.46 KiB) Viewed 1835 times
Maybe I'm using the solar data instead or it's calculated the other way round instead.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Wednesday 29 July 2020 20:11
by madpatrick
This is the screenshot of my P1 meter

Re: Controlling Toon [HACKED] from Domoticz
Posted: Friday 31 July 2020 12:58
by Jasper79
I also have Solaredge though the api plugin does not show me the current watts.
Today I deleted all UV's and devices because it still wasn't showing like your screenshot.
Added them all back from the link you provided earlier and now I do have some values now and will have to wait to see if it will be okay.
For now it does not show any electricity usage or delivery form the solar pannels.
For the missing items in the Solaredge API I wil search for the topic and ask there.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Friday 31 July 2020 22:22
by Jasper79
Watching the graph today tells me that I still have the wrong date.
If it wasn't for the solar panels I would have the right data, now during sunshine I have a flat line, and when sundown it show the right amount.
So probably I'm reading bought energy only instead of the used energy.
To get this right I think I need another set of data coming from the Toon Zon meter adapter.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Saturday 01 August 2020 13:37
by Jasper79
Just received a wemos shield for reading the meter values directly so think I'll go that way.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Thursday 13 August 2020 9:47
by StevenHoogslag
Hello Jasper,
Do you have Wemos hardware for access to Toon (version 2020) data or slimme meter data?
Re: Controlling Toon [HACKED] from Domoticz
Posted: Thursday 13 August 2020 9:53
by Jasper79
Right now I'm using a wemos to read P1 data instead of the Toon data.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Friday 11 September 2020 9:11
by senadj
Followed the NL manual. I now have an error:
2020-09-11 12:44:13.602 Error: EventSystem: problem writing file: C:\Program Files (x86)\Domoticz\scripts\dzVents\generated_scripts\Toon Setpoint.lua
2020-09-11 12:44:13.617 Error: EventSystem: problem writing file: C:\Program Files (x86)\Domoticz\scripts\dzVents\generated_scripts\Toon.lua
What am I doing wrong?
I can now only operate Toon Scenes. The rest will not work.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Wednesday 07 October 2020 14:04
by Jasper79
I can control Toon from Domoticz though I'd like to expand the features.
What I would like is that when the temperature is manually changed a timer should start and after 30 min the auto program is set again.
I created a blockly which does nothing whatever I tried.

- Toon auto.png (16.41 KiB) Viewed 1557 times
Even the log part doesn't show up.
I tried the 30% and also number 30 as well as text Tijdelijk and I can't find the script running.
Used Device and Timer.
Some help please,.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Wednesday 07 October 2020 17:37
by Jasper79
5 seconds are for testing of course, so I don't have to wait for half an hour

Re: Controlling Toon [HACKED] from Domoticz
Posted: Friday 09 October 2020 10:13
by Jasper79
Been trying some more .
When I have a dummy switch and the Toon Scene at 50% the dummy does not turn on.
When swapping the dummy switch to trigger and the scene as set the scene changes when triggering the switch.
Why can't the scene work as a trigger?

- Toon auto test.png (5.99 KiB) Viewed 1533 times
Re: Controlling Toon [HACKED] from Domoticz
Posted: Thursday 15 October 2020 16:24
by Larsoss
Hello,
Since this morning (while I was working) I keep getting these messages.
So I haven't changed anything, and I would like your help to diagnose and fix the problem.
What can I try?
2020-10-15 16:21:00.682 Error: dzVents: Error: (3.0.2) -=# P1 Toon #=-: An error occurred when calling event handler Toon_script
2020-10-15 16:21:00.682 Error: dzVents: Error: (3.0.2) -=# P1 Toon #=-: ...moticz/scripts/dzVents/generated_scripts/Toon_script.lua:68: attempt to perform arithmetic on a nil value (local 'CurrentElectricityFlowLaag')
I also quickly restored a backup DB from 2 days ago, but even then I immediately get the message ..
Domoticz version = 2020.2 and Toon (root) version is 5.33.9
Re: Controlling Toon [HACKED] from Domoticz
Posted: Thursday 15 October 2020 17:02
by waaren
Larsoss wrote: ↑Thursday 15 October 2020 16:24
2020-10-15 16:21:00.682 Error: dzVents: Error: (3.0.2) -=# P1 Toon #=-: An error occurred when calling event handler Toon_script
2020-10-15 16:21:00.682 Error: dzVents: Error: (3.0.2) -=# P1 Toon #=-: ...moticz/scripts/dzVents/generated_scripts/Toon_script.lua:68: attempt to perform arithmetic on a nil value (local 'CurrentElectricityFlowLaag')
There are quite a number of versions flying around on this and other fora. So please share the script you use now.
Generally speaking debugging start with switch the log to debug. In most dzVents scripts you can do that by changing domoticz.LOG_INFO or domoticz.LOG_ERROR to domoticz.LOG_DEBUG in the logging section.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Thursday 15 October 2020 17:16
by Larsoss
Probably found it already. I pulled my cables out of the P1 meter 1x, and then plugged them in again.
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
-- json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- test
-- 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://192.168.1.120/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 == 22 then currentActiveState = 40 -- Comfort
elseif currentActiveTemp == 20 then currentActiveState = 30 -- Home
elseif currentActiveTemp == 18.5 then currentActiveState = 20 -- Sleep
elseif currentActiveTemp == 16 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
}
Re: Controlling Toon [HACKED] from Domoticz
Posted: Thursday 15 October 2020 17:33
by Jasper79
So far no one has been able figure out how to use the program state as trigger?
Re: Controlling Toon [HACKED] from Domoticz
Posted: Thursday 15 October 2020 20:06
by madpatrick
Jasper79 wrote: ↑Thursday 15 October 2020 17:33
So far no one has been able figure out how to use the program state as trigger?
Hi Jasper79,
I don't understand your question exactly
With the script you can use the program state of Toon back and forth
It uses the command "currentProgramState" which is able to use.
Re: Controlling Toon [HACKED] from Domoticz
Posted: Thursday 15 October 2020 20:18
by Jasper79
Well I posted a Blockly a few posts up and that doesn't trigger (changes of state trigger a dummy switch) , also it doesn't show up on the logs.
When reversing the entire script it does work. (click on the dummy switch changes the toon status)
Edit,
Forget everything above,
I'll tell you what I was trying to achieve.
My daughter sometimes bumps the temperature to far above the program setpoint which has the state "tijdelijk" Then the heating turns on and it will most likely not reach a setpoint of 25c.
So what I want is that the Toon goes back to the normal program and lowers the setpoint.
What I was trying is when state is tijdelijk set state to follow program after 30min (when testing I used 5 seconds)
Re: Controlling Toon [HACKED] from Domoticz
Posted: Friday 16 October 2020 14:56
by madpatrick
Jasper79 wrote: ↑Thursday 15 October 2020 20:18
Well I posted a Blockly a few posts up and that doesn't trigger (changes of state trigger a dummy switch) , also it doesn't show up on the logs.
When reversing the entire script it does work. (click on the dummy switch changes the toon status)
Edit,
Forget everything above,
I'll tell you what I was trying to achieve.
My daughter sometimes bumps the temperature to far above the program setpoint which has the state "tijdelijk" Then the heating turns on and it will most likely not reach a setpoint of 25c.
So what I want is that the Toon goes back to the normal program and lowers the setpoint.
What I was trying is when state is tijdelijk set state to follow program after 30min (when testing I used 5 seconds)
Jasper
I'm not a programming expert, but this could be workaround
You must not need set the trigger on % level, but on the name of the level

When i try this is a message in my log (which indicates the trigger works)
The setpoint can work the same
Re: Controlling Toon [HACKED] from Domoticz
Posted: Friday 16 October 2020 16:40
by Jasper79
It just refuses to work with the Toon switches as trigger.
Problem is in the IF part because when using a dummy switch for that the rest works fine.

- Toon on Tijdelijk script.png (25.11 KiB) Viewed 1421 times

- Toon on Tijdelijk.png (67.89 KiB) Viewed 1421 times
Re: Controlling Toon [HACKED] from Domoticz
Posted: Friday 16 October 2020 18:41
by madpatrick
What options do you have under the switch “ToonAutoProgram” ?
Can you give screenshot as i’ve posted of the switch