Which version of the script are you using.Alxxx wrote: ↑Friday 19 February 2021 14:15u am trying to use the script i checked the uservariables for at least 10 times made 2 times form scratch new settings.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
but the temperature will not show the signal to the toon like home,comfort,away, manual are working OK
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
}