Weather station automatization reports using with Github Actions and X (also knowing as Twitter in the past) daily report publication process.
The information is obtained from Weather Underground platform. Launching HTTP request over the Web API to get information about the weather information sent by our weather station.
Finally it´s reported in X platform:
- X (Twitter) profile: ⛅Tiempo Castrocontrigo✌️
Here, a picture about the weather station 📸
- Recommended create python virtual environment and install requirements.txt packages.
python -m venv venv
.\venv\Scripts\activate
pip install -r .\requirements.txt
Note: scripts using by default environment variables but, you can use also input arguments.
- Get report about weather station and print in console.
python .\src\weather-station\test\morning_daily_scheduler_on_x.py `
--weather_underground_station_id <WEATHER_UNDERGROUND_STATION_ID> `
--weather_underground_api_key <WEATHER_UNDERGROUND_API_KEY>
- Get report from previous day and publish tweet in X (Twitter) platform.
python .\src\weather-station\post_morning_daily_tweet_in_x.py `
--weather_underground_station_id <WEATHER_UNDERGROUND_STATION_ID> `
--weather_underground_api_key <WEATHER_UNDERGROUND_API_KEY> `
--x_api_key <X_API_KEY> `
--x_api_key_secret <X_API_KEY_SECRET> `
--x_access_token <X_ACCESS_TOKEN> `
--x_access_secret_token <X_ACCESS_SECRET_TOKEN>
- Get report from previous day and publish post in Facebook platform.
Note
Meta (Facebook) requires generate a Long-live-token that expires after 60 days: use generate_facebook_long_lived_token.py script.
python .\src\weather-station\post_morning_daily_post_in_facebook.py `
--weather_underground_station_id <WEATHER_UNDERGROUND_STATION_ID> `
--weather_underground_api_key <WEATHER_UNDERGROUND_API_KEY> `
--facebook_access_token <FACEBOOK_ACCESS_TOKEN> `
--facebook_page_id <FACEBOOK_PAGE_ID>
How to use generate_facebook_long_lived_token.py python script:
python generate_long_lived_token.py `
--app_id <FACEBOOK_APP_ID> `
--app_secret <FACEBOOK_SECRET_APP> `
--short_token <FACEBOOK_SHORT_TOKEN>
-
For
app_idandapp_secretgo tohttps://developers.facebook.com/, go to My Apps, select the app and go to app configuration. Onbasicyou can get this data. -
For
short_tokenuse theGET /me/accountsend-point over Graph API Explorer and getaccess_tokenvalue. -
Page Id value also can be capture from
GET /me/accountsresponse.
python .\src\weather-station\test\run_unit_tests.py
