]> git.basschouten.com Git - openhab-addons.git/commitdiff
[http] Add examples (#9540)
authorJ-N-K <J-N-K@users.noreply.github.com>
Tue, 29 Dec 2020 14:02:38 +0000 (15:02 +0100)
committerGitHub <noreply@github.com>
Tue, 29 Dec 2020 14:02:38 +0000 (15:02 +0100)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
bundles/org.openhab.binding.http/xtend_examples.md [new file with mode: 0644]

diff --git a/bundles/org.openhab.binding.http/xtend_examples.md b/bundles/org.openhab.binding.http/xtend_examples.md
new file mode 100644 (file)
index 0000000..50b492f
--- /dev/null
@@ -0,0 +1,63 @@
+## Vito WIFI (https://github.com/openhab/openhab-addons/issues/9480#issuecomment-751335696)
+
+### .things
+```
+Thing http:url:vitowifi "VitoWifi" @ "1stfloor" [baseURL="http://192.168.1.61/", commandMethod="POST", delay="1000", refresh="90", timeout="900"]   {
+
+    Channels:
+        Type number : Channel_Vito_ID           "Vito_ID"                  [ stateExtension="read?DP=0x00f8&Type=CountS", stateTransformation="REGEX:(^[-+]?[0-9]+)" ]
+        Type number : Channel_Vito_Mode         "Vito_Mode"                [ stateExtension="read?DP=0xb000&Type=Mode", stateTransformation="REGEX:(^[-+]?[0-9]+)", commandExtension="write?DP=0xb000&Type=Mode&Value=%2$s" ]
+        Type number : Channel_Vito_OnOff        "Vito_OnOff_for_ESPEasy"   [ stateExtension="control?cmd=Status,GPIO,12", stateTransformation="JSONPATH(state)",commandExtension="control?cmd=GPIO,12,%2$s"]
+}
+```
+
+### .items
+
+``` 
+Number Vito_ID                   "Vito_ID"           <switch>                (gHeating)                                              {channel="http:url:vitowifi:Channel_Vito_ID" ,   expire="5m"  }
+Number Vito_Mode                 "Vito_Mode"         <switch>                (gHeating)                                              {channel="http:url:vitowifi:Channel_Vito_Mode" ,   expire="5m"  }// 0= Off 1= WW 2= WW+heat 0x42 (66)=party
+Number Vito_OnOff                "ONOFF Switch"      <switch>                (gHeating)                                              {channel="http:url:vitowifi:Channel_Vito_OnOff" ,   expire="5m"  }   
+```
+
+## Feinstaubsensor (https://community.openhab.org/t/http-binding-openhab-3-version/101851/235)
+
+The http request http://feinstaubsensor-14255834/data.json is answering with a JSON string.
+So I need some simple JSONPATH transformation and one java script transformation.
+Data is polled every 10 seconds.
+
+### .things
+
+```
+Thing http:url:feinstaub "Feinstaub" [ baseURL="http://feinstaubsensor-14255834/data.json", refresh=10] {        
+   Channels:            
+      Type number : SDS_PM10 [ stateTransformation="JSONPATH:$.sensordatavalues[0].value" ]
+      Type number : SDS_PM25 [ stateTransformation="JSONPATH:$.sensordatavalues[1].value" ]
+      Type number : Temperatur [ stateTransformation="JSONPATH:$.sensordatavalues[2].value" ]
+      Type number : Pressure [ stateTransformation="JS:airpressure.js" ]
+      Type number : Humidity [ stateTransformation="JSONPATH:$.sensordatavalues[4].value" ]
+}
+```
+
+### .items
+
+```
+/* **************************
+ * Feinstaub sensor data
+ * ************************** */
+  Number N_FS_SDS_PM10 "Partikelgröße 10µm [%.2f µg/m³]" { channel="http:url:feinstaub:SDS_PM10" }
+  Number N_FS_SDS_PM25 "Partikelgröße 2.5µm [%.2f µg/m³]" { channel="http:url:feinstaub:SDS_PM25" }
+  Number N_FS_Temperatur "Temperatur [%.2f °C]" <temperature> { channel="http:url:feinstaub:Temperatur" }
+  Number N_FS_Pressure "Luftdruck [%.2f hPa]" <pressure> { channel="http:url:feinstaub:Pressure" }
+  Number N_FS_Humidity "Luftfeuchte [%.2f %%]" <water> { channel="http:url:feinstaub:Humidity" }
+```
+
+### airpressure.js (transformation)
+
+I have a BME2080 sensor connected. The Humidity must be diveded by 100 to show hPa.
+
+```
+(function(x) {
+    var json = JSON.parse(x);
+    return json.sensordatavalues[3].value/100;
+})(input)
+```
\ No newline at end of file