Files, scripts, howtos and more for openHAB.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
751 B

7 years ago
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