added sml

This commit is contained in:
2017-11-14 11:27:18 +01:00
parent be0450db0d
commit 7c3e2381cb
5 changed files with 167 additions and 1 deletions
+14
View File
@@ -0,0 +1,14 @@
rule "EHZ"
when
Time cron "0,30 */1 * * * ?" // this one cycles every 30 seconds. depends on your needs
then
// getting the payload of the meter
var String meter_payload = executeCommandLine("/home/openhabian/src/libsml/examples/sml_server /dev/ttyUSB0", 5000) // note the argument /dev/ttyUSB0 - your meter-device-id goes here
// splitting the payload - first in lines, then getting counterStr and consumptionStr with delimiter "#"
val lines = meter_payload.split('\n')
val counterStr = lines.get(0).split('#').get(1)
val consumptionStr = lines.get(2).split('#').get(1)
// Updating the items
if (EHZ_status_power.state != counterStr) EHZ_status_power.sendCommand(counterStr)
EHZ_consumption_power.postUpdate(consumptionStr)
end