项目作者: krzysztofkarolak

项目描述 :
Python app for sending weather and air conditions data to Blynk Projects
高级语言: Python
项目地址: git://github.com/krzysztofkarolak/blynk-external-data.git
创建时间: 2018-05-17T20:03:09Z
项目社区:https://github.com/krzysztofkarolak/blynk-external-data

开源协议:

下载


Blynk Api External Weather Data

A Python app for weather data deployment to Blynk Projects, using:

  • Airly for temperature and air pollution data,
  • Yahoo Weather for temperature, wind speed/direction, weather conditions data,
  • Open Weather Map for temperature, humidity, pressure, wind speed/direction, weather conditions data,
  • Blynk Server Api for data deployment to Blynk projects.

This application works with default or custom instance of Blynk server.

If your Blynk Project provides a temperature sensor with a fan mounted outside, the app can send the information to the sensor if weather conditions are favourable to start the fan.

Configuration

Python 3.11 or newer is recommended. Make sure you have installed Python depedencies:

  1. PyYAML>=4.2b1
  2. certifi>=2018.4.16
  3. chardet>=3.0.4
  4. idna>=2.6
  5. pytz>=2018.4
  6. requests>=2.20.0
  7. urllib3>=1.24.2

Create config.yml file and enter your API keys:

  1. server:
  2. name: "My Data Server"
  3. timezone: "Europe/Berlin"
  4. lang: "pl" # en or pl are supported for weather data
  5. units: "metric" # metric or imperial
  6. location:
  7. latitude: "52.526400"
  8. longitude: "13.397261"
  9. owmCityId: "2950159" # OpenWeatherMap City Id
  10. yahooCityWOEID: "638242"
  11. apiKeys:
  12. airlyKey: "yourapikey" # You can request your API Key on airly.eu
  13. owmKey: "yourapikey" # You can request your API Key on openweathermap.org
  14. blynkKey: "yourapikey" # Blynk Project Api Key
  15. blynkServer:
  16. hostname: "blynk-cloud.com" # Your Blynk Server URL
  17. port: "9443" # Default HTTPS Api port
  18. devices:
  19. fan: true # If there is a fan in your temperature sensor, leave this option true

Deploying code

This app was intended to work in Heroku or GCP Cloud Functions. You can easily deploy it to Heroku instance:

  1. $ heroku create
  2. $ git add .
  3. $ git commit -am "First commit"
  4. $ git push heroku master

or in GCP Cloud Functions:

  1. $ gcloud functions deploy function-name --runtime python311 --entry-point=BlynkExternalData

Blynk Project Configuration

Default Virtual Pins are listed below:

  • V36: Air Quality Color
  • V37: Air Quality Description
  • V38: Humidity
  • V39: PM 1
  • V40: PM 2.5
  • V41: PM 10
  • V42: Air Pollution Level
  • V43: Temperature
  • V44: Air Quality Index - CAQI
  • V45: Temperature Sensor’s Fan favourable conditions (based on weather conditions) [0 or 1]
  • V46: Date and time of data update
  • V47: Wind Speed
  • V48: Wind Direction
  • V49: Pressure
  • V70: OWM Weather Conditions
  • V71: Server Name
  • V72: Yahoo Weather Conditions