
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
automation-hat
Advanced tools
Node.js project to support Pimoroni Automation Hat (https://shop.pimoroni.com/products/automation-hat) running on Raspberry Pis.
The node version support and the corresponding version of this library are listed in the table below.
| Automation Hat Version | Supported Node Versions |
|---|---|
| 1 | 14, 15, 16, 17, 18, 19 |
| 2.0 | 16, 17, 18, 19 |
| 2.1+ | 16, 17, 18,19, 20 |
| 3.0+ | 18, 19, 20, 21, 22 |
Supported functionality:
Currently not supported
Raspberry Pi versions 3 and 4 should be supported however version 5 has not been tested.
The underlying hardware design has changed and may not work as expected.
Simply run
npm i automation-hat
To simply use the whole library create an instance of the AutomationHat class.
This class has all other functionality of the Automation Hat already configured but disabled (except for the led lights).
const automationHat = new AutomationHat();
To enable modules you simple call the .SERVICE.enable() method. Services are disabled by default to save the LEDs life when not in use (eg no led for the relays) and in the name of general performance.
However if you only need one part of the Automation Hat you can create instances of the following services:
LightServiceRelayServiceDigitalInputServiceDigitalOutputServiceAnalogInputService (NOTE: Analog Input Service has not been completed)WARN: When creating instances of the services yourself ensure that you only create singleton (one of each) instances. Creating multiple
LightServicefor example may have unknown behaviour or errors. You have been warned!
The LightService looks after all the led lights.
There is a property for each led light on the Automation Hat (e.g. LightService.power for the power led).
You can create an instance of the light service like this
const lightService = new LightService()
Each light has the following properties:
| Property | Description |
|---|---|
| state | on or off |
Each light has the following methods:
| Method | Description |
|---|---|
| off() | Turn a light off |
| on() | Turn a light on |
| toggle() | Toggle a light (off -> on, on -> off) |
| update() | Update the state of all lights. Light state will not change unless this method is called! |
The RelayService looks after all the relays.
There is a property for each relay. For example RelayService.relay1.
To create an instance of the relay service you have to pass in an instance of the LightService.
const lightService = new LightService();
const relayService = new RelayService(lightService);
The RelayService has the following methods:
Each light has the following methods:
| Method | Description |
|---|---|
| disable() | Disables relay control and turns off relay lights |
| enable() | Enables relay control. Defaults to NC/off |
Each relay has the following properties:
| Property | Description |
|---|---|
| state | on or off. on is NO (Normally Open) and off if NC (Normally Closed) |
Each relay has the following methods:
| Method | Description |
|---|---|
| off() | Turn a relay off (i.e. NC) |
| on() | Turn a relay on (i.e. NO) |
| toggle() | Toggle a relay (off -> on, on -> off) |
The DigitalInputService looks after all the digital inputs.
There is a property for each digital input. For example DigitalInputService.input1.
To create an instance of the digital input service you have to pass in an instance of the LightService.
const lightService = new LightService();
const digitalInputService = new DigitalInputService(lightService);
The DigitalInputService has the following methods:
| Method | Description |
|---|---|
| read() | read all digital inputs value and set it's state |
Each digital input has the following properties:
| Property | Description |
|---|---|
| state | low or high |
Each digal input has the following methods:
| Method | Description |
|---|---|
| read() | Read the digital input's value and set it's state |
The DigitalOutputService looks after all the digital outputs.
There is a property for each digital output. For example DigitalOutputService.output1.
To create an instance of the digital output service you have to pass in an instance of the LightService.
const lightService = new LightService();
const digitalOutputService = new DigitalOutputService(lightService);
The DigitalOutputService has the following methods:
| Method | Description |
|---|---|
| disable() | Disables digital output control and sets all the outputs to low |
| enable() | Enables digital output control. Defaults to low |
Each digital output has the following properties:
| Property | Description |
|---|---|
| state | low or high |
Each digital output has the following methods:
| Method | Description |
|---|---|
| high() | Set a digital ouput high |
| low() | Set a digital ouput low |
| toggle() | Toggle a digital ouptut (low -> high, high -> low) |
NOTE: The analog input service has not been implemented. However this is the general thought/direction and may yet have breaking changes
The AnalogInputService looks after all the analog inputs.
There is a property for each analog input. For example AnalogInputService.input1.
To create an instance of the analog input service you have to pass in an instance of the LightService.
const lightService = new LightService();
const analogInputService = new AnalogInputService(lightService);
The AnalogInputService has the following methods:
| Method | Description |
|---|---|
| disable() | Disables analog input reading and turns off analog input lights |
| enable() | Enables analog input reading |
Find a bug or want to contribute, simply clone this repository and submit a pull request.
FAQs
Node.js project to support Pimoroni Automation Hat
We found that automation-hat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.