Controlling Toon [HACKED] from Domoticz

For heating/cooling related questions in Domoticz

Moderator: leecollings

User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

Alxxx wrote: Friday 19 February 2021 14:15
madpatrick wrote: Thursday 18 February 2021 20:28 If you want have a easy setup you better can you this plugin
viewtopic.php?f=34&t=34986

Otherwise if you to use this script, you need to give more information.
Check all names and uservariables in detail. A misspell is easy made
u am trying to use the script i checked the uservariables for at least 10 times made 2 times form scratch new settings.
but the temperature will not show the signal to the toon like home,comfort,away, manual are working OK
Which version of the script are you using.
There are several version floating on the forum or in this tread.
Try to check each function each time.
If one is working go to the other.

What is your log telling you ?

for your convenience, this is my script.

Code: Select all

	local scriptVersion = 'Versie 1.03 '
	local scriptVar     = '-=# TOON Script #=-'

return {
        on      = { timer = {'every minute'},
        },
logging = { level  = domoticz.LOG_ERROR,
       		marker = scriptVar },

execute = function(domoticz)
        local ToonThermostat        = 'Toon Thermostaat'                                       --   Sensor showing setpoint
        local ToonTemperature       = 'Temperatuur Kamer'                                      --   Sensor showing room temperature
        local ToonAutoProgram       = 'Toon Auto Program'                                      --   Sensor showing auto program status
        local ToonBoilerModulation  = 'ModulationLevel'                                        -- * Sensor showing Boiler Modulation
        local ToonScenes            = 'Toon Scenes'                                            -- * Sensor showing program
        local ToonBoilerSetpoint    = 'Ketel Setpoint'                                         -- * Sensor showing boiler temperature set point
        local ToonBoilerTempIn      = 'Ketel Temp IN'                                          -- * Sensor showing water temp return
        local ToonBoilerTempOut     = 'Ketel Temp UIT'                                         -- * Sensor showing water temp out
        local ToonBoilerPressure    = 'Keteldruk'                                              --   Sensor showing boilerpressure
        local ToonBurnerName        = 'Ketelstand'                                             --   Sensor showing boiler modus
        local P1SmartMeterPower     = 'P1 Elektra'                                             --   Sensor Energy consumption
        local P1SmartMeterGas1      = 'P1 Gas'                                                 --   Sensor Gas consumption
        local ToonIP                = '192.168.1.200'                                          -- IP address of your Toon
        local DomoticzIP            = '192.168.1.1:9200'                                       -- IP address and portnumber of your Domoticz server
        local SetPointAway          = 18.5                                                     -- temperature of setpoint Away
        local SetPointSleep         = 17.0                                                     -- temperature of setpoint Sleep
        local SetPointHome          = 20.0                                                     -- temperature of setpoint Home
        local SetPointComfort       = 20.5                                                     -- temperature of setpoint Comfort
    
-- 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 CurrentElectricityDeliveredFlowHoog   = tonumber(jsonGasPower.dev_25.CurrentElectricityFlow)                      --stroomgeleverd momenteel laagtarief
        local CurrentElectricityDeliveredFlowLaag   = tonumber(jsonGasPower.dev_27.CurrentElectricityFlow)                      --stroomgeleverd momenteel hoogtarief
         
        local PowerConsumption                      = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag                   --stroomverbruik totaal aktueel
        local PowerProduction                       = CurrentElectricityDeliveredFlowHoog + CurrentElectricityDeliveredFlowLaag --stroomverbruik totaal geleverd
        
                --USAGE1= energy usage meter tariff 1
                --USAGE2= energy usage meter tariff 2
                --RETURN1= energy return meter tariff 1
                --RETURN2= energy return meter tariff 2
                --CONS= actual usage power (Watt)
                --PROD= actual return power (Watt)
                --updateP1(usage1, usage2, return1, return2, cons, prod): Function. Updates the device. Supports command options. 
        domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, PowerConsumption, PowerProduction).silent()
      domoticz.log('P1 : Meter Verbruik laagtarief  : ' .. CurrentElectricityQuantityLaag/1000 .. ' kWh ', domoticz.LOG_FORCE)
      domoticz.log('P1 : Meter Verbruik hoogtarief  : ' .. CurrentElectricityQuantityHoog/1000 .. ' kWh', domoticz.LOG_FORCE)
      domoticz.log('P1 : Meter Levering laagtarief  : ' .. CurrentElectricityDeliveredLaag/1000 .. ' kWh', domoticz.LOG_FORCE)
      domoticz.log('P1 : Meter Levering hoogtarief  : ' .. CurrentElectricityDeliveredHoog/1000 .. ' kWh', domoticz.LOG_FORCE)
    
        domoticz.log('P1 : Huidig Stroom Verbruik     : ' .. PowerConsumption .. ' W', domoticz.LOG_FORCE)
        domoticz.log('P1 : Huidig Stroom Opbrengst    : ' .. PowerProduction .. ' W', domoticz.LOG_FORCE)

-- Update the gasconsumption
        local CurrentGasFlow                   = tonumber(jsonGasPower.dev_21.CurrentGasFlow)
        local CurrentGasQuantity               = tonumber(jsonGasPower.dev_21.CurrentGasQuantity)
        domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()   

-- 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('Update van de CV-water temperatuur IN: ' ..currentboilerInTemp .. ' °C',domoticz.LOG_INFO)
  --         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('Update van de CV-water temperatuur UIT : ' ..currentboilerOutTemp .. ' °C',domoticz.LOG_INFO)
 --           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).sValue,1) ~= domoticz.utils.round(currentBoilerPressure,1) then
           domoticz.log('Update van de waterdruk : ' ..currentBoilerPressure .. ' bar',domoticz.LOG_FORCE)
           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)
        
-- Update the current scene by temperature
		local currentActiveTemp = tonumber(jsonThermostatInfo.currentSetpoint) / 100

                    if currentActiveState == 0 or currentActiveTemp == SetPointComfort  then currentActiveState = 40     -- Comfort
                elseif currentActiveState == 1 or currentActiveTemp == SetPointHome     then currentActiveState = 30     -- Home
                elseif currentActiveState == 2 or currentActiveTemp == SetPointSleep    then currentActiveState = 20     -- Sleep
                elseif currentActiveState == 3 or currentActiveTemp == SetPointAway     then currentActiveState = 10     -- Away
                elseif currentActiveState == -1 then currentActiveState = 50 -- Manual                    
                    
                --domoticz.log('Update Toon scene door temperature of Scene wijziging : ' ..currentActiveState,domoticz.LOG_FORCE)
            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('Update van de ketelstand: ' ..currentBurnerInfo,domoticz.LOG_FORCE)
            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('Update van de Modulatie stand: ' ..currentModulationLevel .. ' %',domoticz.LOG_FORCE)
            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('Update van het ketelwater temperatuur setpunt: ' ..currentInternalBoilerSetpoint .. ' °C',domoticz.LOG_FORCE)
            domoticz.devices(ToonBoilerSetpoint).updateTemperature(currentInternalBoilerSetpoint)
        end
        
-- Update the thermostat sensor to current setpoint
        if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then
            domoticz.log('Update van de temperatuur instelling naar: ' ..currentSetpoint .. ' °C',domoticz.LOG_FORCE)
            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('Update van de kamertemparatuur : ' ..currentTemperature .. ' °C',domoticz.LOG_FORCE)
            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('Update van de Toon Scene : '..currentActiveState,domoticz.LOG_FORCE)
            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('Update van het Toon Auto Program : '..currentProgramState,domoticz.LOG_FORCE)
 --           domoticz.devices(ToonAutoProgram).switchSelector(currentProgramState).silent()
 --       end
        
   end
}
Adjust it to your system
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
Alxxx
Posts: 3
Joined: Monday 04 March 2019 19:30
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.9700
Location: Holland
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Alxxx »

madpatrick wrote: Friday 19 February 2021 14:22
Alxxx wrote: Friday 19 February 2021 14:15
madpatrick wrote: Thursday 18 February 2021 20:28 If you want have a easy setup you better can you this plugin
viewtopic.php?f=34&t=34986

Otherwise if you to use this script, you need to give more information.
Check all names and uservariables in detail. A misspell is easy made
u am trying to use the script i checked the uservariables for at least 10 times made 2 times form scratch new settings.
but the temperature will not show the signal to the toon like home,comfort,away, manual are working OK
Which version of the script are you using.
There are several version floating on the forum or in this tread.
Try to check each function each time.
If one is working go to the other.

What is your log telling you ?

for your convenience, this is my script.

Code: Select all

	local scriptVersion = 'Versie 1.03 '
	local scriptVar     = '-=# TOON Script #=-'

return {
        on      = { timer = {'every minute'},
        },
logging = { level  = domoticz.LOG_ERROR,
       		marker = scriptVar },

execute = function(domoticz)
        local ToonThermostat        = 'Toon Thermostaat'                                       --   Sensor showing setpoint
        local ToonTemperature       = 'Temperatuur Kamer'                                      --   Sensor showing room temperature
        local ToonAutoProgram       = 'Toon Auto Program'                                      --   Sensor showing auto program status
        local ToonBoilerModulation  = 'ModulationLevel'                                        -- * Sensor showing Boiler Modulation
        local ToonScenes            = 'Toon Scenes'                                            -- * Sensor showing program
        local ToonBoilerSetpoint    = 'Ketel Setpoint'                                         -- * Sensor showing boiler temperature set point
        local ToonBoilerTempIn      = 'Ketel Temp IN'                                          -- * Sensor showing water temp return
        local ToonBoilerTempOut     = 'Ketel Temp UIT'                                         -- * Sensor showing water temp out
        local ToonBoilerPressure    = 'Keteldruk'                                              --   Sensor showing boilerpressure
        local ToonBurnerName        = 'Ketelstand'                                             --   Sensor showing boiler modus
        local P1SmartMeterPower     = 'P1 Elektra'                                             --   Sensor Energy consumption
        local P1SmartMeterGas1      = 'P1 Gas'                                                 --   Sensor Gas consumption
        local ToonIP                = '192.168.1.200'                                          -- IP address of your Toon
        local DomoticzIP            = '192.168.1.1:9200'                                       -- IP address and portnumber of your Domoticz server
        local SetPointAway          = 18.5                                                     -- temperature of setpoint Away
        local SetPointSleep         = 17.0                                                     -- temperature of setpoint Sleep
        local SetPointHome          = 20.0                                                     -- temperature of setpoint Home
        local SetPointComfort       = 20.5                                                     -- temperature of setpoint Comfort
    
-- 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 CurrentElectricityDeliveredFlowHoog   = tonumber(jsonGasPower.dev_25.CurrentElectricityFlow)                      --stroomgeleverd momenteel laagtarief
        local CurrentElectricityDeliveredFlowLaag   = tonumber(jsonGasPower.dev_27.CurrentElectricityFlow)                      --stroomgeleverd momenteel hoogtarief
         
        local PowerConsumption                      = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag                   --stroomverbruik totaal aktueel
        local PowerProduction                       = CurrentElectricityDeliveredFlowHoog + CurrentElectricityDeliveredFlowLaag --stroomverbruik totaal geleverd
        
                --USAGE1= energy usage meter tariff 1
                --USAGE2= energy usage meter tariff 2
                --RETURN1= energy return meter tariff 1
                --RETURN2= energy return meter tariff 2
                --CONS= actual usage power (Watt)
                --PROD= actual return power (Watt)
                --updateP1(usage1, usage2, return1, return2, cons, prod): Function. Updates the device. Supports command options. 
        domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, PowerConsumption, PowerProduction).silent()
      domoticz.log('P1 : Meter Verbruik laagtarief  : ' .. CurrentElectricityQuantityLaag/1000 .. ' kWh ', domoticz.LOG_FORCE)
      domoticz.log('P1 : Meter Verbruik hoogtarief  : ' .. CurrentElectricityQuantityHoog/1000 .. ' kWh', domoticz.LOG_FORCE)
      domoticz.log('P1 : Meter Levering laagtarief  : ' .. CurrentElectricityDeliveredLaag/1000 .. ' kWh', domoticz.LOG_FORCE)
      domoticz.log('P1 : Meter Levering hoogtarief  : ' .. CurrentElectricityDeliveredHoog/1000 .. ' kWh', domoticz.LOG_FORCE)
    
        domoticz.log('P1 : Huidig Stroom Verbruik     : ' .. PowerConsumption .. ' W', domoticz.LOG_FORCE)
        domoticz.log('P1 : Huidig Stroom Opbrengst    : ' .. PowerProduction .. ' W', domoticz.LOG_FORCE)

-- Update the gasconsumption
        local CurrentGasFlow                   = tonumber(jsonGasPower.dev_21.CurrentGasFlow)
        local CurrentGasQuantity               = tonumber(jsonGasPower.dev_21.CurrentGasQuantity)
        domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()   

-- 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('Update van de CV-water temperatuur IN: ' ..currentboilerInTemp .. ' °C',domoticz.LOG_INFO)
  --         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('Update van de CV-water temperatuur UIT : ' ..currentboilerOutTemp .. ' °C',domoticz.LOG_INFO)
 --           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).sValue,1) ~= domoticz.utils.round(currentBoilerPressure,1) then
           domoticz.log('Update van de waterdruk : ' ..currentBoilerPressure .. ' bar',domoticz.LOG_FORCE)
           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)
        
-- Update the current scene by temperature
		local currentActiveTemp = tonumber(jsonThermostatInfo.currentSetpoint) / 100

                    if currentActiveState == 0 or currentActiveTemp == SetPointComfort  then currentActiveState = 40     -- Comfort
                elseif currentActiveState == 1 or currentActiveTemp == SetPointHome     then currentActiveState = 30     -- Home
                elseif currentActiveState == 2 or currentActiveTemp == SetPointSleep    then currentActiveState = 20     -- Sleep
                elseif currentActiveState == 3 or currentActiveTemp == SetPointAway     then currentActiveState = 10     -- Away
                elseif currentActiveState == -1 then currentActiveState = 50 -- Manual                    
                    
                --domoticz.log('Update Toon scene door temperature of Scene wijziging : ' ..currentActiveState,domoticz.LOG_FORCE)
            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('Update van de ketelstand: ' ..currentBurnerInfo,domoticz.LOG_FORCE)
            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('Update van de Modulatie stand: ' ..currentModulationLevel .. ' %',domoticz.LOG_FORCE)
            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('Update van het ketelwater temperatuur setpunt: ' ..currentInternalBoilerSetpoint .. ' °C',domoticz.LOG_FORCE)
            domoticz.devices(ToonBoilerSetpoint).updateTemperature(currentInternalBoilerSetpoint)
        end
        
-- Update the thermostat sensor to current setpoint
        if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then
            domoticz.log('Update van de temperatuur instelling naar: ' ..currentSetpoint .. ' °C',domoticz.LOG_FORCE)
            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('Update van de kamertemparatuur : ' ..currentTemperature .. ' °C',domoticz.LOG_FORCE)
            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('Update van de Toon Scene : '..currentActiveState,domoticz.LOG_FORCE)
            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('Update van het Toon Auto Program : '..currentProgramState,domoticz.LOG_FORCE)
 --           domoticz.devices(ToonAutoProgram).switchSelector(currentProgramState).silent()
 --       end
        
   end
}
Adjust it to your system



I tried the easy plugin but still not working. i Think there is something wrong in basic .The hardware i can choose and install
but there are no devices coming after restart.
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

Alxxx wrote: Friday 19 February 2021 17:10 I tried the easy plugin but still not working. i Think there is something wrong in basic .The hardware i can choose and install
but there are no devices coming after restart.
Check in your settings menu at devices and add them to your system (green arrow)
In dutch : Instellingen/Apparaten en zoek de toegevoegde hardware
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
User avatar
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

Post by EdwinK »

I find this error in the log:

2021-03-21 19:23:00.615 Error: dzVents: Error: (3.1.6) ...e/pi/domoticz/scripts/dzVents/generated_scripts/Toon.lua:73: attempt to index a nil value (global 'jsonBoilerInfo')

This is line 73:

Code: Select all

-- Update the Boiler Water In to current value
         local currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

Which firmware version do you have on your Toon ?

Since firmware 5.39.7 the boiler inlet and outlet temperature has been disabled.
You need to remove these line in the script and remove the devices in your domoticz
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
User avatar
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

Post by EdwinK »

I believe it's 5.22.14.

Removing those lines
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
S10NL
Posts: 12
Joined: Sunday 23 February 2020 19:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by S10NL »

Since some days my log keeps spamming the same error, which i cant figure out:

Code: Select all

2021-04-07 08:51:00.922 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:51:00.922 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:52:00.909 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:52:00.910 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:53:00.885 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:53:00.886 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:54:00.883 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:54:00.884 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:55:01.008 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:55:01.009 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:56:00.951 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:56:00.953 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:57:00.930 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:57:00.930 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:58:01.042 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:58:01.042 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
I've read the posts above and removed the - boilerOutTemp and boilerInTemp variables in the script, but the message keeps spamming the log.
Does anyone know a solution or where to start?

Below my toon script:

Code: Select all

return {
   on = {
      timer = {
         'every minute'
      }
   },
   execute = function(domoticz)
        local ToonThermostat        = domoticz.variables('UV_ToonThermostatSensorName').value -- Sensor showing current setpoint
        local ToonTemperature       = domoticz.variables('UV_ToonTemperatureSensorName').value -- Sensor showing current room temperature
        --local ToonBoilerTempIn      = domoticz.variables('UV_ToonboilerInTempName').value -- Sensor showing water temp return
        --local ToonBoilerTempOut     = domoticz.variables('UV_ToonboilerOutTempName').value -- Sensor showing current water temp out
        local ToonBoilerPressure    = domoticz.variables('UV_ToonboilerPressure').value -- Sensor showing current room temperature
        local ToonBoilerModulation  = domoticz.variables('UV_ToonboilerModulationLevel').value -- Sensor showing current Boiler Modulation
        local ToonScenes            = domoticz.variables('UV_ToonScenesSensorName').value -- Sensor showing current program
        local ToonAutoProgram       = domoticz.variables('UV_ToonAutoProgramSensorName').value -- Sensor showing current auto program status
        local ToonProgramInformation = domoticz.variables('UV_ToonProgramInformationSensorName').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_ToonBoilerTempSetpointSensorName').value  -- Sensor showing current boiler set point water temp out
    
        -- Handle json
        local json = assert(loadfile "/opt/domoticz/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()
        
        -- JSON data from Toon contains a extra "," which should not be there.
        ThermostatInfo = string.gsub(ThermostatInfo, ",}", "}")
        
        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_4.", "dev_4")
--        GasPowerInfo = string.gsub(GasPowerInfo, "dev_4:", "dev_4\":")
        
--        local jsonGasPower = json:decode(GasPowerInfo)
        
       -- domoticz.log(jsonGasPower)
--         local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_44.CurrentElectricityFlow )
--         local CurrentElectricityQuantityHoog = tonumber(jsonGasPower.dev_44.CurrentElectricityQuantity)
--         local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_46.CurrentElectricityFlow )
--         local CurrentElectricityQuantityLaag = tonumber(jsonGasPower.dev_46.CurrentElectricityQuantity)
--         local CurrentGasFlow = tonumber(jsonGasPower.dev_41.CurrentGasFlow)
--         local CurrentGasQuantity = tonumber(jsonGasPower.dev_41.CurrentGasQuantity)
--         local CurrentElectricityQuantity =   CurrentElectricityFlowHoog + CurrentElectricityFlowLaag
--         local CurrentElectricityDeliveredLaag = 0
--         local CurrentElectricityDeliveredHoog = 0
--         local totalDeliveredPower = 0

--        domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, CurrentElectricityQuantity, totalDeliveredPower).silent()
        
--        domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()

-- Update the Boiler Water In to current value
         local currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
        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)
        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)
        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.devices(ToonBoilerPressure).updatePressure(currentBoilerPressure).silent()
        end

        local currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
        local currentTemperature = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
        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      
        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<br>                elseif currentActiveState == 4 then currentActiveState = 60 -- Holiday
            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<br>            
            elseif currentBurnerInfo == 3 then currentBurnerInfo = 10 -- voorverwarmen volgend setpoint
        end
            
        if CurrentToonBurnerValue ~= currentBurnerInfo then  -- Update toon burner selector if it has changed
            -- 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
}
User avatar
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

Post by EdwinK »

deleted as it were some stupid old Lua scripts
Last edited by EdwinK on Wednesday 07 April 2021 9:45, edited 1 time in total.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
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

Post by EdwinK »

@S10NL Guess what. I now tried your version, and that is working. Strange.

Edit: alright, some small issue

2021-04-07 09:43:00.615 Error: dzVents: Error: (3.1.7) ...e/pi/domoticz/scripts/dzVents/generated_scripts/Toon.lua:8: attempt to index a nil value
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
S10NL
Posts: 12
Joined: Sunday 23 February 2020 19:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by S10NL »

S10NL wrote: Wednesday 07 April 2021 9:00 Since some days my log keeps spamming the same error, which i cant figure out:

Code: Select all

2021-04-07 08:51:00.922 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:51:00.922 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:52:00.909 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:52:00.910 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:53:00.885 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:53:00.886 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:54:00.883 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:54:00.884 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:55:01.008 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:55:01.009 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:56:00.951 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:56:00.953 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:57:00.930 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:57:00.930 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
2021-04-07 08:58:01.042 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Toon
2021-04-07 08:58:01.042 Error: dzVents: Error: (3.0.2) /opt/domoticz/dzVents/runtime/Utils.lua:121: attempt to perform arithmetic on a nil value (local 'x')
I've read the posts above and removed the - boilerOutTemp and boilerInTemp variables in the script, but the message keeps spamming the log.
Does anyone know a solution or where to start?

Below my toon script:

Code: Select all

return {
   on = {
      timer = {
         'every minute'
      }
   },
   execute = function(domoticz)
        local ToonThermostat        = domoticz.variables('UV_ToonThermostatSensorName').value -- Sensor showing current setpoint
        local ToonTemperature       = domoticz.variables('UV_ToonTemperatureSensorName').value -- Sensor showing current room temperature
        --local ToonBoilerTempIn      = domoticz.variables('UV_ToonboilerInTempName').value -- Sensor showing water temp return
        --local ToonBoilerTempOut     = domoticz.variables('UV_ToonboilerOutTempName').value -- Sensor showing current water temp out
        local ToonBoilerPressure    = domoticz.variables('UV_ToonboilerPressure').value -- Sensor showing current room temperature
        local ToonBoilerModulation  = domoticz.variables('UV_ToonboilerModulationLevel').value -- Sensor showing current Boiler Modulation
        local ToonScenes            = domoticz.variables('UV_ToonScenesSensorName').value -- Sensor showing current program
        local ToonAutoProgram       = domoticz.variables('UV_ToonAutoProgramSensorName').value -- Sensor showing current auto program status
        local ToonProgramInformation = domoticz.variables('UV_ToonProgramInformationSensorName').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_ToonBoilerTempSetpointSensorName').value  -- Sensor showing current boiler set point water temp out
    
        -- Handle json
        local json = assert(loadfile "/opt/domoticz/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()
        
        -- JSON data from Toon contains a extra "," which should not be there.
        ThermostatInfo = string.gsub(ThermostatInfo, ",}", "}")
        
        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_4.", "dev_4")
--        GasPowerInfo = string.gsub(GasPowerInfo, "dev_4:", "dev_4\":")
        
--        local jsonGasPower = json:decode(GasPowerInfo)
        
       -- domoticz.log(jsonGasPower)
--         local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_44.CurrentElectricityFlow )
--         local CurrentElectricityQuantityHoog = tonumber(jsonGasPower.dev_44.CurrentElectricityQuantity)
--         local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_46.CurrentElectricityFlow )
--         local CurrentElectricityQuantityLaag = tonumber(jsonGasPower.dev_46.CurrentElectricityQuantity)
--         local CurrentGasFlow = tonumber(jsonGasPower.dev_41.CurrentGasFlow)
--         local CurrentGasQuantity = tonumber(jsonGasPower.dev_41.CurrentGasQuantity)
--         local CurrentElectricityQuantity =   CurrentElectricityFlowHoog + CurrentElectricityFlowLaag
--         local CurrentElectricityDeliveredLaag = 0
--         local CurrentElectricityDeliveredHoog = 0
--         local totalDeliveredPower = 0

--        domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, CurrentElectricityQuantity, totalDeliveredPower).silent()
        
--        domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()

-- Update the Boiler Water In to current value
         local currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
        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)
        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)
        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.devices(ToonBoilerPressure).updatePressure(currentBoilerPressure).silent()
        end

        local currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
        local currentTemperature = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
        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      
        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<br>                elseif currentActiveState == 4 then currentActiveState = 60 -- Holiday
            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<br>            
            elseif currentBurnerInfo == 3 then currentBurnerInfo = 10 -- voorverwarmen volgend setpoint
        end
            
        if CurrentToonBurnerValue ~= currentBurnerInfo then  -- Update toon burner selector if it has changed
            -- 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
}
Fixed it myself. There was still a bit of code refering to the boilertempIN and boilertempOUT variables.
Commented them out, and no more errors messages
User avatar
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

Post by EdwinK »

Now only this error remains:

2021-04-07 12:43:00.421 Error: dzVents: Error: (3.1.7) An error occurred when calling event handler Toon
2021-04-07 12:43:00.421 Error: dzVents: Error: (3.1.7) /home/pi/domoticz/dzVents/runtime/Utils.lua:203: attempt to compare number with nil
Last edited by EdwinK on Wednesday 07 April 2021 12:43, edited 1 time in total.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

EdwinK wrote: Wednesday 07 April 2021 11:49 Now only this error remains:

2021-04-07 11:48:00.408 Error: dzVents: Error: (3.1.7) /home/pi/domoticz/dzVents/runtime/Utils.lua:203: attempt to compare number with nil
This looks to me an other script then the Toon script : Utils.lua
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
User avatar
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

Post by EdwinK »

Yes, but i don't have a script with that name, and it only pops up if the Toonscript is running. It maybe is a part of Lua?
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

EdwinK wrote: Wednesday 07 April 2021 12:42 Yes, but i don't have a script with that name, and it only pops up if the Toonscript is running. It maybe is a part of Lua?
It is a part of Domoticz and you can find it here : /var/domoticz/www/app/devices

There a lot of altered scripts on the forum currently so difficult to check for you.
My script is still running without issue. If you like i can share it.
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by waaren »

EdwinK wrote: Wednesday 07 April 2021 11:49 Now only this error remains:

2021-04-07 12:43:00.421 Error: dzVents: Error: (3.1.7) An error occurred when calling event handler Toon
2021-04-07 12:43:00.421 Error: dzVents: Error: (3.1.7) /home/pi/domoticz/dzVents/runtime/Utils.lua:203: attempt to compare number with nil
Utils.lua is part of the dzVents framework and the error in line 203 is caused by a call from your scripts to the round function with something that is not a number.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
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

Post by EdwinK »

@madpatrick please do.

I now had the script that user S10NL posted a few post above this. I believe this is your script.

Code: Select all

return {
   on = {
      timer = {
         'every minute'
      }
   },
   execute = function(domoticz)
        local ToonThermostat        = domoticz.variables('UV_ToonThermostatSensorName').value -- Sensor showing current setpoint
        local ToonTemperature       = domoticz.variables('UV_ToonTemperatureSensorName').value -- Sensor showing current room temperature
        --local ToonBoilerTempIn      = domoticz.variables('UV_ToonboilerInTempName').value -- Sensor showing water temp return
        --local ToonBoilerTempOut     = domoticz.variables('UV_ToonboilerOutTempName').value -- Sensor showing current water temp out
        local ToonBoilerPressure    = domoticz.variables('UV_ToonboilerPressure').value -- Sensor showing current room temperature
        local ToonBoilerModulation  = domoticz.variables('UV_ToonboilerModulationLevel').value -- Sensor showing current Boiler Modulation
        local ToonScenes            = domoticz.variables('UV_ToonScenesSensorName').value -- Sensor showing current program
        local ToonAutoProgram       = domoticz.variables('UV_ToonAutoProgramSensorName').value -- Sensor showing current auto program status
        local ToonProgramInformation = domoticz.variables('UV_ToonProgramInformationSensorName').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_ToonBoilerTempSetpointSensorName').value  -- Sensor showing current boiler set point water temp out
    
        -- Handle json
        -- local json = assert(loadfile "/opt/domoticz/scripts/lua/JSON.lua")()  -- For Linux
        local  json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
        local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
        local ThermostatInfo = handle:read('*all')
        handle:close()
        
        -- JSON data from Toon contains a extra "," which should not be there.
        ThermostatInfo = string.gsub(ThermostatInfo, ",}", "}")
        
        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_4.", "dev_4")
--        GasPowerInfo = string.gsub(GasPowerInfo, "dev_4:", "dev_4\":")
        
--        local jsonGasPower = json:decode(GasPowerInfo)
        
       -- domoticz.log(jsonGasPower)
--         local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_44.CurrentElectricityFlow )
--         local CurrentElectricityQuantityHoog = tonumber(jsonGasPower.dev_44.CurrentElectricityQuantity)
--         local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_46.CurrentElectricityFlow )
--         local CurrentElectricityQuantityLaag = tonumber(jsonGasPower.dev_46.CurrentElectricityQuantity)
--         local CurrentGasFlow = tonumber(jsonGasPower.dev_41.CurrentGasFlow)
--         local CurrentGasQuantity = tonumber(jsonGasPower.dev_41.CurrentGasQuantity)
--         local CurrentElectricityQuantity =   CurrentElectricityFlowHoog + CurrentElectricityFlowLaag
--         local CurrentElectricityDeliveredLaag = 0
--         local CurrentElectricityDeliveredHoog = 0
--         local totalDeliveredPower = 0

--        domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, CurrentElectricityQuantity, totalDeliveredPower).silent()
        
--        domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()

-- Update the Boiler Water In to current value
         local currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
        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)
        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)
        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.devices(ToonBoilerPressure).updatePressure(currentBoilerPressure).silent()
        end

        local currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
        local currentTemperature = domoticz.utils.round(tonumber(jsonThermostatInfo.currentTemp) / 100,1)
        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      
        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<br>                elseif currentActiveState == 4 then currentActiveState = 60 -- Holiday
            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<br>            
            elseif currentBurnerInfo == 3 then currentBurnerInfo = 10 -- voorverwarmen volgend setpoint
        end
            
        if CurrentToonBurnerValue ~= currentBurnerInfo then  -- Update toon burner selector if it has changed
            -- 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
}
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

EdwinK wrote: Wednesday 07 April 2021 15:46 @madpatrick please do.

I now had the script that user S10NL posted a few post above this. I believe this is your script.
This is my latest script

Code: Select all

	local scriptVersion = 'Versie 1.03 '
	local scriptVar     = '-=# TOON Script #=-'

return {
        on      = { timer = {'every minute'},
        },
logging = { level  = domoticz.LOG_ERROR,
       		marker = scriptVar },

execute = function(domoticz)
        local ToonThermostat        = 'Toon Thermostaat'                                       --   Sensor showing setpoint
        local ToonTemperature       = 'Temperatuur Kamer'                                      --   Sensor showing room temperature
        local ToonAutoProgram       = 'Toon Auto Program'                                      --   Sensor showing auto program status
        local ToonBoilerModulation  = 'ModulationLevel'                                        -- * Sensor showing Boiler Modulation
        local ToonScenes            = 'Toon Scenes'                                            -- * Sensor showing program
        local ToonBoilerSetpoint    = 'Ketel Setpoint'                                         -- * Sensor showing boiler temperature set point
        local ToonBoilerTempIn      = 'Ketel Temp IN'                                          -- * Sensor showing water temp return
        local ToonBoilerTempOut     = 'Ketel Temp UIT'                                         -- * Sensor showing water temp out
        local ToonBoilerPressure    = 'Keteldruk'                                              --   Sensor showing boilerpressure
        local ToonBurnerName        = 'Ketelstand'                                             --   Sensor showing boiler modus
        local P1SmartMeterPower     = 'P1 Elektra'                                             --   Sensor Energy consumption
        local P1SmartMeterGas1      = 'P1 Gas'                                                 --   Sensor Gas consumption
        local ToonIP                = 192.168.x.x			                    --   IP address of your Toon
        local SetPointAway          = 18.5                                                     --   temperature of setpoint Away
        local SetPointSleep         = 17.0                                                     --   temperature of setpoint Sleep
        local SetPointHome          = 20.0                                                     --   temperature of setpoint Home
        local SetPointComfort       = 20.5                                                     --   temperature of setpoint Comfort
    
-- 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 CurrentElectricityDeliveredFlowHoog   = tonumber(jsonGasPower.dev_25.CurrentElectricityFlow)                      --stroomgeleverd momenteel laagtarief
        local CurrentElectricityDeliveredFlowLaag   = tonumber(jsonGasPower.dev_27.CurrentElectricityFlow)                      --stroomgeleverd momenteel hoogtarief
         
        local PowerConsumption                      = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag                   --stroomverbruik totaal aktueel
        local PowerProduction                       = CurrentElectricityDeliveredFlowHoog + CurrentElectricityDeliveredFlowLaag --stroomverbruik totaal geleverd
        
                --USAGE1= energy usage meter tariff 1
                --USAGE2= energy usage meter tariff 2
                --RETURN1= energy return meter tariff 1
                --RETURN2= energy return meter tariff 2
                --CONS= actual usage power (Watt)
                --PROD= actual return power (Watt)
                --updateP1(usage1, usage2, return1, return2, cons, prod): Function. Updates the device. Supports command options. 
        domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, PowerConsumption, PowerProduction).silent()
    --  domoticz.log('P1 : Meter Verbruik laagtarief  : ' .. CurrentElectricityQuantityLaag/1000 .. ' kWh ', domoticz.LOG_FORCE)
    --  domoticz.log('P1 : Meter Verbruik hoogtarief  : ' .. CurrentElectricityQuantityHoog/1000 .. ' kWh', domoticz.LOG_FORCE)
    --  domoticz.log('P1 : Meter Levering laagtarief  : ' .. CurrentElectricityDeliveredLaag/1000 .. ' kWh', domoticz.LOG_FORCE)
    --  domoticz.log('P1 : Meter Levering hoogtarief  : ' .. CurrentElectricityDeliveredHoog/1000 .. ' kWh', domoticz.LOG_FORCE)
    
    --    domoticz.log('P1 : Huidig Stroom Verbruik     : ' .. PowerConsumption .. ' W', domoticz.LOG_FORCE)
    --    domoticz.log('P1 : Huidig Stroom Opbrengst    : ' .. PowerProduction .. ' W', domoticz.LOG_FORCE)

-- Update the gasconsumption
        local CurrentGasFlow                   = tonumber(jsonGasPower.dev_21.CurrentGasFlow)
        local CurrentGasQuantity               = tonumber(jsonGasPower.dev_21.CurrentGasQuantity)
        domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()   

-- 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('Update van de CV-water temperatuur IN: ' ..currentboilerInTemp .. ' °C',domoticz.LOG_INFO)
  --         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('Update van de CV-water temperatuur UIT : ' ..currentboilerOutTemp .. ' °C',domoticz.LOG_INFO)
 --           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).sValue,1) ~= domoticz.utils.round(currentBoilerPressure,1) then
           domoticz.log('Update van de waterdruk : ' ..currentBoilerPressure .. ' bar',domoticz.LOG_FORCE)
           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)
        
-- Update the current scene by temperature
		local currentActiveTemp = tonumber(jsonThermostatInfo.currentSetpoint) / 100

                    if currentActiveState == 0 or currentActiveTemp == SetPointComfort  then currentActiveState = 40     -- Comfort
                elseif currentActiveState == 1 or currentActiveTemp == SetPointHome     then currentActiveState = 30     -- Home
                elseif currentActiveState == 2 or currentActiveTemp == SetPointSleep    then currentActiveState = 20     -- Sleep
                elseif currentActiveState == 3 or currentActiveTemp == SetPointAway     then currentActiveState = 10     -- Away
                elseif currentActiveState == -1 then currentActiveState = 50 -- Manual                    
                    
                --domoticz.log('Update Toon scene door temperature of Scene wijziging : ' ..currentActiveState,domoticz.LOG_FORCE)
            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('Update van de Ketelstand: ' ..currentBurnerInfo,domoticz.LOG_FORCE)
            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('Update van de Modulatie stand: ' ..currentModulationLevel .. ' %',domoticz.LOG_FORCE)
            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('Update van het ketelwater temperatuur setpunt: ' ..currentInternalBoilerSetpoint .. ' °C',domoticz.LOG_FORCE)
            domoticz.devices(ToonBoilerSetpoint).updateTemperature(currentInternalBoilerSetpoint)
        end
        
-- Update the thermostat sensor to current setpoint
        if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then
            domoticz.log('Update van de temperatuur instelling naar: ' ..currentSetpoint .. ' °C',domoticz.LOG_FORCE)
            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('Update van de Kamertemparatuur : ' ..currentTemperature .. ' °C',domoticz.LOG_FORCE)
            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('Update van de Toon Scene : '..currentActiveState,domoticz.LOG_FORCE)
            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('Update van het Toon Auto Program : '..currentProgramState,domoticz.LOG_FORCE)
 --           domoticz.devices(ToonAutoProgram).switchSelector(currentProgramState).silent()
 --       end
        
   end
}
Not sure if your are using the P1 or Solarpanel function. This can be deleted.
I think it is pretty straight forward.

I've implemented the Setpoint function, so Domoticz or Toon will also be updated when the temperature is set to a value which matches the setpoint.
Check the names of your devices with mine in the top line of the script at local xxxxx = yyyyyyyy (change yyyyyyy)

If not working 100% send me a PM
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
User avatar
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

Post by EdwinK »

i don't have solarpanels :( They keep telling me that my roof is not good enough.

Even with your script, I get the same error message :(
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

EdwinK wrote: Wednesday 07 April 2021 17:02 i don't have solarpanels :( They keep telling me that my roof is not good enough.

Even with your script, I get the same error message :(
Then i think the value remain at 0.
If not we can try to set the Return vlaues to 0 or adjust the script

Just try it and let's see if it is working
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
User avatar
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

Post by EdwinK »

So, what do you want me to do?
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest