Toon met Domoticz: IDX 0 not found!

If your (rooted) Toon doesn't do what it's supposed to, post here. Dutch allowed / Posten in 't Nederlands toegestaan.

Moderators: marcelr, TheHogNL, Toonz

Clinthighway
Starting Member
Starting Member
Posts: 13
Joined: Sat Aug 11, 2018 11:52 pm

Toon met Domoticz: IDX 0 not found!

Post by Clinthighway »

Hallo allemaal,

Ik heb een tijde terug aan de handleiding van TerrorSource domoticaforum.eu/viewtopic.php?f=87& ... 6%23p86846
Mijn Toon gekoppeld aan Domoticz, Alleen krijg het niet volledig werkend.

Temperatuur uitlezen lukt, Toonscenes aanpassen (Thuis,Weg, Slaapstand) aanpassen lukt en wordt zonder problemen door gegeven aan de Toon.
Behalve de optie "Toontermostat" werkt niet, (Deze wordt ook in het rood weer gegeven).

Als ik de temperatuur aanpas schiet deze automatisch weer terug naar de standaard 20 'C.
Dit in combinatie met de geven fout log "2018-08-11 23:55:00.466 Error: EventSystem: UpdateDevice IDX 0 not found!"

Die waarschijnlijk afkomstig is van de LUA script "Toon" want als ik deze uitschakel krijg ik geen nieuwe Error te zien in de fout log.

Heb al diverse dingen geprobeerd.

Clean install Raspberry + Domoticz
Diverse software versies van Domoticz.
Toon reset (Software versie 4.16.8 )
Alles gecontroleerd maar kan niks geks vinden.

Hopelijk dat iemand hier nog iets weet waar ik naar zou kunnen kijken om het op te lossen ?

Alvast bedankt.
TerrorSource
Administrator
Administrator
Posts: 494
Joined: Thu May 04, 2017 9:28 pm

Re: Toon met Domoticz: IDX 0 not found!

Post by TerrorSource »

Heb je al in de topic gekeken waar alle info vandaan komt?

https://www.domoticz.com/forum/viewtopic.php?t=11421
mAiden
Member
Member
Posts: 330
Joined: Mon Jul 10, 2017 10:22 am

Re: Toon met Domoticz: IDX 0 not found!

Post by mAiden »

Hoe ziet je user variabele eruit? Blijkbaar mis je er een, aangezien hij een idx niet kan vinden.
Member of the Toon Software Collective
Clinthighway
Starting Member
Starting Member
Posts: 13
Joined: Sat Aug 11, 2018 11:52 pm

Re: Toon met Domoticz: IDX 0 not found!

Post by Clinthighway »

Image

user variabele moet goed zijn denk ik ?
Alles staat er in als goed is zonder spel fouten.\

Daarom snap ik de IDX fout ook niet.
Clinthighway
Starting Member
Starting Member
Posts: 13
Joined: Sat Aug 11, 2018 11:52 pm

Re: Toon met Domoticz: IDX 0 not found!

Post by Clinthighway »

Gedeeltelijk het probleem gevonden.

Als ik de Toon script gebruikt die meegeleverd zit met handleiding van TerrorSource krijg ik de IDX 0 error vanuit het laatste stukje script.
Terwijl de Dumy hardware en user variabele goed staan naar mij idee.

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)}
			end

    end
Als laatste stukje script verwijderd krijg ik geen IDX 0 error meer.
En kan de thermostaat gebruiken in Domoticz.

Alleen krijg ik een andere error te zien waardoor de temperatuur niet geupdate wordt in Domoticz.

"Error: EventSystem: in Toon: [string "-- Version 1:
..."]:143: 'end' expected (to close 'if' at line 45) near <eof>
"
Als zo lees betreft het regel 45 en 143.

regel 45

Code: Select all

 if jsonThermostatInfo ~= nil then

regel 143

Code: Select all

 return commandArray 
Alleen dit lijtk mij in het geheel goed te staan.
Zitten geen dubbele If's of ends in.

Misschien dat iemand het kan zien ?
Heb laatste stukje script effe uitgezet waarop de IDX 0 error van afkomstig is.

Code: Select all

-- Version 1:
-- 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

-- Version 2
-- Improvements:
-- - Check each value for a nil value (in case of a failed request)
-- - Changed all global allocations to local. This is to prevent a memory leak. (This is how LUA works)
-- - Added a timeout to curl (--max-time) which will prevent the script from running for more than 10 seconds and thus decreasing the warnings, in case Toon can't be reached.
--   Please take note that this will also ignore the values for that particular request.
-- Source: https://www.domoticz.com/forum/viewtopic.php?f=34&t=11421&start=20#p125837

-- Extra improvement:
-- Updates Toon Burner status in order to see in domoticz if your boiler is on for the hotwater or heating or off
-- Updates Toon Boiler temp

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']
    
    json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()  -- For Raspberryy
    
    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
    currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
    currentBoilerSetPoint = tonumber(jsonThermostatInfo.currentInternalBoilerSetpoint)
	currentBurnerInfo = tonumber(jsonThermostatInfo.burnerInfo)
   
        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 commandArray
mAiden
Member
Member
Posts: 330
Joined: Mon Jul 10, 2017 10:22 am

Re: Toon met Domoticz: IDX 0 not found!

Post by mAiden »

Je mag best mij scripts die ik gebruik ervoor, proberen?

Toon Thermostaat:

Code: 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 commandArray
Toon zonder de branderinfo

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

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
    ToonProgramInformationSensorName = uservariables['UV_ToonProgramInformationSensorName'] -- Sensor showing displaying program information status
    ToonIP = uservariables['UV_ToonIP']
    DomoticzIP = uservariables['UV_DomoticzIP']

    json = assert(loadfile "/home/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()
    
    jsonThermostatInfo = json:decode(ThermostatInfo)
    
    currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
    local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
    currentTemperature = tonumber(string.format("%.1f", currentTemperature))  -- 1 decimaal is voldoende
    currentProgramState = tonumber(jsonThermostatInfo.programState)
    currentActiveState = tonumber(jsonThermostatInfo.activeState)
    currentNextTime = jsonThermostatInfo.nextTime
    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
        
--
Even opletten dat je de correcte user variable heb toegevoegd.. Zal voor de zekerheid hier onder mij user variable zetten..
User.png
User.png (35.53 KiB) Viewed 11316 times
Gas en Stroom variable is niet nodig, dit zijn aparte LUA scripts die ik gebruik, om het gas en stroom verbruik uit Toon te lezen.
Member of the Toon Software Collective
Clinthighway
Starting Member
Starting Member
Posts: 13
Joined: Sat Aug 11, 2018 11:52 pm

Re: Toon met Domoticz: IDX 0 not found!

Post by Clinthighway »

Heb je script toegevoegd.

Krijg op het eerste gezicht geen fout log meer te zien.

Alleen werkt met de script te Thermostaat niet meer.

(Ben trouwens in de toekomst wel benieuwd naar je Stroom/gas script :D )
Clinthighway
Starting Member
Starting Member
Posts: 13
Joined: Sat Aug 11, 2018 11:52 pm

Re: Toon met Domoticz: IDX 0 not found!

Post by Clinthighway »

Heb je script even naast die van mij gelegd met Note++ en even compare gedaan.

Verschill zit hem er in bij regel nr 39

Ik moet hier voor nog een keer "end" invullen om me thermostaat te laten werken.
Alleen als ik dit invul krijg weer een error log te zien

"EventSystem: in Toon: [string "commandArray = {}..."]:39: <eof> expected near 'end'"

Image

Dus op een of andere manier zit er toch iets fout.

Voor de rest is het script precies het zelfde.

Code: 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
    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()

	
    
    jsonThermostatInfo = json:decode(ThermostatInfo)
    
    currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
    local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100

    currentProgramState = tonumber(jsonThermostatInfo.programState)
    currentActiveState = tonumber(jsonThermostatInfo.activeState)
    currentNextTime = jsonThermostatInfo.nextTime
    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    
    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
        



return commandArray
mAiden
Member
Member
Posts: 330
Joined: Mon Jul 10, 2017 10:22 am

Re: Toon met Domoticz: IDX 0 not found!

Post by mAiden »

Zie wat je bedoeld.. Ga daar morgen even naar kijken voor je, zodat wel functioneert.

Kom er op terug
Member of the Toon Software Collective
mAiden
Member
Member
Posts: 330
Joined: Mon Jul 10, 2017 10:22 am

Re: Toon met Domoticz: IDX 0 not found!

Post by mAiden »

@Clinthighway:

Zoals beloofd, kwam ik er op terug.. Deze Dzevents werken wel bij mij..

Code: Select all


return {
	on = {
		timer = {
			'every minute'
		}
	},
	execute = function(domoticz)
        local ToonThermostatSensorName = domoticz.variables('UV_ToonThermostatSensorName').value -- Sensor showing current setpoint
        local ToonTemperatureSensorName = domoticz.variables('UV_ToonTemperatureSensorName').value -- Sensor showing current room temperature
        local ToonScenesSensorName  = domoticz.variables('UV_ToonScenesSensorName').value -- Sensor showing current program
        local ToonAutoProgramSensorName = domoticz.variables('UV_ToonAutoProgramSensorName').value -- Sensor showing current auto program status
        local ToonProgramInformationSensorName = 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
    
        -- Handle json
        --local json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")()  -- For Windows
        local json = assert(loadfile "/home/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 currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
        local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
        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
            end
        local currentNextTime = jsonThermostatInfo.nextTime
        local currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
        local currentBoiletSetPoint = jsonThermostatInfo.currentInternalBoilerSetpoint
        ----
        
        -- Update the thermostat sensor to current setpoint
        if domoticz.devices(ToonThermostatSensorName).setPoint*100 ~= currentSetpoint*100 then
            domoticz.log('Updating thermostat sensor to new set point: ' ..currentSetpoint)
            domoticz.devices(ToonThermostatSensorName).updateSetPoint(currentSetpoint).silent()
        end
        

        -- Update the temperature sensor to current room temperature
        if domoticz.round(domoticz.devices(ToonTemperatureSensorName).temperature, 1) ~= domoticz.round(currentTemperature, 1) then 
            domoticz.log('Updating the temperature sensor to new value: ' ..currentTemperature)
            domoticz.devices(ToonTemperatureSensorName).updateTemperature(currentTemperature)
        end
        
        -- Update the toon scene selector sensor to current program state
        if domoticz.devices(ToonScenesSensorName).level ~= currentActiveState then  -- Update toon selector if it has changed
            domoticz.log('Updating Toon Scenes selector to: '..currentActiveState)
            domoticz.devices(ToonScenesSensorName).switchSelector(currentActiveState).silent()
        end
        
        -- Updates the toon auto program switch 
        if domoticz.devices(ToonAutoProgramSensorName).level ~= currentProgramState then -- Update toon auto program selector if it has changed
            domoticz.log('Updating Toon Auto Program selector to: '..currentProgramState)
            domoticz.devices(ToonAutoProgramSensorName).switchSelector(currentProgramState).silent()
        end
        
        -- Updates the toon program information text box
        if currentNextTime == 0 or currentNextSetPoint == 0 then
            ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
        else
            ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
        end
        
        if domoticz.devices(ToonProgramInformationSensorName).text ~= ToonProgramInformationSensorValue then
            domoticz.log('Updating Toon Program Information to: '..ToonProgramInformationSensorValue)
            domoticz.devices(ToonProgramInformationSensorName).updateText(ToonProgramInformationSensorValue)
        end
	end
}

Ik heb wel een Dummy aangemaakt, die als thermostaat dient nu, waar je dus ook de temp hoger en lager kan instellen..
Member of the Toon Software Collective
Clinthighway
Starting Member
Starting Member
Posts: 13
Joined: Sat Aug 11, 2018 11:52 pm

Re: Toon met Domoticz: IDX 0 not found!

Post by Clinthighway »

@ mAiden.

Top :)

Scenes en de thermostaat werkt zo als het moet :)
En de error log blijft leeg :)

Alleen wilt de "ToonTemperature" niet meer update pfff.
Lijkt wel als de thermostaat werkt dan de temperatuur niet en anders om pfff
mAiden
Member
Member
Posts: 330
Joined: Mon Jul 10, 2017 10:22 am

Re: Toon met Domoticz: IDX 0 not found!

Post by mAiden »

Clinthighway wrote:@ mAiden.

Top :)

Scenes en de thermostaat werkt zo als het moet :)
En de error log blijft leeg :)

Alleen wilt de "ToonTemperature" niet meer update pfff.
Lijkt wel als de thermostaat werkt dan de temperatuur niet en anders om pfff
Komt goed. Heb morgen dagje vrij van werk, zal er dan is volledig in duiken.
Member of the Toon Software Collective
Clinthighway
Starting Member
Starting Member
Posts: 13
Joined: Sat Aug 11, 2018 11:52 pm

Re: Toon met Domoticz: IDX 0 not found!

Post by Clinthighway »

Top dat zou helemaal super zijn :D,

Duizendmaal thanks.

off-topic vraagje.

Is het trouwens lastig om de Stroom / Gas status door te linken naar Domoticz ?
En weet jij toevallig waarom met de eerste LUA scripts de Boilerstatus niet werkte ?
Komt dat omdat ik met Toon geen ketelprofiel ingesteld krijgt ?
Clinthighway
Starting Member
Starting Member
Posts: 13
Joined: Sat Aug 11, 2018 11:52 pm

Re: Toon met Domoticz: IDX 0 not found!

Post by Clinthighway »

mAiden wrote:
Clinthighway wrote:@ mAiden.

Top :)

Scenes en de thermostaat werkt zo als het moet :)
En de error log blijft leeg :)

Alleen wilt de "ToonTemperature" niet meer update pfff.
Lijkt wel als de thermostaat werkt dan de temperatuur niet en anders om pfff
Komt goed. Heb morgen dagje vrij van werk, zal er dan is volledig in duiken.
Ondertussen al tijd er voor gehad :) ?
User avatar
madpatrick
Member
Member
Posts: 104
Joined: Wed Dec 06, 2017 9:52 pm
Location: Zuid-Holland

Re: Toon met Domoticz: IDX 0 not found!

Post by madpatrick »

Clinthighway,

Ik had zelf ook problemen met de scripts en heb deze als volgt.
Let goed op de Gebruikersvariabelen !

1e:
- Toon_Getinfo_lua
- Lua
- Device

Code: Select all

-- Version 1:
-- 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

-- Version 2
-- Improvements:
-- - Check each value for a nil value (in case of a failed request)
-- - Changed all global allocations to local. This is to prevent a memory leak. (This is how LUA works)
-- - Added a timeout to curl (--max-time) which will prevent the script from running for more than 10 seconds and thus decreasing the warnings, in case Toon can't be reached.
--   Please take note that this will also ignore the values for that particular request.
-- Source: https://www.domoticz.com/forum/viewtopic.php?f=34&t=11421&start=20#p125837

-- Extra improvement:
-- Updates Toon Burner status in order to see in domoticz if your boiler is on for the hotwater or heating or off
-- Updates Toon Boiler temp
-- 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 = {}

    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 
	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']
    
-- 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 "/var/domoticz/scripts/lua/JSON.lua")()  -- For Linux (ClearOS)
--  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()
    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)
    -- 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
    currentTemperature = tonumber(string.format("%.1f", currentTemperature))  -- 1 decimaal is voldoende
    currentProgramState = tonumber(jsonThermostatInfo.programState)
    currentActiveState = tonumber(jsonThermostatInfo.activeState)
    currentNextTime = jsonThermostatInfo.nextTime
	currentBurnerInfo = tonumber(jsonThermostatInfo.burnerInfo)
    currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
	currentBoilerSetPoint = tonumber(jsonThermostatInfo.currentInternalBoilerSetpoint)
	currentboilerInTemp = tonumber(jsonBoilerInfo.boilerInTemp)
    currentboilerInTemp = tonumber(string.format("%.0f", currentboilerInTemp))  -- %.1f 1 decimaal is voldoende
    currentboilerOutTemp = tonumber(jsonBoilerInfo.boilerOutTemp)
     currentboilerOutTemp = tonumber(string.format("%.0f", currentboilerOutTemp))  --%.1f 1 decimaal is voldoende
    currentboilerPressure = tonumber(jsonBoilerInfo.boilerPressure)
   
        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 = 'Temp : ' ..currentSetpoint.. '° / ' ..currentTemperature.. '°'
            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

    -- 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


2e:
- Toon_Thermostat
- Lua
- Device

Code: Select all

-- Script used for Toon Thermostaat utility device, upon changing temp in Domoticz, temperature is sent to Toon. 
--
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 commandArray

Gebruikersvariabelen

Code: Select all

13	UV_ToonboilerPressure				String		Keteldruk
12	UV_ToonboilerOutTempName			String		BoilerOutletTemp
11	UV_ToonboilerInTempName			String		BoilerInletTemp
10	UV_ToonBurnerName					String		Ketelstand	
9	UV_ToonBoilerTempSetpointSensorName	String		Toon Boiler
8	UV_DomoticzIP						String		192.168.1.1:9200	
7	UV_ToonProgramInformationSensorName	String		Toon Information
6	UV_ToonAutoProgramSensorName		String		Toon Auto Program
5	UV_ToonChangedByDomoticz			Integer		0
4	UV_ToonScenesSensorName			String		Toon Scenes
3	UV_ToonTemperatureSensorName		String		Kamer Temperatuur
2	UV_ToonIP						String		192.168.1.143
1	UV_ToonThermostatSensorName		String		Toon Thermostaat
Post Reply

Return to “Toon issues and support (Nederlands toegestaan)”