Moin,
hier wollte ich mal kurz für alle interessierten die Anbindung von Openhab an Domiq präsentieren.
Ich habe hierzu das TCP-Binding benutzt:
openhab.cfg
Hier mal einige Items Einträge als Beispiel
domiq.items
Dann benötigt man noch Rules zum einen um die Daten von der Domiq zu verarbeiten:
domiq.rules
Und zum anderen um Befehle an die Domiq zu senden:
domiqsenden.rules
An der Domiq muss man nichts ändern, die plappert vor sich hin und teilt alles mit Openhab. Somit kann ich z.B. in der Domiq einfach eine Variable erfinden
und diese z.B. durch einen Taster setzen lassen, z.B. VAR.hue.event.hue=1 Da Openhab das mitbekommt kann ich darauf eine Rule anwenden und somit z.B.
eine Hue Lampe schalten s.o. oder den Denon AVR und die Squeezebox anschalten etc....
hier wollte ich mal kurz für alle interessierten die Anbindung von Openhab an Domiq präsentieren.
Ich habe hierzu das TCP-Binding benutzt:
openhab.cfg
Code:
################################# TCP - UDP Binding ################################### # # all parameters can be applied to both the TCP and UDP binding unless # specified otherwise # Port to listen for incoming connections tcp:port=3000 # Cron-like string to reconnect remote ends, e.g for unstable connection or remote ends tcp:reconnectron=0 0 0 * * # Interval between reconnection attempts when recovering from a communication error, # in seconds tcp:retryinterval=5 # Queue data whilst recovering from a connection problem (TCP only) tcp:queue=true # Maximum buffer size whilst reading incoming data tcp:buffersize=1024 # Share connections within the Item binding configurations #tcp:itemsharedconnections=true # Share connections between Item binding configurations #tcp:bindingsharedconnections=true # Share connections between inbound and outbound connections #tcp:directionssharedconnections=true # Allow masks in ip:port addressing, e.g. 192.168.0.1:* etc tcp:addressmask=true # Pre-amble that will be put in front of data being sent #tcp:preamble='' # Post-amble that will be appended to data being sent #tcp:postamble='' # Perform all write/read (send/receive) operations in a blocking mode, e.g. the binding # will wait for a reply from the remote end after data has been sent tcp:blocking=true # timeout, in milliseconds, to wait for a reply when initiating a blocking write/read # operation tcp:timeout=3000 # Update the status of Items using the response received from the remote end (if the # remote end sends replies to commands) tcp:updatewithresponse=true # Timeout - or 'refresh interval', in milliseconds, of the worker thread tcp:refreshinterval=250 # Timeout, in milliseconds, to wait when "Selecting" IO channels ready for communication #tcp:selecttimeout=1000 # Used character set #tcp:charset=ASCII
domiq.items
Code:
String domiq { tcp=">[[b][i]IP-DOMIQ[/i][/b]:4224:'REGEX((.*))']" } Contact s_sofafenster "Wozi Fenster [%S]" <contact> (g_fenster,g_mysql) Dimmer l_wozi "Wozi" <light> (g_mysql,g_l_dg) Rollershutter r_wozi "Wozi [%S]" <rollershutter> (g_rolladen,g_rolladeneg,g_mysql) Number lux "Helligkeit [%.1f Lux]" <sun> (gwettertemp,gwetter,g_mysql) Number t_wozi "Wohnzimmer [%.1f °C]" <temperature> (g_mysql,g_wozi,gwettertemp,gtemp,g_t_wozi) String t_wozi_min "- Min. Temp [%s]" <temperature> String t_wozi_max "- Max. Temp [%s]" <temperature>
domiq.rules
Code:
import org.openhab.core.library.types.* import org.openhab.model.script.actions.* import java.lang.* rule "domiqs" when Item domiq received update then var txt = domiq.state.toString var Integer anzahl = txt.split("\\s+").size var String[] txtleer txtleer = txt.split("\\s+") var String[] txt_ergeb for (i: 0 .. (anzahl - 1)) { txt_ergeb = txtleer.get(i).split("=") if (txt_ergeb.get(1) != ("?")) { if (txt_ergeb.get(0) == ("LCN.value.0.9.r2")) t_wozi.postUpdate((new Double(txt_ergeb.get(1)) - 1000)/10) else if (txt_ergeb.get(0) == ("VAR.KOBELKA.event.lux")) lux.postUpdate(txt_ergeb.get(1)) else if (txtleer.get(i) == ("LCN.sensor.0.21.3=1")) s_sofafenster.postUpdate(CLOSED) else if (txtleer.get(i) == ("LCN.sensor.0.21.3=0")) s_sofafenster.postUpdate(OPEN) else if (txt_ergeb.get(0) == ("VAR.roll_position_rel.21.2")) r_sofafenster.postUpdate(txt_ergeb.get(1)) else if (txt_ergeb.get(0) == ("LCN.output.0.55.1")) { var leddimm = new Integer(txt_ergeb.get(1)) * 5 l_wozi.postUpdate(leddimm) } else if (txtleer.get(i) == ("VAR.hue.event.hue=1")) { cSofaecke.sendCommand("80,100,57") } else if (txtleer.get(i) == ("VAR.hue.event.hue=0")) { Sofaecke.sendCommand(OFF) } else end
domiqsenden.rules
Code:
import org.openhab.core.library.types.* import org.openhab.model.script.actions.* import java.lang.* rule "Dimmed Light FlurEG" when Item l_flureg received command then var Number percent = 0 var Number percentd = 0 if(l_flureg.state instanceof DecimalType){ percent = l_flureg.state as DecimalType percentd = (l_flureg.state as DecimalType) / 5 percentd = Math::round(percentd.intValue()) } if(receivedCommand==INCREASE) percent = percent + 2 if(receivedCommand==DECREASE) percent = percent - 2 if(receivedCommand==ON) percent = 100 if(receivedCommand==OFF) percent = 0 if(percent<0) percent = 0 if(percent>100) percent = 100 postUpdate(l_flureg, percent); if (percent>0 && percent<100) { sendCommand(domiq, "LCN.output.0.16.2=" + percentd + "\n") sendCommand(domiq, "LCN.output.0.10.1=" + percentd + "\n") }else{ sendCommand(domiq, "LCN.output.0.16.2=" + percent + "\n") sendCommand(domiq, "LCN.output.0.10.1=" + percent + "\n") } end rule "l_esstisch an" when Item l_esstisch received command ON then sendCommand(domiq, "LCN.output.0.9.1=100\n") end rule "l_esstisch aus" when Item l_esstisch received command OFF then sendCommand(domiq, "LCN.output.0.9.1=0\n") end rule "rolladen sofafenster" when Item r_sofafenster received command DOWN then sendCommand(domiq, "rolladen.wozi.klein=down\n") end rule "rolladen sofafenster hoch" when Item r_sofafenster received command UP then sendCommand(domiq, "rolladen.wozi.klein=up\n") end rule "rolladen sofafenster stop" when Item r_sofafenster received command STOP then sendCommand(domiq, "rolladen.wozi.klein=stop\n") end rule "Min- and Max values Wozi" when Item t_wozi received update then var Number Min var Number Max var String tmp var SimpleDateFormat df = new SimpleDateFormat( "HH:mm" ) if (t_wozi.state instanceof DecimalType) { Min = (t_wozi.minimumSince(now.toDateMidnight, "mysql").state as DecimalType) tmp = (Math::round(Min.floatValue*10.0)/10.0) + " °C (" + df.format(t_wozi.minimumSince(now.toDateMidnight, "mysql").timestamp) + " )" postUpdate(t_wozi_min, tmp) Max = t_wozi.maximumSince(now.toDateMidnight, "mysql").state as DecimalType df = new SimpleDateFormat( "HH:mm" ) tmp = (Math::round(Max.floatValue*10.0)/10.0) + " °C (" + df.format(t_wozi.maximumSince(now.toDateMidnight, "mysql").timestamp) + ")" postUpdate(t_wozi_max, tmp) } end
und diese z.B. durch einen Taster setzen lassen, z.B. VAR.hue.event.hue=1 Da Openhab das mitbekommt kann ich darauf eine Rule anwenden und somit z.B.
eine Hue Lampe schalten s.o. oder den Denon AVR und die Squeezebox anschalten etc....
Kommentar