Sign inSign up

jasonacox/weather411

By jasonacox

•Updated about 1 month ago

Pull current weather from OpenWeatherMap, store in InfluxDB and make available via local API.

Image
0

50K+

jasonacox/weather411 repository overview

⁠Weather411 Server

Docker Pulls

This server pulls current weather data from OpenWeatherMap.org⁠, makes it available via local API calls and stores the data in InfluxDB for graphing.

This service was built to easily add weather data graphs to the Powerwall-Dashboard⁠ project.

Docker: docker pull jasonacox/weather411⁠

⁠Quick Start

  1. Create a weather411.conf file (cp weather411.conf.sample weather411.conf) and update with your specific location details:

    • Enter your OpenWeatherMap API Key (APIKEY) You can get a free account and key at OpenWeatherMap.org⁠.
    • Enter your GPS Latitude (LAT) and Longitude (LON). To get your location, you can use this tool⁠.
    [Weather411]
    DEBUG = no
    
    [API]
    # Port to listen on for requests (default 8676)
    ENABLE = yes
    PORT = 8676
    
    [OpenWeatherMap]
    # Register and get APIKEY from OpenWeatherMap.org
    APIKEY = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    # Enter your location in latitude and longitude 
    LAT = xxx.xxxx
    LON = yyy.yyyy
    WAIT = 10
    TIMEOUT = 10
    # standard, metric or imperial 
    UNITS = metric
    
    [InfluxDB]
    # Record data in InfluxDB server 
    ENABLE = yes
    HOST = influxdb
    PORT = 8086
    DB = powerwall
    FIELD = weather
    # Auth - Leave blank if not used
    USERNAME =
    PASSWORD =
    # Influx 2.x - Leave blank if not used
    TOKEN =
    ORG =
    URL =
    
  2. Run the Docker Container to listen on port 8676.

    docker run \
    -d \
    -p 8676:8676 \
    -e WEATHERCONF='/var/lib/weather/weather411.conf' \
    -v ${PWD}:/var/lib/weather \
    --name weather411 \
    --restart unless-stopped \
    jasonacox/weather411
    
  3. Test the API Service

    Website of Current Weather: http://localhost:8676/⁠

    # Get Current Weather Data
    curl -i http://localhost:8676/temp
    curl -i http://localhost:8676/all
    curl -i http://localhost:8676/conditions
    
    # Get Proxy Stats
    curl -i http://localhost:8676/stats
    
    # Clear Proxy Stats
    curl -i http://localhost:8676/stats/clear
    

⁠Build Your Own

This folder contains the server.py script that runs a multi-threaded python based API webserver.

The Dockerfile here will allow you to containerize the proxy server for clean installation and running.

  1. Build the Docker Container

    # Build for local architecture  
    docker build -t weather411:latest .
    
    # Build for all architectures - requires Docker experimental 
    docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t weather411:latest . 
    
    
  2. Setup the Docker Container to listen on port 8676.

    docker run \
    -d \
    -p 8676:8676 \
    -e WEATHERCONF='/var/lib/weather/weather411.conf' \
    --name weather411 \
    -v ${PWD}:/var/lib/weather \
    --restart unless-stopped \
    weather411
    
  3. Test the API

    curl -i http://localhost:8676/temp
    curl -i http://localhost:8676/stats
    

    Browse to http://localhost:8676/⁠ to see current weather conditions.

⁠Troubleshooting Help

If you see python errors, make sure you entered your credentials correctly in docker run.

# See the logs
docker logs weather411

# Stop the server
docker stop weather411

# Start the server
docker start weather411

⁠Release Notes

⁠0.1.2 - Snow and Rain Data
  • Fix rain and snow values not being retrieved (refer issue #42) by @mcbirse (PR #69)
⁠0.1.1 - Error Handling
  • Added additional error handling for pulling and processing OpenWeatherMap data.
⁠0.1.0 - Free Weather API Update
  • Moved from OpenWeatherMap /data/2.5/onecall to free /data/2.5/weather URI (see #51)
⁠0.0.5 - Dockerized
  • Set up to run in docker and incorporated into Powerwall-Dashboard.
⁠0.0.1 - Initial Release
  • Initial Release

Tag summary

Content type

Image

Digest

sha256:c96721ba3…

Size

24 MB

Last updated

about 1 month ago

docker pull jasonacox/weather411