Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
219ab59
changes for a 2.1.1 version of Pi Weather Rock with Internationalizat…
carloshm Apr 16, 2021
b381e7e
Delete piweatherrock.lang.json
carloshm Apr 16, 2021
95f4c9f
Delete screenshot.jpeg
carloshm Apr 17, 2021
34a552b
Delete weather-mock.json
carloshm Apr 17, 2021
8daed5d
Delete forecast-mock.json
carloshm Apr 17, 2021
ce7d494
Delete pwr-config-upgrade
carloshm Apr 17, 2021
6105dd5
Delete pwr-ui
carloshm Apr 17, 2021
7af61d5
version 2.2.1 with intl and local with sample for es, eu, gl, en, it,…
carloshm Apr 17, 2021
60db718
Merge branch 'master' of https://github.com/carloshm/PiWeatherRock
carloshm Apr 17, 2021
be01888
fix requirements python-i18n
carloshm Apr 17, 2021
16020b9
typo es lang
carloshm Apr 17, 2021
ae51ac2
remove unnecessary imports
carloshm Apr 17, 2021
b25595c
included timezone
carloshm Apr 18, 2021
bca700f
changes for openmeteo vs darksky
carloshm Apr 30, 2023
4c9553d
fix typo
carloshm Apr 30, 2023
b647074
Update forecast.py
carloshm Nov 7, 2023
f8f76f9
Update forecast.py
carloshm Nov 7, 2023
8f0a13d
Update openmeteo.py
broundonb Aug 12, 2024
41c59a6
Update openmeteo.py
broundonb Aug 12, 2024
247afca
Update piweatherrock.es.json
broundonb Aug 12, 2024
ef3a3b8
Update openmeteo.py
broundonb Aug 12, 2024
ad6ad87
Create piweatherrock-config.json
carloshm Aug 12, 2024
e506603
Update README.md
carloshm Aug 12, 2024
a91abc7
Update README.md
carloshm Aug 12, 2024
c63fc50
Update README.md
carloshm Aug 12, 2024
dd7c507
Update README.md
carloshm Aug 12, 2024
82c024c
Update README.md
carloshm Aug 12, 2024
c704e40
Update README.md
carloshm Aug 12, 2024
be4a971
Update README.md
carloshm Aug 12, 2024
ad9bd63
Update README.md
carloshm Aug 12, 2024
dec50dd
Update piweatherrock.es.json
broundonb Aug 12, 2024
2ae4f02
Update piweatherrock.es.json
broundonb Aug 12, 2024
d4bd306
Update __init__.py
carloshm Aug 12, 2024
dfb5d44
Update __init__.py
carloshm Aug 12, 2024
b06fe1a
Update __init__.py
carloshm Aug 12, 2024
bd0da1f
Add files via upload
carloshm Aug 28, 2024
e6f52c2
Add files via upload
carloshm Aug 28, 2024
13eecfb
Add files via upload
carloshm Aug 28, 2024
4f90bb9
Add files via upload
carloshm Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,36 @@ More information about the project and full documentation can be found at https:
- [optional] `twine upload --repository-url https://test.pypi.org/legacy/ dist/*`
- `twine upload dist/*`
- Create a git tag and push it

## Local Development process

```python
python3 -m venv env_name
source env_name/bin/activate
```

```python
git clone https://github.com/carloshm/PiWeatherRock.git
cd PiWeatherRock
git pull (for any additional external change after a while)
```

Make changes

```python
git add .
git commit -m "changes description"
git push origin main
```

## Run changes https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html

```python
python3 -m pip install --upgrade setuptools wheel
python3 -m pip install .
python3 ./scripts/pwr-ui -c ./piweatherrock/piweatherrock-config.json
```

## Validate Service Data

https://api.open-meteo.com:443 "GET /v1/forecast?latitude=40.299457&longitude=-3.743399&appid=openmeteo-request-piweatherrock&timezone=Europe/Madrid&models=best_match&forecast_days=4&current_weather=true&temperature_unit=celsius&windspeed_unit=kmh&precipitation_unit=mm&timeformat=iso8601&hourly=visibility,weathercode,temperature_2m,relativehumidity_2m,apparent_temperature,surface_pressure,cloudcover,windspeed_80m,precipitation,precipitation_probability,dewpoint_2m,windspeed_10m,windgusts_10m,winddirection_10m,cloudcover_low,direct_radiation&daily=sunrise,sunset,uv_index_max,weathercode,temperature_2m_max,temperature_2m_min,apparent_temperature_max,apparent_temperature_min,precipitation_sum,precipitation_probability_mean,precipitation_probability_min,windgusts_10m_max,precipitation_probability_max,windspeed_10m_max,winddirection_10m_dominant HTTP/1.1"
Empty file modified install.sh
100755 → 100644
Empty file.
9 changes: 9 additions & 0 deletions piweatherrock/climate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2023 Carlos de Huerta <carlos.hm@live.com>
# Distributed under the MIT License (https://opensource.org/licenses/MIT)

from .forecast import Forecast


def forecast(key, latitude, longitude, time=None, timeout=None, **queries):
return Forecast(key, latitude, longitude, time, timeout, **queries)
62 changes: 62 additions & 0 deletions piweatherrock/climate/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# data.py


class DataPoint(object):
def __init__(self, data):
self._data = data

if isinstance(self._data, dict):
for name, val in self._data.items():
setattr(self, name, val)

if isinstance(self._data, list):
setattr(self, 'data', self._data)

def __setattr__(self, name, val):
def setval(new_val=None):
return object.__setattr__(self, name, new_val if new_val else val)

# regular value
if not isinstance(val, (list, dict)) or name == '_data':
return setval()

# set specific data handlers
if name in ('alerts', 'flags'):
return setval(eval(name.capitalize())(val))

# data
if isinstance(val, list):
val = [DataPoint(v) if isinstance(v, dict) else v for v in val]
return setval(val)

# set general data handlers
setval(DataBlock(val) if 'data' in val.keys() else DataPoint(val))

def __getitem__(self, key):
return self._data[key]

def __len__(self):
return len(self._data)


class DataBlock(DataPoint):
def __iter__(self):
return self.data.__iter__()

def __getitem__(self, index):
# keys in darksky API datablocks are always str
if isinstance(index, str):
return self._data[index]
return self.data.__getitem__(index)

def __len__(self):
return self.data.__len__()


class Flags(DataPoint):
def __setattr__(self, name, value):
return object.__setattr__(self, name.replace('-', '_'), value)


class Alerts(DataBlock):
pass
283 changes: 283 additions & 0 deletions piweatherrock/climate/data/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
{
"latitude": 40.3,
"longitude": -3.7399998,
"timezone": "Europe/Madrid",
"currently": {
"time": 1682848800,
"summary": "Nublado",
"icon": "cloudy",
"nearestStormDistance": 0,
"precipIntensity": 3,
"precipIntensityError": 0,
"precipProbability": 3,
"precipType": "rain",
"temperature": 17.0,
"apparentTemperature": 17.0,
"dewPoint": 0,
"humidity": 0,
"pressure": 0,
"windSpeed": 9.0,
"windGust": 46.1,
"windBearing": 61.0,
"cloudCover": 0,
"uvIndex": 6.2,
"visibility": 0,
"ozone": 0
},
"daily": {
"summary": null,
"icon": null,
"data": [
{
"time": 1682812800,
"summary": "Nublado",
"icon": "cloudy",
"sunriseTime": 1682838840,
"sunsetTime": 1682889000,
"temperatureHigh": 25.0,
"temperatureLow": 13.7,
"moonPhase": 0,
"precipIntensity": 3,
"precipIntensityMax": 3,
"precipIntensityMaxTime": 0,
"precipProbability": 3,
"precipType": "rain",
"temperatureHighTime": 0,
"temperatureLowTime": 0,
"apparentTemperatureHigh": 23.5,
"apparentTemperatureHighTime": 0,
"apparentTemperatureLow": 12.0,
"apparentTemperatureLowTime": 0,
"dewPoint": 0,
"humidity": 0,
"pressure": 0,
"windSpeed": 12.2,
"windGust": 46.1,
"windGustTime": 0,
"windBearing": 38,
"cloudCover": 0,
"uvIndex": 6.2,
"uvIndexTime": 0,
"visibility": 0,
"ozone": 0,
"temperatureMin": 13.7,
"temperatureMinTime": 0,
"temperatureMax": 25.0,
"temperatureMaxTime": 0,
"apparentTemperatureMin": 12.0,
"apparentTemperatureMinTime": 0,
"apparentTemperatureMax": 23.5,
"apparentTemperatureMaxTime": 0
},
{
"time": 1682899200,
"summary": "Nublado",
"icon": "cloudy",
"sunriseTime": 1682925180,
"sunsetTime": 1682975460,
"temperatureHigh": 26.5,
"temperatureLow": 13.5,
"moonPhase": 0,
"precipIntensity": 3,
"precipIntensityMax": 3,
"precipIntensityMaxTime": 0,
"precipProbability": 3,
"precipType": "rain",
"temperatureHighTime": 0,
"temperatureLowTime": 0,
"apparentTemperatureHigh": 24.1,
"apparentTemperatureHighTime": 0,
"apparentTemperatureLow": 10.7,
"apparentTemperatureLowTime": 0,
"dewPoint": 0,
"humidity": 0,
"pressure": 0,
"windSpeed": 18.3,
"windGust": 35.6,
"windGustTime": 0,
"windBearing": 34,
"cloudCover": 0,
"uvIndex": 7.55,
"uvIndexTime": 0,
"visibility": 0,
"ozone": 0,
"temperatureMin": 13.5,
"temperatureMinTime": 0,
"temperatureMax": 26.5,
"temperatureMaxTime": 0,
"apparentTemperatureMin": 10.7,
"apparentTemperatureMinTime": 0,
"apparentTemperatureMax": 24.1,
"apparentTemperatureMaxTime": 0
},
{
"time": 1682985600,
"summary": "Nublado",
"icon": "cloudy",
"sunriseTime": 1683011460,
"sunsetTime": 1683061920,
"temperatureHigh": 28.6,
"temperatureLow": 16.0,
"moonPhase": 0,
"precipIntensity": 0,
"precipIntensityMax": 0,
"precipIntensityMaxTime": 0,
"precipProbability": 0,
"precipType": "rain",
"temperatureHighTime": 0,
"temperatureLowTime": 0,
"apparentTemperatureHigh": 28.8,
"apparentTemperatureHighTime": 0,
"apparentTemperatureLow": 11.8,
"apparentTemperatureLowTime": 0,
"dewPoint": 0,
"humidity": 0,
"pressure": 0,
"windSpeed": 15.4,
"windGust": 25.9,
"windGustTime": 0,
"windBearing": 35,
"cloudCover": 0,
"uvIndex": 7.65,
"uvIndexTime": 0,
"visibility": 0,
"ozone": 0,
"temperatureMin": 16.0,
"temperatureMinTime": 0,
"temperatureMax": 28.6,
"temperatureMaxTime": 0,
"apparentTemperatureMin": 11.8,
"apparentTemperatureMinTime": 0,
"apparentTemperatureMax": 28.8,
"apparentTemperatureMaxTime": 0
},
{
"time": 1683072000,
"summary": "Nublado",
"icon": "cloudy",
"sunriseTime": 1683097800,
"sunsetTime": 1683148380,
"temperatureHigh": 31.3,
"temperatureLow": 18.2,
"moonPhase": 0,
"precipIntensity": 0,
"precipIntensityMax": 0,
"precipIntensityMaxTime": 0,
"precipProbability": 0,
"precipType": "rain",
"temperatureHighTime": 0,
"temperatureLowTime": 0,
"apparentTemperatureHigh": 29.8,
"apparentTemperatureHighTime": 0,
"apparentTemperatureLow": 15.2,
"apparentTemperatureLowTime": 0,
"dewPoint": 0,
"humidity": 0,
"pressure": 0,
"windSpeed": 40.1,
"windGust": 64.1,
"windGustTime": 0,
"windBearing": 263,
"cloudCover": 0,
"uvIndex": 7.7,
"uvIndexTime": 0,
"visibility": 0,
"ozone": 0,
"temperatureMin": 18.2,
"temperatureMinTime": 0,
"temperatureMax": 31.3,
"temperatureMaxTime": 0,
"apparentTemperatureMin": 15.2,
"apparentTemperatureMinTime": 0,
"apparentTemperatureMax": 29.8,
"apparentTemperatureMaxTime": 0
}
]
},
"hourly": {
"summary": null,
"icon": null,
"data": [
{
"time": 1682852400,
"summary": "Nublado",
"icon": "cloudy",
"precipIntensity": 0,
"precipProbability": 0,
"precipType": "rain",
"temperature": 18.6,
"apparentTemperature": 16.3,
"dewPoint": 8.2,
"humidity": 51,
"pressure": 945.1,
"windSpeed": 12.2,
"windGust": 24.8,
"windBearing": 62,
"cloudCover": 0,
"uvIndex": 456.3,
"visibility": 24140.0,
"ozone": 0
},
{
"time": 1682856000,
"summary": "Nublado",
"icon": "cloudy",
"precipIntensity": 0,
"precipProbability": 0,
"precipType": "rain",
"temperature": 20.3,
"apparentTemperature": 18.6,
"dewPoint": 8.3,
"humidity": 46,
"pressure": 945.4,
"windSpeed": 8.2,
"windGust": 25.2,
"windBearing": 61,
"cloudCover": 0,
"uvIndex": 640.9,
"visibility": 24140.0,
"ozone": 0
},
{
"time": 1682859600,
"summary": "Nublado",
"icon": "cloudy",
"precipIntensity": 0,
"precipProbability": 0,
"precipType": "rain",
"temperature": 21.5,
"apparentTemperature": 20.4,
"dewPoint": 8.1,
"humidity": 42,
"pressure": 945.0,
"windSpeed": 4.2,
"windGust": 21.2,
"windBearing": 70,
"cloudCover": 0,
"uvIndex": 670.2,
"visibility": 24140.0,
"ozone": 0
},
{
"time": 1682863200,
"summary": "Nublado",
"icon": "cloudy",
"precipIntensity": 0,
"precipProbability": 0,
"precipType": "rain",
"temperature": 22.7,
"apparentTemperature": 21.2,
"dewPoint": 7.7,
"humidity": 38,
"pressure": 944.4,
"windSpeed": 6.4,
"windGust": 22.3,
"windBearing": 43,
"cloudCover": 0,
"uvIndex": 684.2,
"visibility": 24140.0,
"ozone": 0
}
]
}
}
Loading