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

automategreen-cli

v0.4.1

Published

Simple Node commandline application for working with your Particle-based Automate Green devices

Downloads

6

Readme

Automate Green CLI

Automate Green CLI is a modified version of the Particle CLI. It has been modified to work with Particle-based Automate Green devices. A simple Find and Replace was performed to updated the names, so the README may not be correct.

The Automate Green CLI is a powerful tool for interacting with your devices and the Automate Green Cloud. The CLI uses node.js and can run on Windows, Mac OS X, and Linux fairly easily. It's also open source so you can edit and change it, and even send in your changes as pull requests if you want to share!

Known Issues

  • The Wireless Photon Setup Wizard will only automatically switch networks on OS X. Users of other operating systems will need to manually connect their computer to the Photon's Wi-Fi. You will be prompted during the wizard when this is required.

Installing

First, make sure you have node.js installed!

Next, open a command prompt or terminal, and install by typing:

$ npm install -g automategreen-cli
$ automategreen cloud login

Note! If you have problems running this, make sure you using Terminal / the Command Prompt as an Administator, or try using sudo

$ sudo npm install -g automategreen-cli

Install (advanced)

To use the local flash and key features you'll need to install DFU-util and openssl. They are freely available and open-source, and there are installers and binaries for most major platforms as well.

Here are some great tutorials on the community for full installs:

Installing on Ubuntu

Installing on Windows

Installing on Mac OS X:

Rather than installing these packages from source, and instead of using MacPorts, it is relatively straightforward to use Homebrew to install dfu-util and openssl. Once you have installed brew the basic command is brew install dfu-util openssl.

Upgrading

To upgrade Automate Green-CLI, enter the following command:

$ npm update -g automategreen-cli

Running from source (advanced)

To grab the CLI source and play with it locally

git clone [email protected]:spark/automategreen-cli.git
cd automategreen-cli
npm install
node app.js help

Table of Contents

Getting Started

These next two commands are all you need to get started setting up an account, claiming a device, and discovering new features.

automategreen setup

Guides you through creating a new account, and claiming your device!

$ automategreen setup

automategreen help

Shows you what commands are available, and how to use them. You can also give the name of a command for detailed help.

$ automategreen help
$ automategreen help keys

Updating Firmware

Photon/P1/Electron

automategreen update

If you wish to easily update the system firmware running on your device to a later version, you can use the automategreen update command. For the exact version it will update to, check the version of the files in the updates folder.

  1. Make sure you have DFU-util installed.
  2. Connect your device via USB, and put it into DFU mode.
  3. Run automategreen update.

Core

Apply the CC3000 patch

The easiest way to apply the CC3000 patch is to flash the known "cc3000" firmware followed by the "tinker" firmware over USB.

  1. Make sure you have DFU-util installed
  2. Connect your Core via USB, and place it into DFU mode by holding both buttons, and releasing reset, keep holding mode until your Core flashes yellow.
  3. Run automategreen flash --usb cc3000. This will run a special firmware program that will update the firmware running inside the CC3000 WiFi module. When it's done running, your Core will be blinking yellow in DFU-mode, you'll need to flash regular firmware like Tinker to get connected and developing again.
  4. Run automategreen flash --usb tinker. This will flash a new version of Tinker to your Core and return to a blinking blue "listening" state, where you can:
  5. Run automategreen setup or automategreen setup wifi to provide your network credentials to get connected again.

Performing a "Deep update"

Any Core shipped before Summer 2014 would benefit from having this update applied at least once. It improves the Core's performance on very busy networks, and helps fix other minor issues. This update now ships with the CLI so you can apply it to Cores that are unable to get online otherwise.

  1. Make sure you have DFU-util installed
  2. Connect your Core via usb, and place it into DFU mode by holding both buttons, and releasing RESET, keep holding MODE until your Core flashes yellow.
  3. Run automategreen flash --usb deep_update_2014_06
  4. Your Core should reboot and try to connect to any previously saved wifi networks, and then update itself again.

Command Reference

automategreen setup wifi

Helpful shortcut for adding another wifi network to a device connected over USB. Make sure your device is connected via a USB cable, and is slow blinking blue listening mode

$ automategreen setup wifi

automategreen login

Login and save an access token for interacting with your account on the Automate Green Cloud.

$ automategreen login

automategreen logout

Logout and optionally revoke the access token for your CLI session.

$ automategreen logout

automategreen list

Generates a list of what devices you own, and displays information about their status, including what variables and functions are available

$ automategreen list

Checking with the cloud...
Retrieving devices... (this might take a few seconds)
my_device_name (0123456789abcdef01234567) 0 variables, and 4 functions
  Functions:
    int digitalwrite(string)
    int digitalread(string)
    int analogwrite(string)
    int analogread(string)

automategreen device add

Adds a new device to your account

$ automategreen device add 0123456789abcdef01234567
Claiming device 0123456789abcdef01234567
Successfully claimed device 0123456789abcdef01234567

automategreen device rename

Assigns a new name to a device you've claimed

$ automategreen device rename 0123456789abcdef01234567 "pirate frosting"

automategreen device remove

Removes a device from your account so someone else can claim it.

$ automategreen device remove 0123456789abcdef01234567
Are you sure?  Please Type yes to continue: yes
releasing device 0123456789abcdef01234567
server said  { ok: true }
Okay!

automategreen flash

Sends a firmware binary, a source file, or a directory of source files, or a known app to your device.

Note! When sending source code, the cloud compiles .ino and .cpp files differently. For .ino files, the cloud will apply a pre-processor. It will add missing function declarations, and it will inject an #include " application.h" line at the top of your files if it is missing.

If you want to build a library that can be used for both Arduino and Automate Green, here's a useful code snippet:

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#elif defined(SPARK)
#include "application.h"
#endif

Flashing a directory

You can setup a directory of source files and libraries for your project, and the CLI will use those when compiling remotely. You can also create automategreen.include and / or a automategreen.ignore file in that directory that will tell the CLI specifically which files to use or ignore.

$ automategreen flash deviceName my_project

Flashing one or more source files

You can include any number of individual source files after the device Name, and the CLI will include them while flashing your app.

$ automategreen flash deviceName app.ino library1.cpp library1.h

Flashing a known app

You can easily reset a device back to a previous existing app with a quick command. Three app names are reserved right now: "tinker", "voodoo", and "cc3000". Tinker is the original firmware that ships with the device, and cc3000 will patch the wifi module on your Core. Voodoo is a build of VoodooSpark to allow local wireless firmata control of a device.

$ automategreen flash deviceName tinker
$ automategreen flash deviceName cc3000
$ automategreen flash deviceName voodoo

You can also update the factory reset version using the --factory flag, over USB with --usb, or over serial using --serial.

$ automategreen flash --factory tinker
$ automategreen flash --usb tinker
$ automategreen flash --serial tinker

Compiling remotely and Flashing locally

To work locally, but use the cloud compiler, simply use the compile command, and then the local flash command after. Make sure you connect your device via USB and place it into DFU mode.

$ automategreen compile device_type my_project_folder --saveTo firmware.bin
OR
$ automategreen compile device_type app.ino library1.cpp library1.h --saveTo firmware.bin

$ automategreen flash --usb firmware.bin
OR
$ automategreen flash --serial firmware.bin

automategreen compile

Compiles one or more source file, or a directory of source files, and downloads a firmware binary. This is device specific and must be passed as an argument during compilation.

The devices available are:

  • photon (alias is 'p')
  • core (alias is 'c')

eg. automategreen compile photon xxx OR automategreen compile p xxxx both targets the photon

Note! The cloud compiles .ino and .cpp files differently. For .ino files, the cloud will apply a pre-processor. It will add missing function declarations, and it will inject an #include " application.h" line at the top of your files if it is missing.

If you want to build a library that can be used for both Arduino and Automate Green, here's a useful code snippet:

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#elif defined(SPARK)
#include "application.h"
#endif

compiling a directory

You can setup a directory of source files and libraries for your project, and the CLI will use those when compiling remotely. You can also create automategreen.include and / or a automategreen.ignore file in that directory that will tell the CLI specifically which files to use or ignore. Those files are just plain text with one line per filename

$ automategreen compile device_type my_project_folder

example automategreen.include

application.cpp
library1.h
library1.cpp

example automategreen.ignore

.ds_store
logo.png
old_version.cpp

Compiling one or more source files

You can include any number of individual source files after the device id, and the CLI will include them while compiling your app.

$ automategreen compile device_type app.ino library1.cpp library1.h

Compiling in a directory containing project files

This will push all the files in a directory that the command line is currently 'cd' in for compilation.

$ automategreen compile device_type .

automategreen call

Calls a function on one of your devices, use automategreen list to see which devices are online, and what functions are available.

$ automategreen call deviceName digitalwrite "D7,HIGH"
1

automategreen get

Retrieves a variable value from one of your devices, use automategreen list to see which devices are online, and what variables are available.

$ automategreen get deviceName temperature
72.1

automategreen monitor

Pulls the value of a variable at a set interval, and optionally display a timestamp

  • Minimum delay for now is 500 (there is a check anyway if you keyed anything less)
  • hitting CTRL + C in the console will exit the monitoring
$ automategreen monitor deviceName temperature 5000
$ automategreen monitor deviceName temperature 5000 --time
$ automategreen monitor all temperature 5000
$ automategreen monitor all temperature 5000 --time
$ automategreen monitor all temperature 5000 --time > my_temperatures.csv

automategreen identify

Retrieves your device id when the device is connected via USB and in listening mode (flashing blue).

$ automategreen identify
$ automategreen identify 1
$ automategreen identify COM3
$ automategreen identify /dev/cu.usbmodem12345

$ automategreen identify
0123456789abcdef01234567

automategreen subscribe

Subscribes to published events on the cloud, and pipes them to the console. Special device name "mine" will subscribe to events from just your devices.

$ automategreen subscribe
$ automategreen subscribe mine
$ automategreen subscribe eventName
$ automategreen subscribe eventName mine
$ automategreen subscribe eventName deviceName
$ automategreen subscribe eventName 0123456789abcdef01234567

automategreen publish

Allows a message to be published via the CLI without using a physical Automate Green device. This is particularly useful when you are testing your firmware against an actual published event.

There is a --private flag that allows you to publish events to devices subscribing to events with the MY_DEVICES option.

$ automategreen publish eventName
$ automategreen publish eventName --private
$ automategreen publish eventName someData
$ automategreen publish eventName someData --private

automategreen serial list

Shows currently connected devices acting as serial devices over USB.

$ automategreen serial list

automategreen serial monitor

Starts listening to the specified serial device, and echoes to the terminal.

$ automategreen serial monitor
$ automategreen serial monitor 1
$ automategreen serial monitor COM3
$ automategreen serial monitor /dev/cu.usbmodem12345

automategreen serial flash

Flash a firmware binary over serial using the YMODEM protocol.

$ automategreen serial flash firmware.bin

automategreen keys doctor

Helps you update your keys, or recover your device when the keys on the server are out of sync with the keys on your device. The automategreen keys tools requires both DFU-util, and openssl to be installed.

Connect your device in DFU mode, and run this command to replace the unique cryptographic keys on your device. Automatically attempts to send the new public key to the cloud as well.

$ automategreen keys doctor your_device_id

There have been reports of the new public key not being sent to the cloud, in which case automategreen keys send will need to be run manually.

automategreen keys new

Generates a new public / private keypair that can be used on a device.

$ automategreen keys new
running openssl genrsa -out device.pem 1024
running openssl rsa -in device.pem -pubout -out device.pub.pem
running openssl rsa -in device.pem -outform DER -out device.der
New Key Created!

$ automategreen keys new mykey
running openssl genrsa -out mykey.pem 1024
running openssl rsa -in mykey.pem -pubout -out mykey.pub.pem
running openssl rsa -in mykey.pem -outform DER -out mykey.der
New Key Created!

automategreen keys load

Copies a .DER formatted private key onto your device's external flash. Make sure your device is connected and in DFU mode. The automategreen keys tools requires both DFU-util, and openssl to be installed. Make sure any key you load is sent to the cloud with automategreen keys send device.pub.pem

$ automategreen keys load device.der
...
Saved!

automategreen keys save

Copies a .DER formatted private key from your device's external flash to your computer. Make sure your device is connected and in DFU mode. The automategreen keys tools requires both DFU-util, and openssl to be installed.

$ automategreen keys save name_of_file
...
Saved!

automategreen keys send

Sends a device's public key to the cloud for use in opening an encrypted session with your device. Please make sure your device has the corresponding private key loaded using the automategreen keys load command.

$ automategreen keys send 0123456789abcdef01234567 device.pub.pem
submitting public key succeeded!

automategreen keys server

Switches the server public key stored on the device's external flash. This command is important when changing which server your device is connecting to, and the server public key helps protect your connection. Your device will stay in DFU mode after this command, so that you can load new firmware to connect to your server. By default this will only change the server key associated with the default protocol for a device. If you wish to change a specific protocol, add --protocol tcp or --protocol udp to the end of your command.

$ automategreen keys server my_server.der
$ automategreen keys server my_server.der --protocol udp

Encoding a server address and port

When using the local cloud you can ask the CLI to encode the IP or dns address into your key to control where your device will connect. You may also specify a port number to be included.

$ automategreen keys server my_server.pub.pem 192.168.1.10
$ automategreen keys server my_server.der 192.168.1.10 9000
$ automategreen keys server my_server.der 192.168.1.10 9000 --protocol udp

automategreen keys address

Reads and displays the server address, port, and protocol from a device.

$ automategreen keys address

tcp://device.spark.io:5683

automategreen keys protocol

Changes the transport protocol used to communicate with the cloud. Available options are tcp and udp for Electrons (if you are running at least firmware version 0.4.8).

$ automategreen keys protocol tcp
$ automategreen keys protocol udp

automategreen config

The config command lets you create groups of settings and quickly switch to a profile by calling automategreen config profile-name. This is especially useful for switching to your local server or between other environments.

Calling automategreen config automategreen will switch Automate Green-Cli back to the Automate Green Cloud API server.

$ automategreen config profile-name
$ automategreen config automategreen
$ automategreen config local apiUrl http://localhost:8080  //creates a new profile with name "local" and saves the IP-address parameter
$ automategreen config useSudoForDfu true

Calling automategreen config identify will output your current config settings.

$ automategreen config identify
Current profile: automategreen
Using API: https://api.automategreen.io
Access token: 01234567890abcdef01234567890abcdef012345

automategreen binary inspect file.bin

Describe binary generated by compile.

$ automategreen binary inspect file.bin
file.bin
 CRC is ok (06276dc6)
 Compiled for photon
 This is a system module number 2 at version 6
 It depends on a system module number 1 at version 6

automategreen webhook

Registers your webhook with the Automate Green Cloud. Creates a postback to the given url when your event is sent.

$ automategreen webhook list
$ automategreen webhook delete WEBHOOK_ID
$ automategreen webhook create example.json #run this command in the directory containing example.json
$ automategreen webhook GET <your_event_name> http://<website.you.are.trying.to.contact

For $ automategreen webhook GET <your_event_name> http://<website.you.are.trying.to.contact, you can retrieve the response using:

void setup(){
Automate Green.subscribe("hook-response/<event_name>", handlerFunction, MY_DEVICES);
}

void handlerFunction(const char *name, const char *data) {
  // Important note!  -- Right now the response comes in 512 byte chunks.  
  // This code assumes we're getting the response in large chunks, and this
  // assumption breaks down if a line happens to be split across response chunks
  
  process the data received here....
}

More examples and information about webhooks can be found here: https://docs.automategreen.io/guide/tools-and-features/webhooks/