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

brocoli-pi

v1.0.7

Published

Brocoli pi - Flask REST API for Raspberry pi

Downloads

2

Readme

Brocoli pi

Brocoli pi - Flask REST API for Raspberry pi

Installation

Install with git

Clone the repository :

git clone https://github.com/CBinet/Brocoli-pi.git

Launch Brocoli pi

Launch the server :

python server.py

Your server will then be running locally at address http://0.0.0.0:5000. From other devices, the address will be your pi address. Example : http://192.168.2.51:5000. You can get your raspberry pi IP address with the following command :

hostname -I

Install with npm

Install the package

npm install brocoli-pi

Navigate inside the brocoli-pi folder then :

Launch Brocoli pi

npm start

Extras - Setup autorun on bootup

If you want to start the server automatically when you boot up your raspberry, you can modify your .profile file located in your raspberry pi home folder :

sudo nano ~/.profile

Add the following line at the end of the file :

python <where-your-server.py-is-located>/server.py

Then press CTRL+X, Y to save and quit the file editor.

Example : Let's say your git repository is located in your home folder. If you want to add a greeting message, pull the latest version of Brocoli-pi and also start the server you would do something like this :

echo Greetings, human.
cd ~/
git pull origin master
python server.py

Using Brocoli-pi

To run the server :

python server.py

Once the server is started, you can test it by navigating to http://0.0.0.0:5000/outputs. You should see a list of your outputs.

Modules

GPIOControls

Classes :

  • Output : Single output pin
  • Group : Group of output pins

Usage :

# Instanciate an output at location '17'
# with label "Red Light".
output = Output(17, "Red Light")

# Toggles the voltage of 'output'
output.toggle()

# ...

# Instanciate a group controlling 'outputs' with
# the label "LED group"
group = Group(0, outputs, "LED group")

# This will toggle the voltage of the outputs
# of the group.
group.toggle()

Routes :

  • GET/ outputs : Returns informations of current binded outputs
  • GET/ outputs/:id : Returns information of the output at 'id' location
  • GET/ outputs/:id/toggle : Toggle the voltage of the output at 'id' location
  • GET/ groups : Returns informations of current binded groups
  • GET/ groups/:id : Returns information of the group 'id'
  • GET/ groups/:id/toggle : Toggle the voltage of the output of group 'id'

Example responses :

GET/ outputs :

{
  "results": [
    {
      "id": 17,
      "info": "Red Light",
      "state": false
    },
    {
      "id": 18,
      "info": "Green Light",
      "state": false
    },
    {
      "id": 19,
      "info": "Yellow Light",
      "state": false
    }
  ]
}

GET/ outputs/17/toggle :

    {
        "id": 17,
        "info": "Red Light",
        "state": true
    }

GET/ groups/0 :

{
    "id": 0,
    "info": "Basic 3 LED group",
    "outputs": [
    {
        "id": 17,
        "info": "Red Light",
        "state": false
    },
    {
        "id": 18,
        "info": "Green Light",
        "state": false
    },
    {
        "id": 19,
        "info": "Yellow Light",
        "state": false
    }
    ],
    "state": false
}

Weather

Working on it :) This is what is available at the moment.

Routes :

  • GET/ weather/current?city='city' : Returns current's weather of 'city'
  • GET/ weather/forecast?city='city' : Returns today's forecast of 'city'

Example responses :

GET/ weather/current?city=Quebec :

{
  "precip_mm": 1.7,
  "last_updated": "2017-04-12 03:15",
  "wind_degree": 50,
  "wind_kph": 15.1,
  "is_day": 0,
  "temp_f": 36.3,
  "vis_miles": 5,
  "temp_c": 2.4,
  "humidity": 98,
  "last_updated_epoch": 1491981306,
  "cloud": 0,
  "feelslike_c": -1.5,
  "wind_mph": 9.4,
  "feelslike_f": 29.3,
  "wind_dir": "NE",
  "pressure_mb": 1021,
  "vis_km": 9.3,
  "precip_in": 0.07,
  "pressure_in": 30.6,
  "condition": {
    "text": "Clear",
    "code": 1000,
    "icon": "//cdn.apixu.com/weather/64x64/night/113.png"
  }
}

GET/ weather/forecast?city=Quebec :

{
  "forecastday": [
    {
      "date": "2017-04-12",
      "astro": {
        "moonrise": "08:58 PM",
        "moonset": "07:03 AM",
        "sunset": "07:30 PM",
        "sunrise": "06:03 AM"
      },
      "date_epoch": 1491955200,
      "day": {
        "avgvis_miles": 6,
        "avghumidity": 84,
        "totalprecip_mm": 3.6,
        "avgtemp_c": 3.1,
        "avgtemp_f": 37.5,
        "maxwind_mph": 5.8,
        "mintemp_f": 36,
        "maxtemp_c": 3.2,
        "mintemp_c": 2.2,
        "maxtemp_f": 37.8,
        "totalprecip_in": 0.14,
        "maxwind_kph": 9.4,
        "avgvis_km": 10.4,
        "condition": {
          "text": "Light drizzle",
          "code": 1153,
          "icon": "//cdn.apixu.com/weather/64x64/day/266.png"
        }
      },
      "hour": [
        {
          "heatindex_c": 1.1,
          "heatindex_f": 34,
          "will_it_rain": 1,
          "will_it_snow": 0,
          "windchill_c": -1.2,
          "windchill_f": 29.8,
          "pressure_in": 30.6,
          "cloud": 100,
          "precip_mm": 1.7,
          "is_day": 0,
          "feelslike_c": -1.2,
          "condition": {
            "text": "Light drizzle",
            "code": 1153,
            "icon": "//cdn.apixu.com/weather/64x64/night/266.png"
          },
          "feelslike_f": 29.8,
          "wind_mph": 5.8,
          "dewpoint_c": 2.3,
          "vis_km": 9.3,
          "temp_f": 31.1,
          "temp_c": -0.5,
          "pressure_mb": 1021,
          "time_epoch": 1491969600,
          "precip_in": 0.07,
          "wind_dir": "ENE",
          "wind_kph": 9.4,
          "vis_miles": 5,
          "humidity": 80,
          "dewpoint_f": 36.1,
          "time": "2017-04-12 00:00",
          "wind_degree": 59
        },
        ...
      ]
    }
  ]
}