That would be great, thanks.
One other thing, i do have high and low tariv but i cant figure this out from the output i have created, how do i read this?
Moderator: leecollings
That would be great, thanks.
Try the script attached as a file. I've replaced dev_3.3 to dev_3.2 and removed the adding of the 2 tariffs.
Did you find out how to fix this?terrorsource wrote: ↑Wednesday 10 May 2017 17:59 [...]
Is working, but gives an error in logs:[...]Error: EventSystem: in ToonThermostat: [string "-- Script used for Toon Thermostaat utility d..."]:8: bad argument #1 to 'pairs' (table expected, got nil)
Code: Select all
if currentProgramState == 0 then currentProgramState = '10' -- No
elseif currentProgramState == 1 then currentProgramState = '20' -- Yes
elseif currentProgramState == 2 then currentProgramState = '30' -- Temporary
end
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
-- Udates 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
ToonIP = uservariables['UV_ToonIP']
DomoticzIP = uservariables['UV_DomoticzIP']
json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Raspberry
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, ",}", "}")
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
-- 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
--
return commandArray
Code: Select all
<hcb_web>
<port>10080</port>
<defaultEntry>/qmf/www/</defaultEntry>
<enforceWhitelist>0</enforceWhitelist>
<whitelist>
<item>hdrv_zwave</item>
<item>hdrv_hue</item>
<item>happ_thermstat</item>
</whitelist>
</hcb_web>
FunFair wrote: ↑Monday 13 November 2017 12:30Try the script attached as a file. I've replaced dev_3.3 to dev_3.2 and removed the adding of the 2 tariffs.
If you don't have a smart meter I don't know if it's possible to differentiate between low and normal tariff. Toon does not store these values seperately to my knowledge.
The gas readout script does not have to be altered.
After installing the toon store and change the qmf_release.xml to the following it's working now.Eggybert wrote: ↑Wednesday 20 December 2017 19:37Code: Select all
<hcb_web> <port>10080</port> <defaultEntry>/qmf/www/</defaultEntry> <enforceWhitelist>0</enforceWhitelist> <whitelist> <item>hdrv_zwave</item> <item>hdrv_hue</item> <item>happ_thermstat</item> </whitelist> </hcb_web>
Code: Select all
<hcb_web>
<defaultEntry>/hdrv_zwave/</defaultEntry>
<enforceWhitelist>0</enforceWhitelist>
<whitelist>
<item>hdrv_zwave</item>
<item>hdrv_hue</item>
</whitelist>
</hcb_web>
Code: Select all
return {
active = true,
on = {
timer = {
'every minute'
}
},
execute = function(domoticz, device)
domoticz.log('Script temp active')
if ( domoticz.devices('Toon Temperature').temperature >= 19.0 ) then
domoticz.log('Toon temp te hoog')
end
end
}
Code: Select all
return {
active = true,
on = {
devices = {
'Toon Temperature'
}
},
execute = function(domoticz, device)
domoticz.log('Script TempKamerTeHoog active')
if (device.temperature >= 19.0 ) then
domoticz.log('Temperatuur kamer is te hoog')
end
end
}
Users browsing this forum: Google [Bot] and 1 guest