Da wir auch dieses Jahr unsere Script Suite zur Verwaltung und Ansteuerung von Sensoren und Aktoren verschiedener Hersteller erweitern wollen, hier ein kleiner Vorgeschmack auf ein neues Script mit dem sich mehrere Homematik  Temperatur Sensoren in einem Rutsch abfragen und den entsprechenden DomoticZ Geräten zuweisen lassen.

HomeMatic CCU XMLAPI, DomoticZ Scripting engine -> LUA interpreter

Das Script erwartet die Angabe der CCU IP (xmlAPI muss dort installiert sein) und die Zuordnung der localen DomoticZ IDX sowie CCU Temperatur Sensoren IDX in einem Array HMSensors im Format "DOM_IDX","HM_IDX". 

--###################################################################
--#Script Name	: dom_hm_get_temp.lua                                                                                              
--#Description	: get multiple temperatur values from homematic CCU 
--#               and pass them to the right local domotiz devices
--#Args         :                                                                                           
--#Date         : 03. February 2019
--#Author       : Heiko Zschenderlein                                                
--#Email        : Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!
--#Comments     : Development State, to be improved
--#Disclaimer   : Please read the Disclaimer at the end of the script 
--#             : Bitte lesen Sie den Haftungsausschluss am Ende des Scripts
--###################################################################
commandArray = {}
now=os.date("*t")
-- run script every 3 minutes
if now.min % 3 == 0 then

-- function to read xmlAPI output from CCU
function XML_Capture(cmd,flatten)
   local f = assert(io.popen(cmd, 'r'))
   local s = assert(f:read('*a'))
   f:close()
   if flatten  then
      s = string.gsub(s, '^%s+', '')
      s = string.gsub(s, '%s+$', '')
      s = string.gsub(s, '[\n\r]+', ' ')
   end
   return s
end

-- function to update local device values
local function update(idx, value1)
    local cmd = string.format("%d|0|%.2f", idx, value1)
    table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end


debug = false
-- Array to assign local device id`s to the once we need to get the value off the CCU
HMSensors = {[2]=1648,[3]=1499,[4]=1420,[5]=1727}

CCU_IP = "192.168.10.251"
print("...get Data from ".. CCU_IP)

for dom_idx,hm_idx in pairs(HMSensors) do

XML_string=XML_Capture("curl -s 'http://"..CCU_IP.."/addons/xmlapi/state.cgi?datapoint_id="..hm_idx.."'",1)

valid = string.find(XML_string, "<state>")    -- check we are looking in the right place

    if valid == nil then
        print ("Bad XML status read - info NOT updated")
    else


  t = string.find(XML_string,"value=")     -- read position of temperature string
    v = string.find(XML_string,"</state>")      -- read voltage string

 t1 = t+7
t2 = t1+4

 t = string.find(XML_string,"<gauge_temp>")  -- read temperature string
    print(t)
    temp = string.sub(XML_string,t1,t2)
    
    temp1 =tonumber(temp)

    
--    commandstring = 'curl -s "http://192.168.10.180/control?cmd=OLEDCMD,clear" && curl -s "http://192.168.10.180/control?cmd=OLED,1,1,Kueche:%20'..temp1..'%7FC"'
--    os.execute(commandstring) 

update(dom_idx,temp1)

   print("temperature given = "..dom_idx.."'"..temp1.."'")
    end 
 
end

end

return commandArray
--# DISCLAIMER :
--# Downloading and using data from this website occurs at the own risk of the User. The Provider does not accept any liability for damages that occur directly or indirectly through the use of provided data.
--# All logos, trademarks and word marks used, even if not expressly marked as such, are the property of their respective owners.
--# Das Herunterladen und Verwenden von Daten von dieser Website erfolgt auf eigenes Risiko des Benutzers. Der Anbieter übernimmt keine Haftung für Schäden, die direkt oder indirekt durch die Verwendung der bereitgestellten Daten entstehen.
--# Alle verwendeten Logos, Markenzeichen und Wortmarken sind, auch wenn nicht ausdrücklich als solche gekennzeichnet, Eigentum ihrer jeweiligen Inhaber.