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, TerrorSource, Toonz

Re: Toon met Domoticz: IDX 0 not found!

Postby Edwin66 » Wed Sep 12, 2018 10:05 am

Ik ga hier eens rustig voor zitten, dit weekeinde, nu we nog geen verwarming nodig hebben. Straks in de stookperiode wordt dat niet echt gewaardeerd. :)
Toon® (rooted) | Hue bulbs | TRÅDFRI bulbs | Smart Plug | Domoticz latest BETA |

I'm not a programmer, just wish things work MY way
Edwin66
Starting Member
Starting Member
 
Posts: 47
Joined: August 2018

Re: Toon met Domoticz: IDX 0 not found!

Postby Edwin66 » Sun Sep 23, 2018 10:54 am

madpatrick wrote:Clinthighway,

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

1e:


Vervangen deze scripts de scripts uit de handleiding, of zijn het toevoegingen?

Edit: Nevermind, vervangt de oude scripts dus. Nu alleen nog de nil-error op regel 81 op zien te lossen
Toon® (rooted) | Hue bulbs | TRÅDFRI bulbs | Smart Plug | Domoticz latest BETA |

I'm not a programmer, just wish things work MY way
Edwin66
Starting Member
Starting Member
 
Posts: 47
Joined: August 2018

Re: Toon met Domoticz: IDX 0 not found!

Postby madpatrick » Sun Sep 23, 2018 1:06 pm

Edwin66 wrote:
madpatrick wrote:Clinthighway,

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

1e:


Vervangen deze scripts de scripts uit de handleiding, of zijn het toevoegingen?

Edit: Nevermind, vervangt de oude scripts dus. Nu alleen nog de nil-error op regel 81 op zien te lossen


Deze vervangen de scripts uit de handleiding.
Let op: er zitten nog een aantal fouten in mijn vorige post (Dzvents en LUA door elkaar heen geknipt en geplakt.)
Ook heb ik er er nog een extra toevoeging in geplaatst: Boiler Modulation Level

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
-- Updates Toon boilerModulationLevel sensor to value set on Toon

commandArray = {}
-- uservariables
    ToonIP = uservariables['UV_ToonIP']
    DomoticzIP = uservariables['UV_DomoticzIP']
    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
    ToonboilerModulationLevel = uservariables['UV_ToonboilerModulationLevel'] -- Sensor showing current Boiler Modulation Level
   
-- 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)

    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))  -- afgeronde getallen is voldoende
    currentboilerOutTemp = tonumber(jsonBoilerInfo.boilerOutTemp)
    currentboilerOutTemp = tonumber(string.format("%.0f", currentboilerOutTemp))  -- afgeronde getallen is voldoende
    currentboilerPressure = tonumber(jsonBoilerInfo.boilerPressure)
    currentboilerModulationLevel = tonumber(jsonBoilerInfo.boilerModulationLevel) --Toon Modulation Level
   
-- 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 = '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
           
-- 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 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)}
            -- update the boilerModulationLevel
            print('Updating boiler Modulation Level to value: ' ..currentboilerModulationLevel)
            commandArray[11] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonboilerModulationLevel], currentboilerModulationLevel)}
        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)}
            -- update the boilerModulationLevel
            print('Updating boiler Modulation Level to value: ' ..currentboilerModulationLevel)
            commandArray[11] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonboilerModulationLevel], currentboilerModulationLevel)}
        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
       
-- update the boilerModulationLevel
        --if otherdevices_svalues[ToonboilerModulationLevel]*100 ~= currentboilerModulationLevel*100 then
        --    print('Updating boiler Modulation Level to value: ' ..currentboilerModulationLevel)
        --    commandArray[11] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonboilerModulationLevel], currentboilerModulationLevel)}
        --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


Image

Image
User avatar
madpatrick
Member
Member
 
Posts: 67
Joined: December 2017
Location: Zuid-Holland

Re: Toon met Domoticz: IDX 0 not found!

Postby Edwin66 » Sun Sep 23, 2018 3:11 pm

ik heb nu jouw voorbeeld gevolgd, zowel voor de 2 scripts als de user-variabelen, maar blijf de rotte foutmelding houden

Code: Select all
2018-09-23 16:09:16.916 Error: EventSystem: in Toon_Getinfo_lua: [string "-- Version 1:..."]:87: attempt to perform arithmetic on field '?' (a nil value)
Toon® (rooted) | Hue bulbs | TRÅDFRI bulbs | Smart Plug | Domoticz latest BETA |

I'm not a programmer, just wish things work MY way
Edwin66
Starting Member
Starting Member
 
Posts: 47
Joined: August 2018

Re: Toon met Domoticz: IDX 0 not found!

Postby madpatrick » Sun Sep 23, 2018 3:29 pm

Edwin66 wrote:ik heb nu jouw voorbeeld gevolgd, zowel voor de 2 scripts als de user-variabelen, maar blijf de rotte foutmelding houden

Code: Select all
2018-09-23 16:09:16.916 Error: EventSystem: in Toon_Getinfo_lua: [string "-- Version 1:..."]:87: attempt to perform arithmetic on field '?' (a nil value)

Het lijkt dat er ergens een naam niet goed staan. (regel 87)
Check nog even goed alle namen van je dummy schakelaars en gebruikersvariabelen. Het is hoofdletter gevoelig

Code: Select all
UV_ToonboilerModulationLevel            String                       ModulationLevel
UV_ToonboilerPressure                   String                       Keteldruk
UV_ToonboilerOutTempName                String                       BoilerOutletTemp
UV_ToonboilerInTempName                 String                       BoilerInletTemp
UV_ToonBurnerName                       String                       Ketelstand
UV_ToonBoilerTempSetpointSensorName     String                       Toon Boiler
UV_DomoticzIP                           String                       192.168.1.1:9200
UV_ToonProgramInformationSensorName     String                       Toon Information
UV_ToonAutoProgramSensorName            String                       Toon Auto Program
UV_ToonChangedByDomoticz                Integer                       0
UV_ToonScenesSensorName                 String                       Toon Scenes
UV_ToonTemperatureSensorName            String                       Kamer Temperatuur
UV_ToonIP                               String                       192.168.1.143
UV_ToonThermostatSensorName             String                       Toon Thermostaat
User avatar
madpatrick
Member
Member
 
Posts: 67
Joined: December 2017
Location: Zuid-Holland

Re: Toon met Domoticz: IDX 0 not found!

Postby TerrorSource » Sun Sep 23, 2018 4:48 pm

madpatrick wrote:
Edwin66 wrote:ik heb nu jouw voorbeeld gevolgd, zowel voor de 2 scripts als de user-variabelen, maar blijf de rotte foutmelding houden

Code: Select all
2018-09-23 16:09:16.916 Error: EventSystem: in Toon_Getinfo_lua: [string "-- Version 1:..."]:87: attempt to perform arithmetic on field '?' (a nil value)

Het lijkt dat er ergens een naam niet goed staan. (regel 87)
Check nog even goed alle namen van je dummy schakelaars en gebruikersvariabelen. Het is hoofdletter gevoelig


Remove the top comment lines from all scripts.
they start with --
TerrorSource
Member
Member
 
Posts: 211
Joined: May 2017

Re: Toon met Domoticz: IDX 0 not found!

Postby Edwin66 » Sun Sep 23, 2018 7:39 pm

[delete]
Last edited by Edwin66 on Thu Sep 27, 2018 7:58 pm, edited 1 time in total.
Toon® (rooted) | Hue bulbs | TRÅDFRI bulbs | Smart Plug | Domoticz latest BETA |

I'm not a programmer, just wish things work MY way
Edwin66
Starting Member
Starting Member
 
Posts: 47
Joined: August 2018

Re: Toon met Domoticz: IDX 0 not found!

Postby Edwin66 » Tue Sep 25, 2018 6:28 pm

Eindelijk alles weer werkend, tenminste... tot zo ver. Nu dus weer kijken naar dit probleem.

Mijn UV tabel:

Volgens mij is die gelijk

ik zien nu dat een UV er twee keer in voorkomt.
Attachments
Screen Shot 2018-09-25 at 19.41.56.png
Screen Shot 2018-09-25 at 19.41.56.png (129.05 KiB) Viewed 1282 times
Last edited by Edwin66 on Thu Sep 27, 2018 10:34 am, edited 1 time in total.
Toon® (rooted) | Hue bulbs | TRÅDFRI bulbs | Smart Plug | Domoticz latest BETA |

I'm not a programmer, just wish things work MY way
Edwin66
Starting Member
Starting Member
 
Posts: 47
Joined: August 2018

Re: Toon met Domoticz: IDX 0 not found!

Postby Edwin66 » Thu Sep 27, 2018 7:59 pm

Eindelijk werkend, op de IDX 0 not found fout na. Twee typo's in de namen van de UV en de switches, en twee UV's over het hoofd gezien.
Toon® (rooted) | Hue bulbs | TRÅDFRI bulbs | Smart Plug | Domoticz latest BETA |

I'm not a programmer, just wish things work MY way
Edwin66
Starting Member
Starting Member
 
Posts: 47
Joined: August 2018

Previous

Return to Toon issues and support (Nederlands toegestaan)

Who is online

Users browsing this forum: No registered users and 0 guests