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-enlighten-power

v1.1.3

Published

This plugin simulates a CO2 air quality accessory that you can switch to the "detected" state when the power produced by your Envoy solar system reaches a threshold.

Downloads

7

Readme

homebridge-enlighten-power

npm npm

Description

This plugin simulates a CO2 air quality accessory that you can switch to the "detected" state when the power produced by your Envoy solar system reaches a threshold.
You can use this state to automate other tasks or just to get information.
Current power is not displayed directly, but appears in the accessory settings under "Current level" in [ppm], but it is [W].

It can work locally (with Bonjour or custom url) or via API.

Local API returns two production values: inverters and eim

{"production":[ { "type":"inverters", "wNow":5007, ....}, { "type":"eim", "wNow":5766.563, ....}]

The plug-in read eim value by default but you can override this behavior by adding "type": "inverters" in config.json.

Bonjour

Example config.json for Bonjour (http://envoy.local/production.json):

"accessories": [
        {
        "accessory": "enlighten-power",
        "name": "> 6000 W",
        "type": "eim",          // optionnal, default "eim"
        "update_interval": 1,
        "power_threshold": 6000,
        }
]

Custom url

Example config.json for custom url:

 "accessories": [
        {
        "accessory": "enlighten-power",
        "name": "> 6000 W",
        "type": "inverters",          // optionnal, default "eim"
        "url": "http://envoy_ip/production.json",
        "update_interval": 1,
        "power_threshold": 6000
        }
]

API

Please note that API data is updated only every 15 minutes and access is limited:: https://developer.enphase.com/plans
The free plan allowing to make 10'000 requests per month, by default it refreshes every 5 minutes (12 * 24 * 31 = 8928).

Example config.json for API:

"accessories": [
        {
        "accessory": "enlighten-power",
        "name": "> 6000 W",
        "connection": "api",
        "api_key": "API_KEY",
        "api_user_id": "USER_ID",
        "site_id": "SITE_ID",
        "update_interval": 5,
        "power_threshold": 6000
        }
]

Bonus: aks with Python

You can ask the current power produced with this one line command:

curl -s "http://envoy.local/production.json" | python -c "import sys, json; print json.load(sys.stdin)['production'][1]['wNow']"

Result:

5788.47

Bonus: Python script and Piface2

In my case, I execute this script every minute to activate my boiler via Piface2 extension board when level of production reach 6000 W.

Install pifacedigitalio

Thanks to @rfennel who have manage to get it working with Buster:

  1. Get PIP (PIP3 for Python3) sudo apt-get install python3-pip
  2. Get the libraries sudo pip3 install pifacedigitalio sudo pip3 install pifacecommon
  3. Make sure the SPI access is enabled to the IO (you get errors when you run the script if you miss this out) sudo sed -i 's/#dtparam=spi=on/dtparam=spi=on/' /boot/config.txt
  4. Reboot
    sudo reboot

Script can now be executed with python3 check_power_local.py

Script

check_power_local.py

import sys
import requests
import json
import pifacedigitalio

response = requests.get('http://envoy.local/production.json')
data = response.json()
current_power = data['production'][1]['wNow']

if isinstance(current_power, float):

pfd = pifacedigitalio.PiFaceDigital(init_board=False)
state = pfd.relays[0].value

if (current_power >= 6000):
        if (state == 1):
                print (current_power, "W - Relay already ON")
        else:
                pfd.relays[0].turn_on()
                print(current_power, "W - Relay in now ON")
else:
        if (state == 0):
                print (current_power, "W - Relay already OFF")
        else:
                pfd.relays[0].turn_off()
                print(current_power, "W - Relay in now OFF")
else:
print("Error")

exit()

Same for API, replace API_KEY, USER_ID and SITE_ID values:

check_power.py

import sys
import requests
import json
import pifacedigitalio

params = (
('key', 'API_KEY'),
('user_id', 'USER_ID'),
)

response = requests.get('https://api.enphaseenergy.com/api/v2/systems/SITE_ID/summary', params=params)
data = response.json()
current_power = data['current_power']

if isinstance(current_power, int):

pfd = pifacedigitalio.PiFaceDigital(init_board=False)
state = pfd.relays[0].value

if (current_power >= 6000):
        if (state == 1):
                print (current_power, "W - Relay already ON")
        else:
                pfd.relays[0].turn_on()
                print(current_power, "W - Relay in now ON")
else:
        if (state == 0):
                print (current_power, "W - Relay already OFF")
        else:
                pfd.relays[0].turn_off()
                print(current_power, "W - Relay in now OFF")
else:
print("Error")

exit()

cron example

Launch cron editor

crontab -e

Execute local script every minutes

# m h  dom mon dow   command
* * * * * python3 /home/pi/check_power_local.py