From ea2adf9813583abf12cebf4c8d423e2cca626b0a Mon Sep 17 00:00:00 2001 From: caiosweet <24454580+caiosweet@users.noreply.github.com> Date: Fri, 31 Dec 2021 19:54:45 +0100 Subject: [PATCH 1/4] Update binary_sensor.py Only from version 2021.12.x of home assistant, to avoid the warning: Entity binary_sensor.burze_storms_nearby () implements device_state_attributes. Please report it to the custom component author. The property called device_state_attributes has changed to extra_state_attributes. --- custom_components/burze_dzis_net/binary_sensor.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/custom_components/burze_dzis_net/binary_sensor.py b/custom_components/burze_dzis_net/binary_sensor.py index 163a6df..a0a4ef7 100644 --- a/custom_components/burze_dzis_net/binary_sensor.py +++ b/custom_components/burze_dzis_net/binary_sensor.py @@ -121,7 +121,7 @@ def __init__(self, entity_id, name, updater): self._data = None @property - def device_state_attributes(self): + def extra_state_attributes(self): output = dict() output[ATTR_ATTRIBUTION] = ATTRIBUTION return output @@ -142,8 +142,8 @@ def is_on(self): return data is not None and data[self._warning_key] > 0 @property - def device_state_attributes(self): - output = super().device_state_attributes + def extra_state_attributes(self): + output = super().extra_state_attributes if self.is_on: data = self._updater.ostrzezenia_pogodowe_output output['level'] = data[self._warning_key] @@ -171,8 +171,8 @@ def is_on(self): return data is not None and data['liczba'] > 0 @property - def device_state_attributes(self): - output = super().device_state_attributes + def extra_state_attributes(self): + output = super().extra_state_attributes if self.is_on: data = self._updater.szukaj_burzy_output output['number'] = data['liczba'] From 8657a90f7fd121468142e0bc4d7180cca7e336ba Mon Sep 17 00:00:00 2001 From: Piotr Machowski Date: Sun, 23 Jan 2022 03:25:43 +0100 Subject: [PATCH 2/4] Add GitHub actions --- .github/workflows/hacs.yaml | 29 ++++++++++++++++ .github/workflows/hassfest.yaml | 12 +++++++ .github/workflows/release.yaml | 27 +++++++++++++++ hacs.json | 5 ++- info.md | 59 --------------------------------- 5 files changed, 72 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/hacs.yaml create mode 100644 .github/workflows/hassfest.yaml create mode 100644 .github/workflows/release.yaml delete mode 100644 info.md diff --git a/.github/workflows/hacs.yaml b/.github/workflows/hacs.yaml new file mode 100644 index 0000000..a59c9a8 --- /dev/null +++ b/.github/workflows/hacs.yaml @@ -0,0 +1,29 @@ +name: Validate HACS +on: + push: + pull_request: +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + name: Download repo + with: + fetch-depth: 0 + + - uses: actions/setup-python@v2 + name: Setup Python + with: + python-version: '3.8.x' + + - uses: actions/cache@v2 + name: Cache + with: + path: | + ~/.cache/pip + key: custom-component-ci + + - name: HACS Action + uses: hacs/action@main + with: + CATEGORY: integration \ No newline at end of file diff --git a/.github/workflows/hassfest.yaml b/.github/workflows/hassfest.yaml new file mode 100644 index 0000000..d1c56cb --- /dev/null +++ b/.github/workflows/hassfest.yaml @@ -0,0 +1,12 @@ +name: Validate with hassfest + +on: + push: + pull_request: + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v2" + - uses: home-assistant/actions/hassfest@master diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4e503f1 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,27 @@ +name: Release + +on: + release: + types: [published] + +jobs: + release: + name: Prepare release + runs-on: ubuntu-latest + steps: + - name: Download repo + uses: actions/checkout@v1 + + - name: Zip burze_dzis_net dir + run: | + cd /home/runner/work/Home-Assistant-custom-components-Burze.dzis.net/Home-Assistant-custom-components-Burze.dzis.net/custom_components/burze_dzis_net + zip burze_dzis_net.zip -r ./ + + - name: Upload zip to release + uses: svenstaro/upload-release-action@v1-release + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: /home/runner/work/Home-Assistant-custom-components-Burze.dzis.net/Home-Assistant-custom-components-Burze.dzis.net/custom_components/burze_dzis_net/burze_dzis_net.zip + asset_name: burze_dzis_net.zip + tag: ${{ github.ref }} + overwrite: true \ No newline at end of file diff --git a/hacs.json b/hacs.json index 830ecc5..2986106 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,8 @@ { "name": "Burze.dzis.net sensor", "domains": ["binary_sensor"], - "country": ["EU", "PL"] + "country": ["EU", "PL"], + "render_readme": true, + "zip_release": true, + "filename": "antistorm.zip" } \ No newline at end of file diff --git a/info.md b/info.md deleted file mode 100644 index 51f34ed..0000000 --- a/info.md +++ /dev/null @@ -1,59 +0,0 @@ -To get more detailed information about parameters of warnings visit [*official API documentation*](https://burze.dzis.net/soap.php?WSDL). - -## Configuration options - -| Key | Type | Required | Default | Description | -| --- | --- | --- | --- | --- | -| `name` | `string` | `False` | `Burze.dzis.net` | Name of sensor | -| `api_key` | `string` | `True` | - | API key for Burze.dzis.net | -| `latitude` | `float` | `False` | Latitude of home | Latitude of monitored point | -| `longitude` | `float` | `False` | Longitude of home | Longitude of monitored point | -| `warnings` | `list` | `False` | - | List of monitored warnings | -| `storms_nearby` | - | `False` | - | Enables monitoring nearby storms | - -### Configuration options of `storms_nearby` - -| Key | Type | Required | Default | Description | -| --- | --- | --- | --- | --- | -| `radius` | `positive int` | `True` | - | Radius of nearby storms monitoring | - -### Possible monitored warnings - -| Key | Description | -| --- | --- | -| `frost_warning` | Enables frost warnings monitoring | -| `heat_warning` | Enables heat warnings monitoring | -| `wind_warning` | Enables wind warnings monitoring | -| `precipitation_warning` | Enables precipitation warnings monitoring | -| `storm_warning` | Enables storm warnings monitoring | -| `tornado_warning` | Enables tornado warnings monitoring | - -## Example usage - -``` -binary_sensor: - - platform: burze_dzis_net - api_key: !secret burze_dzis_net.api_key - warnings: - - frost_warning - - heat_warning - - wind_warning - - precipitation_warning - - storm_warning - - tornado_warning - storms_nearby: - radius: 30 -``` - -## FAQ - -* **How to get API key?** - - To get API key you have to follow steps available at [*official project page*](https://burze.dzis.net/?page=api_interfejs). - -* **What to do if Home Assistant does not find this component?** - - Most likely you have to install additional dependency required for it to run. Activate Python environment Home Assistant is running in and use following command: - ```bash - pip install zeep - ``` From ecf5c6e9340250bf0cc63b077269b4d14e23d3d2 Mon Sep 17 00:00:00 2001 From: Piotr Machowski Date: Sun, 23 Jan 2022 03:27:03 +0100 Subject: [PATCH 3/4] Add device class --- custom_components/burze_dzis_net/__init__.py | 1 + custom_components/burze_dzis_net/binary_sensor.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 custom_components/burze_dzis_net/__init__.py diff --git a/custom_components/burze_dzis_net/__init__.py b/custom_components/burze_dzis_net/__init__.py new file mode 100644 index 0000000..ea6b137 --- /dev/null +++ b/custom_components/burze_dzis_net/__init__.py @@ -0,0 +1 @@ +"""Burze.dzis.net""" \ No newline at end of file diff --git a/custom_components/burze_dzis_net/binary_sensor.py b/custom_components/burze_dzis_net/binary_sensor.py index a0a4ef7..6f32367 100644 --- a/custom_components/burze_dzis_net/binary_sensor.py +++ b/custom_components/burze_dzis_net/binary_sensor.py @@ -4,7 +4,7 @@ from homeassistant.util import Throttle from homeassistant.util.dt import parse_datetime -from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, ENTITY_ID_FORMAT +from homeassistant.components.binary_sensor import DEVICE_CLASS_SAFETY, PLATFORM_SCHEMA, ENTITY_ID_FORMAT from homeassistant.const import CONF_NAME, CONF_RADIUS, CONF_API_KEY, ATTR_ATTRIBUTION, CONF_LATITUDE, CONF_LONGITUDE, \ CONF_SCAN_INTERVAL import homeassistant.helpers.config_validation as cv @@ -126,6 +126,10 @@ def extra_state_attributes(self): output[ATTR_ATTRIBUTION] = ATTRIBUTION return output + @property + def device_class(self): + return DEVICE_CLASS_SAFETY + async def async_update(self): await self._updater.async_update() From 12a619e1426e92dc0846e2fd0608b8c1605dfb66 Mon Sep 17 00:00:00 2001 From: Piotr Machowski Date: Sun, 23 Jan 2022 03:27:44 +0100 Subject: [PATCH 4/4] Update documentation --- LICENSE | 2 +- README.md | 41 +++++++++++++++---- .../burze_dzis_net/manifest.json | 4 +- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index 689f77c..1d3c91d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Piotr Machowski +Copyright (c) 2022 Piotr Machowski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e3a33e4..095a18e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,26 @@ -# Burze.dzis.net sensor +[![HACS Default][hacs_shield]][hacs] +[![GitHub Latest Release][releases_shield]][latest_release] +[![GitHub All Releases][downloads_total_shield]][releases] +[![Buy me a coffee][buy_me_a_coffee_shield]][buy_me_a_coffee] +[![PayPal.Me][paypal_me_shield]][paypal_me] + + +[hacs_shield]: https://img.shields.io/static/v1.svg?label=HACS&message=Default&style=popout&color=green&labelColor=41bdf5&logo=HomeAssistantCommunityStore&logoColor=white +[hacs]: https://hacs.xyz/docs/default_repositories + +[latest_release]: https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/releases/latest +[releases_shield]: https://img.shields.io/github/release/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net.svg?style=popout + +[releases]: https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/releases +[downloads_total_shield]: https://img.shields.io/github/downloads/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/total + +[buy_me_a_coffee_shield]: https://img.shields.io/static/v1.svg?label=%20&message=Buy%20me%20a%20coffee&color=6f4e37&logo=buy%20me%20a%20coffee&logoColor=white +[buy_me_a_coffee]: https://www.buymeacoffee.com/PiotrMachowski -[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/custom-components/hacs) -[![buymeacoffee_badge](https://img.shields.io/badge/Donate-Buy%20Me%20a%20Coffee-ff813f?style=flat)](https://www.buymeacoffee.com/PiotrMachowski) -[![paypalme_badge](https://img.shields.io/badge/Donate-PayPal-0070ba?style=flat)](https://paypal.me/PiMachowski) +[paypal_me_shield]: https://img.shields.io/static/v1.svg?label=%20&message=PayPal.Me&logo=paypal +[paypal_me]: https://paypal.me/PiMachowski + +# Burze.dzis.net sensor This sensor uses official API to get weather warnings from [*Burze.dzis.net*](https://burze.dzis.net/). To get more detailed information about parameters of warnings visit [*official API documentation*](https://burze.dzis.net/soap.php?WSDL). @@ -53,12 +71,20 @@ binary_sensor: ## Installation -Download [*binary_sensor.py*](https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/raw/master/custom_components/burze_dzis_net/binary_sensor.py) and [*manifest.json*](https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/raw/master/custom_components/burze_dzis_net/manifest.json) to `config/custom_components/burze_dzis_net` directory: +### Using [HACS](https://hacs.xyz/) (recommended) + +This integration can be installed using HACS. +To do it search for `Burze.dzis.net` in *Integrations* section. + +### Manual + +To install this integration manually you have to download [*burze_dzis_net.zip*](https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/releases/latest/download/burze_dzis_net.zip) and extract its contents to `config/custom_components/burze_dzis_net` directory: ```bash mkdir -p custom_components/burze_dzis_net cd custom_components/burze_dzis_net -wget https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/raw/master/custom_components/burze_dzis_net/binary_sensor.py -wget https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/raw/master/custom_components/burze_dzis_net/manifest.json +wget https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/releases/latest/download/burze_dzis_net.zip +unzip burze_dzis_net.zip +rm burze_dzis_net.zip ``` ## FAQ @@ -75,3 +101,4 @@ wget https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dz ``` Buy Me A Coffee +PayPal Logo diff --git a/custom_components/burze_dzis_net/manifest.json b/custom_components/burze_dzis_net/manifest.json index 79aa599..ed7db0e 100644 --- a/custom_components/burze_dzis_net/manifest.json +++ b/custom_components/burze_dzis_net/manifest.json @@ -2,8 +2,10 @@ "domain": "burze_dzis_net", "name": "Burze.dzis.net", "documentation": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net", + "issue_tracker": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Burze.dzis.net/issues", "dependencies": [], "codeowners": ["@PiotrMachowski"], "requirements": ["zeep"], - "version": "v1.0.3" + "version": "v1.0.4", + "iot_class": "cloud_polling" } \ No newline at end of file