• Tag Archieven solar
  • Geroote Toon bedienen met Domoticz

    Nadat je jouw Toon succesvol hebt geroot ga je natuurlijk als eerste je Toon-abonnement bij Eneco opzeggen; het abonnement kost je 4,50 € per maand daar heb je nu niets meer aan. Maar hoe krijg je de data van Toon dan in Domoticz? En hoe kan je via Domoticz de Toon bedienen?

    Na het uitvoeren van onderstaande stappen is het mogelijk om informatie uit de Toon te in Domoticz te laten weergeven en de Toon vanuit Domoticz aan te sturen.

    Toon > Domoticz

    • Huidige temperatuur (omgeving)
    • Ingestelde temperatuur (thermostaat)
    • Ingesteld programma
    • Ingestelde scene
    • Brander informatie (wordt de ketel gebruikt voor CV of Warm Water?)
    • Boiler temperatuur (ingaand en uitgaand)
    • Boiler temperatuur-setpoint
    • Keteldruk
    • Modulatie-level

    Domoticz > Toon

    • Instellen temperatuur (thermostaat)
    • Instellen programma
    • Instellen scene

    (Stap 1)

    User variables

    Allereerst gaan we 13 user variables aanmaken (Setup > More Options > User variables). In onderstaande tabel zie je eerst de “Variable name”, vervolgens het type (allemaal String) en tot slot de “Variable value”. Zorg ervoor dat je de namen en waarden exact overneemt (later kun je de namen eventueel wijzigen, maar dat scheelt voor nu wat debugging als er ergens iets niet goed gaat).

    1: UV_ToonboilerModulationLevel        String Boiler_Modulation_level
    2: UV_ToonboilerPressure               String Boilerdruk
    3: UV_ToonboilerOutTempName            String Temperatuur Boiler Uit
    4: UV_ToonboilerInTempName             String Temperatuur Boiler In
    5: UV_ToonProgramInformationSensorName String ToonProgramInformation
    6: UV_ToonAutoProgramSensorName        String ToonAutoProgram
    7: UV_ToonScenesSensorName             String Toon Scenes
    8: UV_ToonTemperatureSensorName        String Temperatuur Binnen
    9: UV_ToonIP                           String 10.0.0.180
    10: UV_ToonThermostatSensorName         String ToonThermostat
    11: UV_DomoticzIP                       String 10.0.0.1:8080
    12: UV_ToonBurnerName                   String ToonBranderInfo
    13: UV_ToonBoilerTempSetpointSensorName String ToonBoilerTempSetpoint

    Bij UV_ToonIP geeft je als waarde het vaste IP van je Toon in en bij UV_DomoticzIP geef je het IP van Domoticz in inclusief het poort-nummer.

    Virtuele devices

    De volgende stap is om virtuele devices aan te maken, deze hebben we nodig om acties te kunnen uitvoeren of data te kunnen aflezen. Ga naar Setup -> Hardware en kies bij Type voor Dummy. Je mag zeg een herkenbare naam kiezen:

    colandino.nl

     

    Zodra de Dummy Hardware toegevoegd is kunnen de virtuele sensoren gaan aanmaken. Klik hiervoor op Create Virtual Sensors (in het donkerblauw).

    Maak nu de virtuele sensor aan van het type “Temperature” en geef “Temperatuur Binnen” als naam van de sensor in:

    Maak op dezelfde wijze onderstaande virtuele sensoren aan:

    (Stap 2)


    1: ToonThermostat - Thermostat Setpoint sensor
    2: ToonAutoProgram - Selector Switch sensor
    3: ToonProgramInformation - Text sensor
    4: Toon Scenes - Selector Switch sensor
    5: ToonIP - Text Sensor
    6: ToonBranderInfo - Selector Switch sensor
    7: ToonBoilerTempSetpoint - Temperatuur sensor
    8: Temperatuur Boiler In - Temperatuur sensor
    9: Temperatuur Boiler Uit - Temperatuur sensor
    10: Boilerdruk - Pressure sensor
    11: Boiler_Modulation_level - Percentage sensor

    Voordat de scripts ingesteld kunnen worden zal de “ToonIP” Text-sensor ingevuld moeten worden met het IP-adres van de Toon.

    Het eerste IP-adres in onderstaande regel is het IP van Domoticz, het tweede IP-adres is het IP van Toon. Ook moet je bij idx= het IDX-nummer van de ToonIP-textsensor invullen.(Zie nr. 9 van stap 1)
    10.0.0.1:8080/json.htm?type=command&param=udevice&idx=22058&nvalue=0&svalue=10.0.0.180

    Bovenstaande regel wordt niet altijd juist getoond, onderstaande regel zou hetzelfde resultaat moeten geven:
    http://10.0.0.1:8080/json.htm?param=udevice&type=command&idx=22058&nvalue=0&svalue=10.0.0.180

    Geef deze URL in een willekeurig browser in, het resultaat zal dan zijn:
    { “status” : “OK”,
    “title” : “Update Device”
    }

    (Stap 3)

    Sensoren instellen

    Er moeten nog een aantal sensoren ingesteld worden, zodat de Toon hiermee
    bediend kan worden. Ga binnen Domoticz naar het tabblad Switches.

    ToonAutoProgram

    Klik bij “ToonAutoProgram” op “Edit”

    • stel “Hide Off Level” in op “OFF”
    • Pas de “Level Names” aan:
      • 0 Off
      • 10 Nee
      • 20 Ja
      • 30 Tijdelijk
    • Pas de “Level Action” aan, gebruik het IP-adres van de Toon.
      • 0
      • 10 http://10.0.0.180/happ_thermstat?action=changeSchemeState&state=0
      • 20 http://10.0.0.180/happ_thermstat?action=changeSchemeState&state=1
      • 30
    • Druk op “Save” om de wijzigingen op te slaan

    Toon Scenes

    Klik bij “Toon Scenes” op “Edit”

    • stel “Hide Off Level” in op “OFF”
    • Pas de “Level Names” aan:
      • 0 Off
      • 10 Weg
      • 20 Slapen
      • 30 Thuis
      • 40 Comfort
      • 50 Handmatig
    • Pas de “Level Action” aan, gebruik het IP-adres van de Toon.
      • 0
      • 10 http://10.0.0.180/happ_thermstat?action=changeSchemeState&state=2&temperatureState=3
      • 20 http://10.0.0.180/happ_thermstat?action=changeSchemeState&state=2&temperatureState=2
      • 30 http://10.0.0.180/happ_thermstat?action=changeSchemeState&state=2&temperatureState=1
      • 40 http://10.0.0.180/happ_thermstat?action=changeSchemeState&state=2&temperatureState=0
      • 50 http://10.0.0.180/happ_thermstat?action=setSetpoint&Setpoint=60
    • Druk op “Save” om de wijzigingen op te slaan

    BranderInfo

    Klik bij “ToonBranderInfo” op “Edit”

    • Pas de “Level Names” aan:
      • 0 Off
      • 10 CV
      • 20 WW
    • Druk op “Save” om de wijzigingen op te slaan

     

    Scripts

    Om alles goed te laten werken gaan we gebruik maken van twee dzVents scripts. Ga naar Setup > More Options > Events en maak een nieuw dzVents-script aan, getriggerd door ‘device’. Haal de code die erin staat weg en plak ondestaande code erin. Geef het script een herkenbare naam (bv. Toon Setpoint), zet het script op actief en sla het op.

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

    Maak vervolgens nog een dzVents-script aan, dit keer getriggerd door Timer. Haal de code weg en plak onderstaande code erin. Ook nu geef je het script een herkenbare naam (bv. Toon), zet je het op actief en sla je het op.

    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://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_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
    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
    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
    }

    P1 Energie-meting (slimme meter)

    Energie-meting, verbruik van elektra en gas, kun je via een P1-kabel naar je Toon laten versturen. Zelf heb ik ervoor gekozen om met een P1 USB-kabel deze gegevens direct naar Domoticz te sturen. Mocht je deze gegevens via Toon willen laten lopen, dan moet je regel 46, 47, 48, 50, 51, 52, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 68 en 70 un-commenten.

    Tevens moet je op regel 51, 52, 57, 58, 59, 60, 61 en 62 het juiste dev_ nummer invullen. Het juiste nummer kun je vinden door onderstaande URL in te geven in een browser (uiteraard wel het IP van jouw Toon gebruiken):

    http://10.0.0.180/hdrv_zwave?action=getDevices.json

    Het is wat lastig om de juiste dev_nummers te vinden, maar met wat puzzelen moet het wel lukken (de nummers zijn helaas niet voor iedere Toon gelijk).

    Ook moet je nog even regel 20 en 21 un-commenten, en user variables aanmaken met dezelfde naam als in regel 20 en 21 staat.

    UV_P1SmartMeterElectra String Stroom
    UV_P1SmartMeterGasMeterStand String Gas

    Tot slot moet je nog een virtuele gas-sensor (naam: Gas) én een virtuele stroom-sensor (naam: Stroom) aanmaken.

    Testen

    Zodra alle dummy sensors, user variables en scripts goed zijn ingeladen kan er binnen de verschillende tabbladen in Domoticz informatie uitgelezen worden of instellingen ingesteld worden.

    Via het tabblad “Temperature” kan bij “ToonTemperature” de omgevingstemperatuur van de Toon worden uitgelezen. De sensor “ToonBoilerTempSetpoint” laat de temperatuur van de Boiler in de CVketel zien.

    Via het tabblad “Utility” kan bij “ToonThermostat” de temperatuur ingesteld worden welke daarna binnen enkele seconden doorgevoerd zou moeten worden in de Toon. De sensor “ToonProgramInformation” laat de ingestelde temperatuur zien. De sensor “ToonIP” laat het IP-adres van de Toon zien zoals eerder is ingesteld. De sensor Stroom en Gas laten het actuele verbruik zien en de meterstand.

    Via het tabblad “Switches” kan bij “ToonScenes” een scene ingesteld worden, bijvoorbeeld “Away” of “Sleep”.
    Ook kan er bij “ToonAutoProgram” ingesteld worden of het in de Toon ingestelde programma aan- of uitgezet moet worden. De sensor “ToonBranderInfo” laat zien of de CV-ketel gebruikt wordt voor CVverwarming(CV) of voor warm water (WW).

    De sensoren “ToonBoilerTempSetpoint” en “ToonBranderInfo” werken alleen als de Toon modulair is aangesloten op de CV-ketel.


  • Datasheets

    Arduino
    Arduino gebruiken om ATTiny 45/85 te programeren
    ATMEGA328 & Arduino pinout
    ATmega328pu pinout
    Arduino ATmega8 pinout
    Arduino DUE pinout
    Arduino Leonardo pinout
    Arduino MEGA pinout
    Arduino Micro pinout
    Arduino MINI pinout
    Arduino Pro MINI pinout
    Arduino UNO pinout
    Arduino YUN pinout


    Amtel
    Amtel microcontrollers datasheets en documenten KLIK


    ATmega8(L) – Complete Datasheet
    ATmega8(L) – Summary Datasheet
    Alle ATmega8 documenten en datasheets KLIK Lees verder  Bericht ID 5410