Module homie-p1

P1 smartmeter to Homie bridge.

This module instantiates a homie device posting data read from a P1 smartmeter port as a Homie device.

The input will be read from a serial port using socat to pass the data to stdout. The actual socat command is:

while : ; do socat [INPUT_STREAM] stdout 2>/dev/null; done

this will dismiss any error output and ensures a restart if something fails.

The module returns a single function that takes an options table. When called it will construct a Homie device and add it to the Copas scheduler (without running the scheduler).

Usage:

    local copas = require "copas"
    local hp1 = require "homie-p1"
    
    hp1 {
      socat_input_stream = "/dev/ttyUSB0,b115200", -- input stream, see socat docs
      homie_mqtt_uri = "http://mqtthost:123",      -- format: "mqtt(s)://user:pass@hostname:port"
      homie_domain = "homie",                      -- default: "homie"
      homie_device_id = "smartmeter",              -- default: "smartmeter"
      homie_device_name = "Homie smartmeter",      -- default: "P1 Smartmeter"
    }
    
    copas()
    

Info:

  • Copyright: Copyright (c) 2022-2023 Thijs Schreijer
  • License: MIT, see LICENSE.
  • Author: Thijs Schreijer


generated by LDoc 1.4.6 Last updated 2023-01-05 15:41:28