Skip to content

Commit 06c171f

Browse files
Merge pull request #203 from PiotrMachowski/dev
v2.6.1
2 parents 3c58741 + 989ef49 commit 06c171f

File tree

9 files changed

+35
-25
lines changed

9 files changed

+35
-25
lines changed

.github/workflows/release.yaml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,35 @@ on:
44
release:
55
types: [published]
66

7+
env:
8+
COMPONENT_NAME: tauron_amiplus
9+
710
jobs:
811
release:
912
name: Prepare release
1013
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
id-token: write
1117
steps:
1218
- name: Download repo
13-
uses: actions/checkout@v1
19+
uses: actions/[email protected]
20+
21+
- name: Adjust version number
22+
shell: bash
23+
run: |
24+
version="${{ github.event.release.tag_name }}"
25+
yq e -P -o=json \
26+
-i ".version = \"${version}\"" \
27+
"${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}/manifest.json"
1428
15-
- name: Zip tauron_amiplus dir
29+
- name: Zip ${{ env.COMPONENT_NAME }} dir
1630
run: |
17-
cd /home/runner/work/Home-Assistant-custom-components-Tauron-AMIplus/Home-Assistant-custom-components-Tauron-AMIplus/custom_components/tauron_amiplus
18-
zip tauron_amiplus.zip -r ./
31+
cd "${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}"
32+
zip ${{ env.COMPONENT_NAME }}.zip -r ./
33+
1934
2035
- name: Upload zip to release
21-
uses: svenstaro/upload-release-action@v1-release
36+
uses: softprops/action-gh-release@v2.2.0
2237
with:
23-
repo_token: ${{ secrets.GITHUB_TOKEN }}
24-
file: /home/runner/work/Home-Assistant-custom-components-Tauron-AMIplus/Home-Assistant-custom-components-Tauron-AMIplus/custom_components/tauron_amiplus/tauron_amiplus.zip
25-
asset_name: tauron_amiplus.zip
26-
tag: ${{ github.ref }}
27-
overwrite: true
38+
files: ${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}/${{ env.COMPONENT_NAME }}.zip

custom_components/tauron_amiplus/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
from .const import (
1414
CONF_METER_ID, CONF_METER_NAME, CONF_SHOW_12_MONTHS, CONF_SHOW_BALANCED, CONF_SHOW_BALANCED_YEAR,
1515
CONF_SHOW_CONFIGURABLE, CONF_SHOW_CONFIGURABLE_DATE, CONF_SHOW_GENERATION, CONF_STORE_STATISTICS, CONF_TARIFF,
16-
DOMAIN,
16+
DOMAIN, PLATFORMS,
1717
)
1818
from .services import DownloadStatisticsService
1919

20-
2120
_LOGGER = logging.getLogger(__name__)
2221

2322
MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=600)
@@ -51,9 +50,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
5150
if DOMAIN not in hass.data:
5251
hass.data[DOMAIN] = {}
5352

54-
hass.async_create_task(
55-
hass.config_entries.async_forward_entry_setup(config_entry, "sensor")
56-
)
53+
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
5754
config_entry.async_on_unload(config_entry.add_update_listener(async_reload_entry))
5855
service = DownloadStatisticsService(hass)
5956
hass.services.async_register(service.domain, service.service, service.async_handle_service, service.schema)
@@ -62,7 +59,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
6259

6360
async def async_unload_entry(hass, config_entry):
6461
"""Unload a config entry."""
65-
await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
62+
await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
6663
return True
6764

6865

custom_components/tauron_amiplus/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
from datetime import timedelta
33

44
from homeassistant.components.sensor import SensorStateClass
5+
from homeassistant.const import Platform
56

7+
PLATFORMS = [Platform.SENSOR]
68
DOMAIN = "tauron_amiplus"
79
STATISTICS_DOMAIN = "tauron_importer"
810
DEFAULT_NAME = "Tauron AMIplus"

custom_components/tauron_amiplus/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"iot_class": "cloud_polling",
99
"issue_tracker": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Tauron-AMIplus/issues",
1010
"requirements": ["requests"],
11-
"version": "v2.6.0"
11+
"version": "v0.0.0"
1212
}

custom_components/tauron_amiplus/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ async def async_handle_service(self, call: ServiceCall) -> None:
3939
_LOGGER.error(f"Failed to download statistics, date from the future: {start_date}")
4040
return
4141
device = device_registry.async_get(call.data["device_id"])
42-
[config_entry_id] = device.config_entries
42+
[config_entry_id, *_] = device.config_entries
4343
config_entry = self._hass.config_entries.async_get_entry(config_entry_id)
4444
await TauronAmiplusStatisticsUpdater.manually_update(self._hass, start_date, config_entry)

custom_components/tauron_amiplus/statistics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from homeassistant.components.recorder.models import StatisticMetaData
66
from homeassistant.components.recorder.statistics import (async_add_external_statistics, get_last_statistics,
77
statistics_during_period)
8-
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, ENERGY_KILO_WATT_HOUR
8+
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, UnitOfEnergy
99
from homeassistant.core import HomeAssistant
1010
from homeassistant.util.dt import as_utc, get_time_zone, utc_from_timestamp
1111

@@ -215,7 +215,7 @@ async def update_stats(self, statistic_id, statistic_name, initial_sum, last_sta
215215
"name": statistic_name,
216216
"source": STATISTICS_DOMAIN,
217217
"statistic_id": statistic_id,
218-
"unit_of_measurement": ENERGY_KILO_WATT_HOUR
218+
"unit_of_measurement": UnitOfEnergy.KILO_WATT_HOUR
219219
}
220220
statistic_data = []
221221
for raw_hour in raw_data:

custom_components/tauron_amiplus/strings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
},
77
"init": {
88
"title": "Enter the connection parameters to the TAURON eLicznik.",
9-
"description": "We will add sensors to get energy usage data from TAURON eLicznik.\n\n {error_info} ",
9+
"description": "We will add sensors to get energy usage data from TAURON eLicznik.\n\n {error_info}",
1010
"data": {
1111
"username": "Username used to login at eLicznik",
1212
"password": "Password used to login at eLicznik"
1313
}
1414
},
1515
"select_meter": {
1616
"title": "Energy meter",
17-
"description": "Choose an energy meter you want to configure\n\n {error_info} ",
17+
"description": "Choose an energy meter you want to configure\n\n {error_info}",
1818
"data": {
1919
"energy_meter_id": "Available energy meters"
2020
}

custom_components/tauron_amiplus/translations/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
},
77
"init": {
88
"title": "Enter the connection parameters to the TAURON eLicznik.",
9-
"description": "We will add sensors to get energy usage data from TAURON eLicznik.\n\n {error_info} ",
9+
"description": "We will add sensors to get energy usage data from TAURON eLicznik.\n\n {error_info}",
1010
"data": {
1111
"username": "Username used to login at eLicznik",
1212
"password": "Password used to login at eLicznik"
1313
}
1414
},
1515
"select_meter": {
1616
"title": "Energy meter",
17-
"description": "Choose an energy meter you want to configure\n\n {error_info} ",
17+
"description": "Choose an energy meter you want to configure\n\n {error_info}",
1818
"data": {
1919
"energy_meter_id": "Available energy meters"
2020
}

custom_components/tauron_amiplus/translations/pl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"select_meter": {
1616
"title": "Punkt poboru",
17-
"description": "Wybierz punkt poboru, który chcesz skonfigurować\n\n {error_info} ",
17+
"description": "Wybierz punkt poboru, który chcesz skonfigurować\n\n {error_info}",
1818
"data": {
1919
"energy_meter_id": "Dostępne punkty poboru"
2020
}

0 commit comments

Comments
 (0)