gielie wrote:Hypermobile wrote:Adjusted somebody elses Script to get it to work with this new app:
It's for Domoticz:
1) make 5 UV_variables in domoticz
UV_ToonIP => {STRING} =192.168.x.x
UV_DomoticzIP => {STRING} = 192.168.x.x
UV_ToonboilerInTempName => {STRING} = BoilerInletTemp
UV_ToonboilerOutTempName => {STRING} = BoilerOutletTemp
UV_BoilerPressure => {STRINT} = BoilerPressure
2) Create 3 dummy sensor; with Name BoilerInletTemp, BoilerOutletTemp, BoilerPressure
3) Create a LUA TIME Event copy paste script.
Code: Select all
-- Time script runs every minute, intended to sync Domoticz with Toon in case the value is changed on the physical device.
-- Updates Toon ToonboilerOutTempName Sensor to value set on Toon
-- Updates Toon ToonboilerInTempName Sensor to value set on Toon
-- Updates Toon ToonboilerPressure sensor to value set on Toon
commandArray = {}
ToonboilerInTempName = uservariables['UV_ToonboilerInTempName'] -- Sensor inlet temperature
ToonboilerOutTempName = uservariables['UV_ToonboilerOutTempName'] -- Sensor outlet temperature
ToonboilerPressure = uservariables['UV_ToonboilerPressure'] -- ToonboilerPressure
ToonIP = uservariables['UV_ToonIP']
DomoticzIP = uservariables['UV_DomoticzIP']
json = assert(loadfile "/usr/local/domoticz/var/scripts/lua/JSON.lua")() -- For Synology
local handle = assert(io.popen(string.format('curl http://%s/boilerstatus/boilervalues.txt', ToonIP)))
local BoilerInfo = handle:read('*all')
handle:close()
-- JSON data from Toon contains a extra "," which should not be there.
BoilerInfo = string.gsub(BoilerInfo, ",}", "}")
jsonBoilerInfo = json:decode(BoilerInfo)
currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
currentboilerOutTemp = tonumber(jsonBoilerInfo.boilerOutTemp)
currentboilerPressure = tonumber(jsonBoilerInfo.boilerPressure)
-- Update the boilerInTemp
if otherdevices_svalues[ToonboilerInTempName]*100 ~= currentboilerInTemp*100 then
print('Updating boiler inlet temp to new value: ' ..currentboilerInTemp)
commandArray[1] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonboilerInTempName], currentboilerInTemp)}
end
-- Update the boilerOutTemp
if otherdevices_svalues[ToonboilerOutTempName]*100 ~= currentboilerOutTemp*100 then
print('Updating boiler outlet temp to new value: ' ..currentboilerOutTemp)
commandArray[2] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonboilerOutTempName], currentboilerOutTemp)}
end
-- Update the boilerPressure
if otherdevices_svalues[ToonboilerPressure]*100 ~= currentboilerPressure*100 then
print('Updating boiler pressure to new value: ' ..currentboilerPressure)
commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonboilerPressure], currentboilerPressure)}
end
return commandArray
---EDITTED: added Pressure measurement
---EDITTED: added *100 to let the IF THEN work Correct
The script works great, accept the pressure because i dont have that value.
Could you add the other parameters to the script like %modulation?
I tried it myself but it doesnt work, i replaced the pressure items for the Modulation parts with no luck.
Current Setpoint
Current temp
Current programstate
Burner info
Modulation level;
Next setpoint.
I grab those from another
IPTOON/happ_thermstat?action=getThermostatInfo
The BoilerStatus grabs Modulation levels; also from this location;
So i thought it's more usefull to get it at it's source
Check allso this Forum
https://www.domoticz.com/forum/viewtopic.php?t=11421
This is my LUA TIME EVENT:
You Need to create a WHole Bunch of USER Variables. to get it to work
Code: Select all
-- Time script runs every minute, intended to sync Domoticz with Toon in case the value is changed on the physical device.
-- Updates Toon Thermostat Sensor to value set on Toon
-- Updates Toon Temperature Sensor to value set on Toon
-- Updates Toon Scenes switch based on program set on Toon
-- Updates Toon Auto Program switch to value set on Toon
-- Updates Toon program information text to value set on Toon
-- Updates Toon Burner status in order to see in domoticz if tyou boiler is on for the hotwater or heating or off (still is a undefined number which i must hunt down)
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
TooncurrentModulationLevel = uservariables['UV_TooncurrentModulationLevel'] -- Sensor showing displaying Current modulation leven
ToonInternalBoilerSetpoint = uservariables['UV_ToonInternalBoilerSetpoint']
ToonIP = uservariables['UV_ToonIP']
DomoticzIP = uservariables['UV_DomoticzIP']
json = assert(loadfile "/usr/local/domoticz/var/scripts/lua/JSON.lua")() -- For Synology
local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
local ThermostatInfo = handle:read('*all')
handle:close()
if(ThermostatInfo ~= "") then
-- JSON data from Toon contains a extra "," which should not be there.
ThermostatInfo = string.gsub(ThermostatInfo, ",}", "}")
jsonThermostatInfo = json:decode(ThermostatInfo)
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
currentModulationLevel = tonumber(jsonThermostatInfo.currentModulationLevel)
currentInternalBoilerSetpoint = tonumber(jsonThermostatInfo.currentInternalBoilerSetpoint)
-- 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
-- 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
-- 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
-- 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
-- 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
-- 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
-- Update the modulation level of the burner
if otherdevices_svalues[TooncurrentModulationLevel]+1 ~= currentModulationLevel+1 then
print('Updating the ModulationLevel to new value: ' ..currentModulationLevel)
commandArray[8] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[TooncurrentModulationLevel], currentModulationLevel)}
end
-- Update the Internal Setpoint of the boiler
if otherdevices_svalues[ToonInternalBoilerSetpoint]+1 ~= currentInternalBoilerSetpoint+1 then
print('Updating the currentInternalBoilerSetpoint to new value: ' ..currentInternalBoilerSetpoint)
commandArray[9] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonInternalBoilerSetpoint], currentInternalBoilerSetpoint)}
end
else
print ('Geen data terug')
end
return commandArray