Re: Controlling Toon [HACKED] from Domoticz
Posted: Friday 11 October 2019 21:24
Open source Home Automation System
https://forum.domoticz.com/
Code: Select all
-- Update the toon burner selector to current program state
CurrentToonBurnerValue = otherdevices_svalues[ToonBurnerName]
if currentBurnerInfo == 0 then currentBurnerInfo = '0' -- uit
elseif currentBurnerInfo == 1 then currentBurnerInfo = '10' -- cv aan
elseif currentBurnerInfo == 2 then currentBurnerInfo = '20' -- warmwater aan
end
if CurrentToonBurnerValue ~= currentBurnerInfo then -- Update toon burner selector if it has changed
print ('Updating Toon burner info')
commandArray[7] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonBurnerName], currentBurnerInfo)}
endCode: Select all
commandArray = {}
ToonThermostatSensorName = uservariables['UV_ToonThermostatSensorName'] -- Sensor showing current setpoint
ToonTemperatureSensorName = uservariables['UV_ToonTemperatureSensorName'] -- Sensor showing current room temperature
ToonScenesSensorName = uservariables['UV_ToonScenesSensorName'] -- Sensor showing current program
ToonAutoProgramSensorName = uservariables['UV_ToonAutoProgramSensorName'] -- Sensor showing current auto program status
ToonBurnerName = uservariables['UV_ToonBurnerName']
ToonProgramInformationSensorName = uservariables['UV_ToonProgramInformationSensorName'] -- Sensor showing displaying program information status
ToonBoilerTempSetpoint = uservariables['UV_ToonBoilerTempSetpointSensorName'] -- Sensor showing current internal boiler temp
ToonIP = uservariables['UV_ToonIP']
DomoticzIP = uservariables['UV_DomoticzIP']
-- Choose the correct platform which Domoticz runs on
-- Remove -- before the line which applies for your situation, set -- for all other platforms
-- json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Raspberry
-- json = assert(loadfile "/opt/domoticz/scripts/lua/JSON.lua")() -- For Linux (LEDE)
json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")() -- For Windows
-- json = assert(loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")() -- For Synology
local handle = assert(io.popen(string.format('curl -m 5 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, ",}", "}")
jsonThermostatInfo = json:decode(ThermostatInfo)
if jsonThermostatInfo ~= nil then
currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
currentProgramState = tonumber(jsonThermostatInfo.programState)
currentActiveState = tonumber(jsonThermostatInfo.activeState)
currentNextTime = jsonThermostatInfo.nextTime
currentBurnerInfo = tonumber(jsonThermostatInfo.burnerInfo)
currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
currentBoilerSetPoint = tonumber(jsonThermostatInfo.currentInternalBoilerSetpoint)
if currentSetpoint ~= nil then
-- Update the thermostat sensor to current setpoint
if otherdevices_svalues[ToonThermostatSensorName]*100 ~= currentSetpoint*100 then
print('Updating thermostat sensor to new set point: ' ..currentSetpoint)
commandArray[1] = {['Variable:UV_ToonChangedByDomoticz'] = '1'} -- Set variable changed to 1 to prevent script ToonSetPoint from shooting an event at Toon
commandArray[2] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonThermostatSensorName], currentSetpoint)}
end
end
if currentTemperature ~= nil then
-- Update the temperature sensor to current room temperature
if otherdevices_svalues[ToonTemperatureSensorName]*100 ~= currentTemperature*100 then
print('Updating the temperature sensor to new value: ' ..currentTemperature)
commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonTemperatureSensorName], currentTemperature)}
end
end
if currentBoilerSetPoint ~= nil then
-- Update the temperature of boiler
if otherdevices_svalues[ToonBoilerTempSetpoint]*100 ~= currentBoilerSetPoint*100 then
print('Updating the boiler temperature to new value: ' ..currentBoilerSetPoint)
commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonBoilerTempSetpoint], currentBoilerSetPoint)}
end
end
if currentActiveState ~= nil then
-- Update the toon scene selector sensor to current program state
CurrentToonScenesSensorValue = otherdevices_svalues[ToonScenesSensorName]
if currentActiveState == -1 then currentActiveState = '50' -- Manual
elseif currentActiveState == 0 then currentActiveState = '40' -- Comfort
elseif currentActiveState == 1 then currentActiveState = '30' -- Home
elseif currentActiveState == 2 then currentActiveState = '20' -- Sleep
elseif currentActiveState == 3 then currentActiveState = '10' -- Away
end
if CurrentToonScenesSensorValue ~= currentActiveState then -- Update toon selector if it has changed
print ('Updating Toon Scenes selector')
commandArray[4] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonScenesSensorName], currentActiveState)}
end
end
if currentProgramState ~= nil then
-- Updates the toon auto program switch
CurrentToonAutoProgramSensorValue = otherdevices_svalues[ToonAutoProgramSensorName]
if currentProgramState == 0 then currentProgramState = '10' -- No
elseif currentProgramState == 1 then currentProgramState = '20' -- Yes
elseif currentProgramState == 2 then currentProgramState = '30' -- Temporary
end
if CurrentToonAutoProgramSensorValue ~= currentProgramState then -- Update toon auto program selector if it has changed
print ('Updating Toon Auto Program selector')
commandArray[5] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonAutoProgramSensorName], currentProgramState)}
end
end
if currentNextTime ~= nil and currentNextSetPoint ~= nil then
-- Updates the toon program information text box
CurrentToomProgramInformationSensorValue = otherdevices_svalues[ToonProgramInformationSensorName]
if currentNextTime == 0 or currentNextSetPoint == 0 then
ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
else
ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
end
if CurrentToomProgramInformationSensorValue ~= ToonProgramInformationSensorValue then
commandArray[6] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonProgramInformationSensorName], ToonProgramInformationSensorValue)}
end
end
-- Update the toon burner selector to current program state
CurrentToonBurnerValue = otherdevices_svalues[ToonBurnerName]
if currentBurnerInfo == 0 then currentBurnerInfo = '0' -- uit
elseif currentBurnerInfo == 1 then currentBurnerInfo = '10' -- cv aan
elseif currentBurnerInfo == 2 then currentBurnerInfo = '20' -- warmwater aan
end
if CurrentToonBurnerValue ~= currentBurnerInfo then -- Update toon burner selector if it has changed
print ('Updating Toon burner info')
commandArray[7] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonBurnerName], currentBurnerInfo)}
end
end
--
return commandArrayCode: Select all
-- script_time_toonselector.lua
-- Reads the Toon Thermostat Setpoint Temperature and updates the
-- selector in Domoticz to represent the current Active State.
-- Off scene is an option, leave it out if not needed.
-- Action commands will not be executed.
commandArray = {}
-- Settings: Configure as desired
-- Name of the switch with the temperature setpoint.
ThermostatSetPointName = 'ToonThermostat' --Must match the name of you SetPoint device
-- Temperature SetPoints.
OffSetPoint = '6.00' --optional
AwaySetPoint = '17.50'
SleepSetPoint = '19.00'
HomeSetPoint = '20.50'
ComfortSetPoint = '21.00'
-- Name of the selector for Toon
ToonSelector = 'ToonScenes' --Must match (including case) the name of your Selector Switch
-- Name of the levels in the selector
OffLevel = 'Off' --optional
AwayLevel = 'Away'
SleepLevel = 'Sleep'
HomeLevel = 'Home'
ComfortLevel = 'Comfort'
-- Values from each level name
OffLevelValue = '0' --optional
AwayLevelValue = '10'
SleepLevelValue = '20'
HomeLevelValue = '30'
ComfortLevelValue = '40'
-- End of settings
-- Toon Thermostat SetPoint:
ThermostatSetPoint = otherdevices_svalues[ThermostatSetPointName]
if (ThermostatSetPoint == HomeSetPoint) then
--print("SetPoint equals to Home");
if (otherdevices[ToonSelector] ~= HomeLevel) then
print("Updating '" .. ToonSelector .. "' selector to '" .. HomeLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..HomeLevelValue
end
elseif (ThermostatSetPoint == ComfortSetPoint) then
--print("SetPoint equals to Comfort");
if (otherdevices[ToonSelector] ~= ComfortLevel) then
print("Updating '" .. ToonSelector .. "' selector to '" .. ComfortLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..ComfortLevelValue
end
elseif (ThermostatSetPoint == SleepSetPoint) then
--print("SetPoint equals to Sleep");
if (otherdevices[ToonSelector] ~= SleepLevel) then
print("Updating '" .. ToonSelector .. "' selector to '" .. SleepLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..SleepLevelValue
end
elseif (ThermostatSetPoint == AwaySetPoint) then
--print("SetPoint equals to Away");
if (otherdevices[ToonSelector] ~= AwayLevel) then
print("Updating '" .. ToonSelector .. "' selector to '" .. AwayLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..AwayLevelValue
end
-- Optional
elseif (ThermostatSetPoint == OffSetPoint) then
--print("SetPoint equals to Off");
if (otherdevices[ToonSelector] ~= OffLevel) then
print("Updating '" .. ToonSelector .. "' selector to '" .. OffLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[ToonSelector]..'|1|'..OffLevelValue
end
end
return commandArrayCode: Select all
commandArray = {}
ToonThermostatSensorName = uservariables['UV_ToonThermostatSensorName'] -- Sensor showing current setpoint
ToonIP = uservariables['UV_ToonIP']
for deviceName,deviceValue in pairs(devicechanged) do
if (deviceName == ToonThermostatSensorName) then
if uservariables['UV_ToonChangedByDomoticz'] == 1 then
commandArray['Variable:UV_ToonChangedByDomoticz'] = '0'
else
SetPoint = otherdevices_svalues[ToonThermostatSensorName]
ToonCommand = string.format('http://%s/happ_thermstat?action=setSetpoint&Setpoint=%s', ToonIP, SetPoint*100)
print('Setting Toon setpoint to '.. SetPoint)
commandArray['OpenURL'] = ToonCommand
end
end
end
return commandArrayDon't know what you want me to do with this.annesdomotic wrote: Saturday 14 December 2019 8:20 perhaps this is useful, almost everything works with these scripts. except the boiler in and out.
setpoint:
return {
on = {
devices = {
'ToonThermostat'
}
},
execute = function(domoticz, device)
domoticz.openURL(string.format('http://%s/happ_thermstat?action=setSetpoint&Setpoint=%s', domoticz.variables('UV_ToonIP').value, device.setPoint*100))
domoticz.log('Setting Toon setpoint to '.. device.setPoint)
end
}
script:
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 "/home/pi/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()
local jsonThermostatInfo = json:decode(ThermostatInfo)
if jsonThermostatInfo == nil then
return
end
local handle2 = assert(io.popen(string.format('curl http://%s/boilerstatus/boilervalues.txt', ToonIP)))
local BoilerInfo = handle2:read('*all')
handle2:close()
-- JSON data from Toon contains a extra "," which should not be there.
BoilerInfo = string.gsub(BoilerInfo, ",}", "}")
jsonBoilerInfo = json:decode(BoilerInfo)
--http://192.168.2.193/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
}
Hello Larsoss,Larsoss wrote: Saturday 14 December 2019 17:35Hi Patrick,
See my screenshot. https://ibb.co/0X1GtKh
Code: Select all
return {
on = {
devices = {
'Toon Thermostaat'
}
},
execute = function(domoticz, device)
domoticz.openURL(string.format('http://%s/happ_thermstat?action=setSetpoint&Setpoint=%s', domoticz.variables('UV_ToonIP').value, device.setPoint*100))
domoticz.log('Setting Toon setpoint to '.. device.setPoint)
end
}Code: Select all
return {
logging = {
level = domoticz.LOG_FORCE, -- Select one of LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE to override system log level
marker = "-=# P1 Toon #=-"
},
on = {
timer = {
'every minute'
}
},
execute = function(domoticz)
local ToonThermostat = domoticz.variables('UV_ToonThermostat').value -- Sensor showing current setpoint
local ToonTemperature = domoticz.variables('UV_ToonTemperature').value -- Sensor showing current room temperature
local ToonBoilerTempIn = domoticz.variables('UV_ToonBoilerTempIn').value -- Sensor showing water temp return
local ToonBoilerTempOut = domoticz.variables('UV_ToonBoilerTempOut').value -- Sensor showing current water temp out
local ToonBoilerPressure = domoticz.variables('UV_ToonBoilerPressure').value -- Sensor showing current room temperature
local ToonBoilerModulation = domoticz.variables('UV_ToonBoilerModulation').value -- Sensor showing current Boiler Modulation
local ToonScenes = domoticz.variables('UV_ToonScenes').value -- Sensor showing current program
local ToonAutoProgram = domoticz.variables('UV_ToonAutoProgram').value -- Sensor showing current auto program status
local ToonProgramInformation = domoticz.variables('UV_ToonProgramInformation').value -- Sensor showing displaying program information status
local ToonIP = domoticz.variables('UV_ToonIP').value
local DomoticzIP = domoticz.variables('UV_DomoticzIP').value
local ToonBurnerName = domoticz.variables('UV_ToonBurnerName').value
local P1SmartMeterPower = domoticz.variables('UV_P1SmartMeterElectra').value
local P1SmartMeterGas1 = domoticz.variables('UV_P1SmartMeterGasMeterStand').value
local ToonBoilerSetpoint = domoticz.variables('UV_ToonBoilerTempSetpoint').value -- Sensor showing current boiler set point water temp out
-- Handle json
-- local json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
local json = assert(loadfile "/var/domoticz/scripts/lua/JSON.lua")() -- For Linux (ClearOS)
local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
local ThermostatInfo = handle:read('*all')
handle:close()
local jsonThermostatInfo = json:decode(ThermostatInfo)
if jsonThermostatInfo == nil then
return
end
local handle2 = assert(io.popen(string.format('curl http://%s/boilerstatus/boilervalues.txt', ToonIP)))
local BoilerInfo = handle2:read('*all')
handle2:close()
-- JSON data from Toon contains a extra "," which should not be there.
BoilerInfo = string.gsub(BoilerInfo, ",}", "}")
jsonBoilerInfo = json:decode(BoilerInfo)
-- http://IP_TOON/hdrv_zwave?action=getDevices.json
local handle4 = assert(io.popen(string.format('curl http://%s/hdrv_zwave?action=getDevices.json', ToonIP)))
local GasPowerInfo = handle4:read('*all')
handle4:close()
-- JSON data from Toon contains a extra "." which should not be there.
GasPowerInfo = string.gsub(GasPowerInfo, "dev_2.", "dev_2")
GasPowerInfo = string.gsub(GasPowerInfo, "dev_2:", "dev_2\":")
local jsonGasPower = json:decode(GasPowerInfo)
-- Update the powerconsumption
local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_24.CurrentElectricityFlow ) --stroomverbruik momenteel hoogtarief
local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_26.CurrentElectricityFlow ) --stroomverbruik momenteel laagtarief
local CurrentElectricityQuantityHoog = tonumber(jsonGasPower.dev_24.CurrentElectricityQuantity) --stroomverbruik totaal hoogtarief
local CurrentElectricityQuantityLaag = tonumber(jsonGasPower.dev_26.CurrentElectricityQuantity) --stroomverbruik totaal laagtarief
local CurrentElectricityDeliveredHoog = tonumber(jsonGasPower.dev_25.CurrentElectricityQuantity) --stroomgeleverd momenteel hoogtarief
local CurrentElectricityDeliveredLaag = tonumber(jsonGasPower.dev_27.CurrentElectricityQuantity) --stroomgeleverd momenteel laagtarief
local CurrentElectricityQuantity = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag --stroomverbruik totaal aktueel
local totalDeliveredPower = 0
local totalDeliveredPower2 = CurrentElectricityDeliveredHoog/1000 + CurrentElectricityDeliveredLaag/1000 --stroomverbruik totaal geleverd
local CurrentGasFlow = tonumber(jsonGasPower.dev_21.CurrentGasFlow)
local CurrentGasQuantity = tonumber(jsonGasPower.dev_21.CurrentGasQuantity)
domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, CurrentElectricityQuantity, totalDeliveredPower).silent()
domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent()
--domoticz.log('*** P1 from toon: ' .. CurrentElectricityQuantityLaag/1000 .. 'kwh USAGE1 | ' ..CurrentElectricityQuantityHoog/1000 .. 'kwh USAGE2 | ' .. CurrentElectricityDeliveredLaag/1000 .. 'kwh RETURN1 | ' .. CurrentElectricityDeliveredHoog/1000 .. 'kwh RETURN2 | ' .. CurrentElectricityQuantity .. 'w consumed | '.. totalDeliveredPower2 .. 'w produced', domoticz.LOG_FORCE)
-- Update the Boiler Water In to current value
local currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
currentboilerInTemp = tonumber(string.format("%.0f", currentboilerInTemp)) -- afgeronde getallen is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerTempIn).temperature,0) ~= domoticz.utils.round(currentboilerInTemp,0) then
domoticz.log('Updating Boiler Water In to current value: ' ..currentboilerInTemp)
domoticz.devices(ToonBoilerTempIn).updateTemperature(currentboilerInTemp).silent()
end
-- Update the Boiler water Out to current value
local currentboilerOutTemp = tonumber(jsonBoilerInfo.boilerOutTemp)
currentboilerOutTemp = tonumber(string.format("%.0f", currentboilerOutTemp)) -- afgeronde getallen is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerTempOut).temperature,0) ~= domoticz.utils.round(currentboilerOutTemp,0) then
domoticz.log('Updating Boiler Water Out to current value: ' ..currentboilerOutTemp)
domoticz.devices(ToonBoilerTempOut).updateTemperature(currentboilerOutTemp).silent()
end
-- Update the Boiler water Pressure to current value
local currentBoilerPressure = tonumber(jsonBoilerInfo.boilerPressure)
-- currentBoilerPressure = tonumber(string.format("%.1f", currentBoilerPressure)) -- 1 decimaal is voldoende [PdB]
if domoticz.utils.round(domoticz.devices(ToonBoilerPressure)._nValue,0) ~= domoticz.utils.round(currentBoilerPressure,0) then
domoticz.log('Updating Boiler Pressure to current value: ' ..currentBoilerPressure, domoticz.LOG_INFO)
domoticz.devices(ToonBoilerPressure).updatePressure(currentBoilerPressure).silent()
end
-- Update the current temperature setpoint
local currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
currentTemperature = tonumber(string.format("%.1f", currentTemperature)) -- 1 decimaal is voldoende [PdB]
-- Update the current auto program
local currentProgramState = tonumber(jsonThermostatInfo.programState)
if currentProgramState == 0 then currentProgramState = 10 -- No
elseif currentProgramState == 1 then currentProgramState = 20 -- Yes
elseif currentProgramState == 2 then currentProgramState = 30 -- Temporary
end
-- Update the current scene by state
local currentActiveState = tonumber(jsonThermostatInfo.activeState)
if currentActiveState == -1 then currentActiveState = 50 -- Manual
elseif currentActiveState == 0 then currentActiveState = 40 -- Comfort
elseif currentActiveState == 1 then currentActiveState = 30 -- Home
elseif currentActiveState == 2 then currentActiveState = 20 -- Sleep
elseif currentActiveState == 3 then currentActiveState = 10 -- Away
end
-- Update the current scene by temperature
local currentActiveTemp = tonumber(jsonThermostatInfo.currentSetpoint) / 100
if currentActiveTemp == 20.5 then currentActiveState = 40 -- Comfort
elseif currentActiveTemp == 19.5 then currentActiveState = 30 -- Home
elseif currentActiveTemp == 17 then currentActiveState = 20 -- Sleep
elseif currentActiveTemp == 18.5 then currentActiveState = 10 -- Away
else currentActiveState = 50 -- Manual
end
-- Update the toon burner selector to current program state
local currentBurnerInfo = tonumber(jsonThermostatInfo.burnerInfo)
local CurrentToonBurnerValue = domoticz.devices(ToonBurnerName).level
if currentBurnerInfo == 0 then currentBurnerInfo = 0 -- uit
elseif currentBurnerInfo == 1 then currentBurnerInfo = 10 -- cv aan
elseif currentBurnerInfo == 2 then currentBurnerInfo = 20 -- warmwater aan
elseif currentBurnerInfo == 3 then currentBurnerInfo = 30 -- voorverwarmen volgend setpoint
end
-- Update toon burner selector if it has changed
if CurrentToonBurnerValue ~= currentBurnerInfo then
domoticz.log('Updating Toon burner info:')
domoticz.devices(ToonBurnerName).switchSelector(currentBurnerInfo)
end
-- Update the modulation level of the burner
local currentModulationLevel = tonumber(jsonThermostatInfo.currentModulationLevel)
if domoticz.devices(ToonBoilerModulation).percentage + 1 ~= currentModulationLevel + 1 then
domoticz.log('Updating the Modulation sensor to new value: ' ..currentModulationLevel)
domoticz.devices(ToonBoilerModulation).updatePercentage(currentModulationLevel)
end
-- Update the temperature Boiler setpoint to current boiler set point
local currentInternalBoilerSetpoint = jsonThermostatInfo.currentInternalBoilerSetpoint+1
if domoticz.utils.round(domoticz.devices(ToonBoilerSetpoint).temperature, 1) ~= domoticz.utils.round(currentInternalBoilerSetpoint, 1) then
domoticz.log('Updating the Boiler internal temperature setpoint to new value: ' ..currentInternalBoilerSetpoint)
domoticz.devices(ToonBoilerSetpoint).updateTemperature(currentInternalBoilerSetpoint)
end
-- Update the thermostat sensor to current setpoint
if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then
domoticz.log('Updating thermostat sensor to new set point: ' ..currentSetpoint)
domoticz.devices(ToonThermostat).updateSetPoint(currentSetpoint).silent()
end
-- Update the temperature sensor to current room temperature
if domoticz.utils.round(domoticz.devices(ToonTemperature).temperature, 1) ~= domoticz.utils.round(currentTemperature, 1) then
domoticz.log('Updating the temperature sensor to new value: ' ..currentTemperature)
domoticz.devices(ToonTemperature).updateTemperature(currentTemperature)
end
-- Update the toon scene selector sensor to current program state
if domoticz.devices(ToonScenes).level ~= currentActiveState then -- Update toon selector if it has changed
domoticz.log('Updating Toon Scenes selector to: '..currentActiveState)
domoticz.devices(ToonScenes).switchSelector(currentActiveState).silent()
end
-- Updates the toon auto program switch
if domoticz.devices(ToonAutoProgram).level ~= currentProgramState then -- Update toon auto program selector if it has changed
domoticz.log('Updating Toon Auto Program selector to: '..currentProgramState)
domoticz.devices(ToonAutoProgram).switchSelector(currentProgramState).silent()
end
-- Updates the toon program information text box
-- local currentNextTime = jsonThermostatInfo.nextTime
-- local currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
-- if currentNextTime == 0 or currentNextSetPoint == 0 then
-- ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
-- else
-- ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
-- end
-- if domoticz.devices(ToonProgramInformation).text ~= ToonProgramInformationSensorValue then
-- domoticz.log('Updating Toon Program Information to: '..ToonProgramInformationSensorValue)
-- domoticz.devices(ToonProgramInformation).updateText(ToonProgramInformationSensorValue)
-- end
end
}Ok, i did copy paste, changed the name of my script to the names you wright.madpatrick wrote: Saturday 14 December 2019 18:20Hello Larsoss,Larsoss wrote: Saturday 14 December 2019 17:35Hi Patrick,
See my screenshot. https://ibb.co/0X1GtKh
I see that you are using 3 scripts. I'm only using 2 scripts.
Toon_setpointToon_scriptCode: Select all
return { on = { devices = { 'Toon Thermostaat' } }, execute = function(domoticz, device) domoticz.openURL(string.format('http://%s/happ_thermstat?action=setSetpoint&Setpoint=%s', domoticz.variables('UV_ToonIP').value, device.setPoint*100)) domoticz.log('Setting Toon setpoint to '.. device.setPoint) end }Maybe this helps you to get a better start.Code: Select all
return { logging = { level = domoticz.LOG_FORCE, -- Select one of LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE to override system log level marker = "-=# P1 Toon #=-" }, on = { timer = { 'every minute' } }, execute = function(domoticz) local ToonThermostat = domoticz.variables('UV_ToonThermostat').value -- Sensor showing current setpoint local ToonTemperature = domoticz.variables('UV_ToonTemperature').value -- Sensor showing current room temperature local ToonBoilerTempIn = domoticz.variables('UV_ToonBoilerTempIn').value -- Sensor showing water temp return local ToonBoilerTempOut = domoticz.variables('UV_ToonBoilerTempOut').value -- Sensor showing current water temp out local ToonBoilerPressure = domoticz.variables('UV_ToonBoilerPressure').value -- Sensor showing current room temperature local ToonBoilerModulation = domoticz.variables('UV_ToonBoilerModulation').value -- Sensor showing current Boiler Modulation local ToonScenes = domoticz.variables('UV_ToonScenes').value -- Sensor showing current program local ToonAutoProgram = domoticz.variables('UV_ToonAutoProgram').value -- Sensor showing current auto program status local ToonProgramInformation = domoticz.variables('UV_ToonProgramInformation').value -- Sensor showing displaying program information status local ToonIP = domoticz.variables('UV_ToonIP').value local DomoticzIP = domoticz.variables('UV_DomoticzIP').value local ToonBurnerName = domoticz.variables('UV_ToonBurnerName').value local P1SmartMeterPower = domoticz.variables('UV_P1SmartMeterElectra').value local P1SmartMeterGas1 = domoticz.variables('UV_P1SmartMeterGasMeterStand').value local ToonBoilerSetpoint = domoticz.variables('UV_ToonBoilerTempSetpoint').value -- Sensor showing current boiler set point water temp out -- Handle json -- local json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux local json = assert(loadfile "/var/domoticz/scripts/lua/JSON.lua")() -- For Linux (ClearOS) local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP))) local ThermostatInfo = handle:read('*all') handle:close() local jsonThermostatInfo = json:decode(ThermostatInfo) if jsonThermostatInfo == nil then return end local handle2 = assert(io.popen(string.format('curl http://%s/boilerstatus/boilervalues.txt', ToonIP))) local BoilerInfo = handle2:read('*all') handle2:close() -- JSON data from Toon contains a extra "," which should not be there. BoilerInfo = string.gsub(BoilerInfo, ",}", "}") jsonBoilerInfo = json:decode(BoilerInfo) -- http://IP_TOON/hdrv_zwave?action=getDevices.json local handle4 = assert(io.popen(string.format('curl http://%s/hdrv_zwave?action=getDevices.json', ToonIP))) local GasPowerInfo = handle4:read('*all') handle4:close() -- JSON data from Toon contains a extra "." which should not be there. GasPowerInfo = string.gsub(GasPowerInfo, "dev_2.", "dev_2") GasPowerInfo = string.gsub(GasPowerInfo, "dev_2:", "dev_2\":") local jsonGasPower = json:decode(GasPowerInfo) -- Update the powerconsumption local CurrentElectricityFlowHoog = tonumber(jsonGasPower.dev_24.CurrentElectricityFlow ) --stroomverbruik momenteel hoogtarief local CurrentElectricityFlowLaag = tonumber(jsonGasPower.dev_26.CurrentElectricityFlow ) --stroomverbruik momenteel laagtarief local CurrentElectricityQuantityHoog = tonumber(jsonGasPower.dev_24.CurrentElectricityQuantity) --stroomverbruik totaal hoogtarief local CurrentElectricityQuantityLaag = tonumber(jsonGasPower.dev_26.CurrentElectricityQuantity) --stroomverbruik totaal laagtarief local CurrentElectricityDeliveredHoog = tonumber(jsonGasPower.dev_25.CurrentElectricityQuantity) --stroomgeleverd momenteel hoogtarief local CurrentElectricityDeliveredLaag = tonumber(jsonGasPower.dev_27.CurrentElectricityQuantity) --stroomgeleverd momenteel laagtarief local CurrentElectricityQuantity = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag --stroomverbruik totaal aktueel local totalDeliveredPower = 0 local totalDeliveredPower2 = CurrentElectricityDeliveredHoog/1000 + CurrentElectricityDeliveredLaag/1000 --stroomverbruik totaal geleverd local CurrentGasFlow = tonumber(jsonGasPower.dev_21.CurrentGasFlow) local CurrentGasQuantity = tonumber(jsonGasPower.dev_21.CurrentGasQuantity) domoticz.devices(P1SmartMeterPower).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, CurrentElectricityQuantity, totalDeliveredPower).silent() domoticz.devices(P1SmartMeterGas1).updateGas(CurrentGasQuantity).silent() --domoticz.log('*** P1 from toon: ' .. CurrentElectricityQuantityLaag/1000 .. 'kwh USAGE1 | ' ..CurrentElectricityQuantityHoog/1000 .. 'kwh USAGE2 | ' .. CurrentElectricityDeliveredLaag/1000 .. 'kwh RETURN1 | ' .. CurrentElectricityDeliveredHoog/1000 .. 'kwh RETURN2 | ' .. CurrentElectricityQuantity .. 'w consumed | '.. totalDeliveredPower2 .. 'w produced', domoticz.LOG_FORCE) -- Update the Boiler Water In to current value local currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp) currentboilerInTemp = tonumber(string.format("%.0f", currentboilerInTemp)) -- afgeronde getallen is voldoende [PdB] if domoticz.utils.round(domoticz.devices(ToonBoilerTempIn).temperature,0) ~= domoticz.utils.round(currentboilerInTemp,0) then domoticz.log('Updating Boiler Water In to current value: ' ..currentboilerInTemp) domoticz.devices(ToonBoilerTempIn).updateTemperature(currentboilerInTemp).silent() end -- Update the Boiler water Out to current value local currentboilerOutTemp = tonumber(jsonBoilerInfo.boilerOutTemp) currentboilerOutTemp = tonumber(string.format("%.0f", currentboilerOutTemp)) -- afgeronde getallen is voldoende [PdB] if domoticz.utils.round(domoticz.devices(ToonBoilerTempOut).temperature,0) ~= domoticz.utils.round(currentboilerOutTemp,0) then domoticz.log('Updating Boiler Water Out to current value: ' ..currentboilerOutTemp) domoticz.devices(ToonBoilerTempOut).updateTemperature(currentboilerOutTemp).silent() end -- Update the Boiler water Pressure to current value local currentBoilerPressure = tonumber(jsonBoilerInfo.boilerPressure) -- currentBoilerPressure = tonumber(string.format("%.1f", currentBoilerPressure)) -- 1 decimaal is voldoende [PdB] if domoticz.utils.round(domoticz.devices(ToonBoilerPressure)._nValue,0) ~= domoticz.utils.round(currentBoilerPressure,0) then domoticz.log('Updating Boiler Pressure to current value: ' ..currentBoilerPressure, domoticz.LOG_INFO) domoticz.devices(ToonBoilerPressure).updatePressure(currentBoilerPressure).silent() end -- Update the current temperature setpoint local currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100 local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100 currentTemperature = tonumber(string.format("%.1f", currentTemperature)) -- 1 decimaal is voldoende [PdB] -- Update the current auto program local currentProgramState = tonumber(jsonThermostatInfo.programState) if currentProgramState == 0 then currentProgramState = 10 -- No elseif currentProgramState == 1 then currentProgramState = 20 -- Yes elseif currentProgramState == 2 then currentProgramState = 30 -- Temporary end -- Update the current scene by state local currentActiveState = tonumber(jsonThermostatInfo.activeState) if currentActiveState == -1 then currentActiveState = 50 -- Manual elseif currentActiveState == 0 then currentActiveState = 40 -- Comfort elseif currentActiveState == 1 then currentActiveState = 30 -- Home elseif currentActiveState == 2 then currentActiveState = 20 -- Sleep elseif currentActiveState == 3 then currentActiveState = 10 -- Away end -- Update the current scene by temperature local currentActiveTemp = tonumber(jsonThermostatInfo.currentSetpoint) / 100 if currentActiveTemp == 20.5 then currentActiveState = 40 -- Comfort elseif currentActiveTemp == 19.5 then currentActiveState = 30 -- Home elseif currentActiveTemp == 17 then currentActiveState = 20 -- Sleep elseif currentActiveTemp == 18.5 then currentActiveState = 10 -- Away else currentActiveState = 50 -- Manual end -- Update the toon burner selector to current program state local currentBurnerInfo = tonumber(jsonThermostatInfo.burnerInfo) local CurrentToonBurnerValue = domoticz.devices(ToonBurnerName).level if currentBurnerInfo == 0 then currentBurnerInfo = 0 -- uit elseif currentBurnerInfo == 1 then currentBurnerInfo = 10 -- cv aan elseif currentBurnerInfo == 2 then currentBurnerInfo = 20 -- warmwater aan elseif currentBurnerInfo == 3 then currentBurnerInfo = 30 -- voorverwarmen volgend setpoint end -- Update toon burner selector if it has changed if CurrentToonBurnerValue ~= currentBurnerInfo then domoticz.log('Updating Toon burner info:') domoticz.devices(ToonBurnerName).switchSelector(currentBurnerInfo) end -- Update the modulation level of the burner local currentModulationLevel = tonumber(jsonThermostatInfo.currentModulationLevel) if domoticz.devices(ToonBoilerModulation).percentage + 1 ~= currentModulationLevel + 1 then domoticz.log('Updating the Modulation sensor to new value: ' ..currentModulationLevel) domoticz.devices(ToonBoilerModulation).updatePercentage(currentModulationLevel) end -- Update the temperature Boiler setpoint to current boiler set point local currentInternalBoilerSetpoint = jsonThermostatInfo.currentInternalBoilerSetpoint+1 if domoticz.utils.round(domoticz.devices(ToonBoilerSetpoint).temperature, 1) ~= domoticz.utils.round(currentInternalBoilerSetpoint, 1) then domoticz.log('Updating the Boiler internal temperature setpoint to new value: ' ..currentInternalBoilerSetpoint) domoticz.devices(ToonBoilerSetpoint).updateTemperature(currentInternalBoilerSetpoint) end -- Update the thermostat sensor to current setpoint if domoticz.devices(ToonThermostat).setPoint*100 ~= currentSetpoint*100 then domoticz.log('Updating thermostat sensor to new set point: ' ..currentSetpoint) domoticz.devices(ToonThermostat).updateSetPoint(currentSetpoint).silent() end -- Update the temperature sensor to current room temperature if domoticz.utils.round(domoticz.devices(ToonTemperature).temperature, 1) ~= domoticz.utils.round(currentTemperature, 1) then domoticz.log('Updating the temperature sensor to new value: ' ..currentTemperature) domoticz.devices(ToonTemperature).updateTemperature(currentTemperature) end -- Update the toon scene selector sensor to current program state if domoticz.devices(ToonScenes).level ~= currentActiveState then -- Update toon selector if it has changed domoticz.log('Updating Toon Scenes selector to: '..currentActiveState) domoticz.devices(ToonScenes).switchSelector(currentActiveState).silent() end -- Updates the toon auto program switch if domoticz.devices(ToonAutoProgram).level ~= currentProgramState then -- Update toon auto program selector if it has changed domoticz.log('Updating Toon Auto Program selector to: '..currentProgramState) domoticz.devices(ToonAutoProgram).switchSelector(currentProgramState).silent() end -- Updates the toon program information text box -- local currentNextTime = jsonThermostatInfo.nextTime -- local currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100 -- if currentNextTime == 0 or currentNextSetPoint == 0 then -- ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°' -- else -- ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°' -- end -- if domoticz.devices(ToonProgramInformation).text ~= ToonProgramInformationSensorValue then -- domoticz.log('Updating Toon Program Information to: '..ToonProgramInformationSensorValue) -- domoticz.devices(ToonProgramInformation).updateText(ToonProgramInformationSensorValue) -- end end }
I don't work with the other script, so diffcult to check for you.
Also check your log file. This could help
I'm using differente UserVariable names the the other script, but basicly it is the same priciple.
Code: Select all
-- 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)
Code: Select all
-- http://192.168.1.120/hdrv_zwave?action=getDevices.json
local handle4 = assert(io.popen(string.format('curl http://%s/hdrv_zwave?action=getDevices.json', ToonIP)))
local GasPowerInfo = handle4:read('*all')
handle4:close()I did checked that, just before you asked about it. And it's there.madpatrick wrote: Saturday 14 December 2019 18:36 restart is not necessary
-- in the beginnen in a line, means a comment and not a command
Also check if the location of JSON.lua is correct
/home/pi/domoticz/scripts/lua/JSON.lua
I did not change the UV. And yes please help me with teamviewer.madpatrick wrote: Saturday 14 December 2019 18:46 did you changed the UV ? I've different names
Further more, what is working and what not.
If you like a can watch at your system with teamviewer
Thanks Patrick for the support.