Damit der MultiSwitch durch OpenHAB gesteuert werden kann, muß die OpenHAB-Konfiguration ergänzt werden. Hierzu sind einige Dateien anzulegen. Der in diesem Beispiel verwendete ESP8266 hat den Hostname 'ESP_016026'. Ihr müsst die gesamten Variablen an Eurer Modul anpassen!

 

Items

Auf dem OpenHAB-Server ist  eine neue Datei /etc/openhab/configuratons/items/multiswitch.items anzulegen:

/*******************************************************************************************/
/* OpenHAB (ab 1.6.1) Item-Configuration */ /* File "/etc/openhab/configuratons/items/multiswitch.items" Rev 1.00 / 21.11.2015 / 18:00 */ /* (C) 2014 Andreas Kriwanek, 83043 Bad Aibling, Germany */ /*******************************************************************************************/ /* This is a demo file for the MultiSwitch 2.00. You have to replace the ESP8266 hostname */ /* in this file by the hostname of your module! */ /*-----------------------------------------------------------------------------------------*/ /* MultiSwitch 2.00, Hostname: ESP_016026 */ /*-----------------------------------------------------------------------------------------*/ Switch ESP_016026_C1 "Waschmaschine" // Real switch Switch ESP_016026_C2 "Wäschetrockner" // Real switch Switch ESP_016026_C3 "Geschirrspüler" // Real switch Switch ESP_016026_C4 "Infrarotheizung Bad" // Real switch Switch ESP_016026_C5 "Infrarotheizung WC" // Real switch String ESP_016026_FB1 "Feedback CH1 [%s]" // Virtual switch String ESP_016026_FB2 "Feedback CH2 [%s]" // Virtual switch String ESP_016026_FB3 "Feedback CH3 [%s]" // Virtual switch String ESP_016026_FB4 "Feedback CH4 [%s]" // Virtual switch String ESP_016026_FB5 "Feedback CH5 [%s]" // Virtual switch String ESP_016026_STATUS "Status [%s]" // MultiSwitch request for values
/*-----------------------------------------------------------------------------------------*/
 

Damit werden die vom EnergyCounter gelieferten Variablen für OpenHAB bekannt gegeben.

 

Sitemap

Für die Anzeige der Variablen in der OpenHAB-Oberfläche dient die Sitemap. Es ist auf dem OpenHAB-Server eine neue Datei /etc/openhab/configuratons/sitemaps/multiswitch.sitemap anzulegen:

/************************************************************************************************/
/* OpenHAB (1.6.1 or higher) Sitemap */
/* File "/etc/openhab/configuratons/sitemaps/multiswitch.sitemap" Rev 1.00 / 21.11.2015 / 18:00 */
/* (C) 2014 Andreas Kriwanek, 83043 Bad Aibling, Germany */
/************************************************************************************************/
/* This is a demo file for the MultiSwitch 2.00. You have to replace the ESP8266 hostname in    */
/* this file by the hostname of your module! */
/*----------------------------------------------------------------------------------------------*/
// MultiSwitch 2.00, Hostname: ESP_016026                                                       */ 
/*----------------------------------------------------------------------------------------------*/

sitemap test label="MultiSwitch"
{
   Frame
{
Switch item=ESP_016026_C1
Switch item=ESP_016026_C2
Switch item=ESP_016026_C3
Switch item=ESP_016026_C4
Switch item=ESP_016026_C5
}
Frame
{
Text item=ESP_016026_FB1
Text item=ESP_016026_FB2
Text item=ESP_016026_FB3
Text item=ESP_016026_FB4
Text item=ESP_016026_FB5
Text item=ESP_016026_STATUS
}
}
/*----------------------------------------------------------------------------------------------*/

 

Rules

Mit Hilfe von Rules können die vom EnergyCounter gemeldeten Momentanwerte auf Tages-, Monats- und Jahresbasis aufsummiert werden.

/***********************************************************************************************************************************************/
/* OpenHAB (1.6.1 or higher) Rules */ /* File "/etc/openhab/configuratons/rules/multiswitch.rules" Rev 1.00 / 21.11.2015 / 18:00 */ /* (C) 2014 Andreas Kriwanek, 83043 Bad Aibling, Germany */ /***********************************************************************************************************************************************/ /* This is a demo file for the MultiSwitch 2.00. You have to replace the ESP8266 hostname in this file by the hostname of your module! */ /*---------------------------------------------------------------------------------------------------------------------------------------------*/ // MultiSwitch 2.00, Hostname: ESP_016026 */ /*---------------------------------------------------------------------------------------------------------------------------------------------*/ import org.openhab.core.library.types.* import org.openhab.core.persistence.* import org.openhab.model.script.actions.* import org.openhab.core.library.types.DecimalType import java.lang.Math //----------------------------------------------------------------------------------------------------------- rule "ESP_016026_C1" when Item ESP_016026_C1 received update then var url = "http://ESP_016026/state?ch1=" + ESP_016026_C1.state.toString sendHttpGetRequest(url) end //----------------------------------------------------------------------------------------------------------- rule "ESP_016026_C2" when Item ESP_016026_C2 received update then var url = "http://ESP_016026/state?ch2=" + ESP_016026_C2.state.toString sendHttpGetRequest(url) end //----------------------------------------------------------------------------------------------------------- rule "ESP_016026_C3" when Item ESP_016026_C3 received update then var url = "http://ESP_016026/state?ch3=" + ESP_016026_C3.state.toString sendHttpGetRequest(url) end //----------------------------------------------------------------------------------------------------------- rule "ESP_016026_C4" when Item ESP_016026_C4 received update then var url = "http://ESP_016026/state?ch4=" + ESP_016026_C4.state.toString sendHttpGetRequest(url) end //----------------------------------------------------------------------------------------------------------- rule "ESP_016026_C5" when Item ESP_016026_C5 received update then var url = "http://ESP_016026/state?ch5=" + ESP_016026_C5.state.toString sendHttpGetRequest(url) end //----------------------------------------------------------------------------------------------------------- rule "ESP_016026_STATUS" when Item ESP_016026_STATUS changed to Boot then var url = "http://ESP_016026/state?ch1=" + ESP_016026_C1.state.toString url = url + "&ch2=" + ESP_016026_C2.state.toString url = url + "&ch3=" + ESP_016026_C3.state.toString url = url + "&ch4=" + ESP_016026_C4.state.toString url = url + "&ch5=" + ESP_016026_C5.state.toString sendHttpGetRequest(url) postUpdate(ESP_016026_STATUS, "Run") end //-----------------------------------------------------------------------------------------------------------

Verwendung des MultiSwitch in OpenHAB

Die OpenHAB-Konfigurationsdateien werden nach OpenHAB per FTP hochgeladen. Über den Webbrowser auf dem PC können die Werte des MultiSwitch anschließend über

http://10.0.0.10:8080/openhab.app?sitemap=multiswitch

aufgerufen werden:

MultiSwitch in OpenHAB

Öffnet man ein zweites Browserfenster über http://ESP_016026 auf den MultiSwitch und ruft die Werte ab, sind sie identisch zu den in OpenHAB gezeigten:

MultiSwitch aktuelle Werte