nrocco / smeterd

Read P1 smart meter packets in Python
MIT License
31 stars 18 forks source link

Different serial settings - can you make it parameterised? #28

Closed RenewedMe closed 1 year ago

RenewedMe commented 3 years ago

Hi Nrocco,

I am a happy user of your library in the house where we are living but I noticed that in our holiday home (up North in Holland) we use a different type of meter which comes with different serial settings: serial_defaults = {'baudrate': 115200, 'bytesize': 8, 'parity': 'N', 'stopbits': 1, 'xonxoff': 1, 'timeout': 20} Would it be possible to parameterise these settings?

Regards, Frank

nrocco commented 3 years ago

Hi Frank, This sounds certainly possible. I’ll take a look later today. One question, are you using smeterd as a command line application or as a python module?

RenewedMe commented 3 years ago

Hi Nrocco,

Thanks for the quick reply! I am using it as a Python module. Basically I am reading the smart meter and then use MQTT to publish the readings which I then pick up on the other side to load it in an Influx DB so I can use Grafana to visualise the data.

Regards Frank

Rabijns commented 3 years ago

Hello, I was also looking into the use of your module. The meter I try to read is apparantly 115200 baud, 8N1, Xon/Xoff. I will use it as apython module, even if for testing purposes, cli use would also be handy. Best regards...

nrocco commented 1 year ago

The serial configuration is already parameterised, both when using as a module and when using the smeterd sub command:

As a module you can do this:

>>> from smeterd.meter import SmartMeter
>>> meter = SmartMeter("/dev/ttyUSB0", baudrate= 115200, bytesize=8, parity="N", xonxoff=True)

Via the cli you can do this:

$ smeterd read-meter --serial-baudrate 115200 --serial-bytesize 8 --serial-parity N --serial-xonxoff

Closing this issue