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

pimodule

v1.0.3

Published

A node package helper to control your UPS PIco HV3.0A/B/B+ HAT

Downloads

11

Readme

PiModule

A node package helper to control your UPS PIco HV3.0A/B/B+ HAT

This library was not developped by the PiModules(R) UPSPIco company. Any query/issue concerning their product won't find answers here, sorry :/ Feel free to refer to their official github repo: https://github.com/modmypi/PiModules

Be aware that this package uses exclusively await/async, no callbacks ;)

Getting Started

The PiModule documentation can be a bit tricky to read. So here is a small helper of the most common features you may want to use. Once you've followed the installation process, you'll be able to use:

  • Set pimodule addresses
  • Get pimodule temperature
  • Set shutdown timer
  • Get pimodule battery level
  • Get/set pimodule powering mode (battery or power)
  • Set backed auxilary power
  • Get pimodule running state
  • Set buzzer state
  • Generate sounds
  • Get/set pimodule bistable relay state
  • Set leds (orange, green, blue)
  • Set events on keys (these named A, B and C)
  • Get/set pimodule fan mode (automatic, manual, disable)
  • Get pimodule fan state
  • Get/set pimodule fan speed
  • Set temperature treshold

Prerequisites

You'll need a UPS PIco HV3.0A/B/B+ HAT, you can order it here: https://pimodules.com/plus-advanced

You'll also need to get the installation process right. Two ways:

  • Ansible Make it easy to reproduce via Ansible, in case your rasperry pi fails. To use the playbook provided, just clone this repository on your dev machine:
git clone https://github.com/RomeHein/pimodule.git

You'll need at least ansible installed. Make sure to change the local address of your raspberry pi aswell as the correct user in the following command:

cd /ansible
ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook pimodule.yml -i raspberrypi.local, --user=pi --ask-pass
  • Script: installer.sh

Just copy past the script installer.sh on your raspberry pi. Make sure you have the right permissions to run the script:

    chmod +x installer.sh

And run it with sudo:

sudo ./installer.sh

Alternatively, you can run it via npm once the repo cloned on your raspberry pi:

sudo npm run installer

Installing

Just install via npm:

npm i pimodule --save

Usage

Import the module and start using it:

    const PiModuleHelper = require('pimodule')
    const piModule = new PiModuleHelper()

    const state = await piModule.piModuleIsRunningProperly()
    console.log(`PiModule is running: ${state}`)

When you instantiate pimodule, make sure you are using the right set of addresses: Three are available: 'default', 'alternate' and 'noRtc' If you are using 'alternate', instantiate the module like so:

    const PiModuleHelper = require('pimodule')
    const piModule = new PiModuleHelper('alternate')

    // Plays imperial starwars march from pimodule built in buzzer
    await piModule.playSounds([[220, 700], [220, 700], [220, 700],[174, 525], [261, 175], [220, 700], [174, 525], [261, 175], [220, 1400]])

Running the tests

Tests seem a bit useless here as functions are very simple wrappers of the i2c-bus node library (which is heavily tested). But I would make sure the library match the current implementation of the PiModule firmware before using pimodule. You can check that by running directly on the raspberry pi

npm run check

This will run tests without mocking the i2c-bus library. That way we are sure addresses are correct

Contributing

All pull requests/suggestions are welcome

Authors

  • Romain Cayzac

License

This project is licensed under the MIT License - see the LICENSE.md file for details