npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

homebridge-p1

v1.3.25

Published

Homebridge plugin for DMSR end-consumer (P1) interface

Downloads

308

Readme

Homebridge P1

Downloads Version Homebridge Discord verified-by-homebridge

GitHub issues GitHub pull requests JavaScript Style Guide

Homebridge plugin for DSMR end-consumer (P1) interface

Copyright © 2018-2024 Erik Baauw. All rights reserved.

This Homebridge plugin exposes a smart meter to Apple's HomeKit, using the end-consumer (P1) interface of the Dutch Smart Meter Requirements (DSMR). It provides insight from HomeKit into your actual and historic energy consumption.

The smart meter sends a push notification ("telegram" in DSMR speak), every second, updating the electricity consumption almost in real time. Older versions of DSMR might send notifications less frequently. Gas consumption is updated once every five minutes. Homebridge P1 maintains the historic consumption.

Depending on the smart meter capabilities, Homebridge P1 exposes up to three HomeKit accessories:

  • Electricity for electricity consumed;
  • Electricity Delivered for electricity delivered back to the network (if you have solar panels);
  • Gas for natural gas consumed (if a smart gas meter has been linked to the smart electricity meter);

Each accessory exposes a service with Total Consumption, just like an Eve Energy, enabling the Eve app to display the consumption history. Eve computes the Total Cost and Projected Cost.

In case of 3-phase electricity, the accessory contains a service per phase showing Power, Current, and Voltage.

Prerequisites

You need a smart meter that provides a P1 port that complies to DSMR (currently DSMR 5.0, DSMR 4.2, and DSMR 2.2+ are tested). The companies maintaining the electricity and natural gas networks in the Netherlands, united in Netbeer Nederland are replacing existing electricity and gas meters with smart meters. In my home, they installed a Landys +Gyr E350 (ZCF1100). Smart meters in Flandres (Belgium), Luxembourg, and Sweden might provide a P1 port as well. I don't know about the rollout plans in those countries. One Flandres installation is reported working, see #47; one Swedish installation is reported not working, see #50.

You need a cable to connect the smart meter's P1 port to a USB port. I got mine here, but you could also make one yourself, as described here. The cable is quite short (~1m) but you can extend it using a regular USB extension cable (female-A to A).

You need a server to run Homebridge. This can be anything running Node.js: from a Raspberry Pi, a NAS system, or an always-on PC running Linux, macOS, or Windows. See the Homebridge Wiki for details. I run Homebridge P1 on a Raspberry Pi 3B+.

Note that Homebridge P1 uses the serialport package to connect to the P1 cable. This package uses some non-JavasScript addons, that need to be compiled while installing Homebridge P1. The server running Homebridge P1 needs to have the appropriate development tools installed.

The user running Homebridge needs privileges to list the serial port devices and to open the serial port device for the P1 cable. Under Raspbian, user pi has these privileges by default. If you run Homebridge under a different user, make sure it's member of the dialout group, and, for Buster, of the gpio group.

To interact with HomeKit, you need Siri or a HomeKit app on an iPhone, Apple Watch, iPad, iPod Touch, or Apple TV (4th generation or later). I recommend to use the latest released versions of iOS, watchOS, and tvOS.
Please note that Siri and even Apple's Home app still provide only limited HomeKit support. To use Homebridge P1, you want to check out some other HomeKit apps, like the Eve app (free) or Matthias Hochgatterer's Home+ app (paid).

As HomeKit uses Bonjour to discover Homebridge, the server running Homebridge must be on the same subnet as your iDevices running HomeKit. For remote access and for HomeKit automations, you need to setup an Apple TV (4th generation or later), HomePod, or iPad as home hub.

Installation

To install Homebridge P1:

  • Follow the instructions on the Homebridge Wiki to install Node.js and Homebridge;
  • Install the Homebridge P1 plugin through Homebridge Config UI X or manually by:
    $ sudo npm -g i homebridge-p1 --unsafe-perm
  • Edit config.json and add the P1 platform provided by Homebridge P1, see Configuration.

Configuration

Homebridge P1 should detect the USB serial cable automatically. In case it doesn't or when you have multiple USB serial devices, you can specify the serialport in config.json:

"platforms": [
  {
    "platform": "P1",
    "serialport": "/dev/ttyUSB0"
  }
]

If Homebridge P1 doesn't receive any data and you have a meter with an older DSMR version, you might need to specify:

"platforms": [
  {
    "platform": "P1",
    "serialport": "/dev/ttyUSB0",
    "dsmr22": true
  }
]

If Homebridge P1 receives data too late (i.e. after the Homebridge server has started) no accessories will be exposed to HomeKit. In this case, set "timeout" in config.json and restart Homebridge. This parameter specifies the number of seconds Homebridge P1 waits for data, before giving up and letting Homebridge startup continue without any P1 accessories. Note that accessories from other plugins will not be reachable while Homebridge P1 waits for data, so you want to set "timeout" as low as possible, while keeping in mind a telegram might be lost due to communication glitches. The default of "timeout": 5 assumes the meter sends a telegram every second. DSMR v2.2 meters only send a telegram every 10 seconds, so when "dsmr22": true is set, a default "timeout": 50 is used.

Caveats

Homebridge P1 is a hobby project of mine, provided as-is, with no warranty whatsoever. I've been running it successfully at my home for years, but your mileage might vary.

The HomeKit terminology needs some getting used to. An accessory more or less corresponds to a physical device, accessible from your iOS device over WiFi or Bluetooth. A bridge (like Homebridge) is an accessory that provides access to other, bridged, accessories. An accessory might provide multiple services. Each service corresponds to a virtual device (like a lightbulb, switch, motion sensor, ..., but also: a programmable switch button, accessory information, battery status). Siri interacts with services, not with accessories. A service contains one or more characteristics. A characteristic is like a service attribute, which might be read or written by HomeKit apps. You might want to checkout Apple's HomeKit Accessory Simulator, which is distributed as an additional tool for Xcode.

Exposing the smart meter to HomeKit is a bit of a hack, lacking proper HomeKit support for smart meters. Also, Eve lacks proper support for gas consumption. The following limitations apply:

  • The Electricity consumption is the combined consumption under Normal and Low tariff. If you have a dual-tariff contract, the cost computed by Eve will be inaccurate;
  • The Gas consumption is actually in m³, but Eve displays kWh. If Homebridge P1 would expose different characteristics for gas consumption, Eve would display the correct units, but not the history. To see the correct cost for Gas, you need to change the Energy Cost under Settings in Eve to match you Gas rate;
  • Eve doesn't take into account fixed (subscription) costs, so the cost displayed is only the variable cost.