Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.6.1 #203

Merged
merged 9 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 21 additions & 10 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@ on:
release:
types: [published]

env:
COMPONENT_NAME: tauron_amiplus

jobs:
release:
name: Prepare release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Download repo
uses: actions/checkout@v1
uses: actions/[email protected]

- name: Adjust version number
shell: bash
run: |
version="${{ github.event.release.tag_name }}"
yq e -P -o=json \
-i ".version = \"${version}\"" \
"${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}/manifest.json"

- name: Zip tauron_amiplus dir
- name: Zip ${{ env.COMPONENT_NAME }} dir
run: |
cd /home/runner/work/Home-Assistant-custom-components-Tauron-AMIplus/Home-Assistant-custom-components-Tauron-AMIplus/custom_components/tauron_amiplus
zip tauron_amiplus.zip -r ./
cd "${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}"
zip ${{ env.COMPONENT_NAME }}.zip -r ./


- name: Upload zip to release
uses: svenstaro/upload-release-action@v1-release
uses: softprops/action-gh-release@v2.2.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /home/runner/work/Home-Assistant-custom-components-Tauron-AMIplus/Home-Assistant-custom-components-Tauron-AMIplus/custom_components/tauron_amiplus/tauron_amiplus.zip
asset_name: tauron_amiplus.zip
tag: ${{ github.ref }}
overwrite: true
files: ${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}/${{ env.COMPONENT_NAME }}.zip
9 changes: 3 additions & 6 deletions custom_components/tauron_amiplus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
from .const import (
CONF_METER_ID, CONF_METER_NAME, CONF_SHOW_12_MONTHS, CONF_SHOW_BALANCED, CONF_SHOW_BALANCED_YEAR,
CONF_SHOW_CONFIGURABLE, CONF_SHOW_CONFIGURABLE_DATE, CONF_SHOW_GENERATION, CONF_STORE_STATISTICS, CONF_TARIFF,
DOMAIN,
DOMAIN, PLATFORMS,
)
from .services import DownloadStatisticsService


_LOGGER = logging.getLogger(__name__)

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

hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, "sensor")
)
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
config_entry.async_on_unload(config_entry.add_update_listener(async_reload_entry))
service = DownloadStatisticsService(hass)
hass.services.async_register(service.domain, service.service, service.async_handle_service, service.schema)
Expand All @@ -62,7 +59,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):

async def async_unload_entry(hass, config_entry):
"""Unload a config entry."""
await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")
await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
return True


Expand Down
2 changes: 2 additions & 0 deletions custom_components/tauron_amiplus/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from datetime import timedelta

from homeassistant.components.sensor import SensorStateClass
from homeassistant.const import Platform

PLATFORMS = [Platform.SENSOR]
DOMAIN = "tauron_amiplus"
STATISTICS_DOMAIN = "tauron_importer"
DEFAULT_NAME = "Tauron AMIplus"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tauron_amiplus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Tauron-AMIplus/issues",
"requirements": ["requests"],
"version": "v2.6.0"
"version": "v0.0.0"
}
2 changes: 1 addition & 1 deletion custom_components/tauron_amiplus/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ async def async_handle_service(self, call: ServiceCall) -> None:
_LOGGER.error(f"Failed to download statistics, date from the future: {start_date}")
return
device = device_registry.async_get(call.data["device_id"])
[config_entry_id] = device.config_entries
[config_entry_id, *_] = device.config_entries
config_entry = self._hass.config_entries.async_get_entry(config_entry_id)
await TauronAmiplusStatisticsUpdater.manually_update(self._hass, start_date, config_entry)
4 changes: 2 additions & 2 deletions custom_components/tauron_amiplus/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from homeassistant.components.recorder.models import StatisticMetaData
from homeassistant.components.recorder.statistics import (async_add_external_statistics, get_last_statistics,
statistics_during_period)
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, ENERGY_KILO_WATT_HOUR
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, UnitOfEnergy
from homeassistant.core import HomeAssistant
from homeassistant.util.dt import as_utc, get_time_zone, utc_from_timestamp

Expand Down Expand Up @@ -215,7 +215,7 @@ async def update_stats(self, statistic_id, statistic_name, initial_sum, last_sta
"name": statistic_name,
"source": STATISTICS_DOMAIN,
"statistic_id": statistic_id,
"unit_of_measurement": ENERGY_KILO_WATT_HOUR
"unit_of_measurement": UnitOfEnergy.KILO_WATT_HOUR
}
statistic_data = []
for raw_hour in raw_data:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/tauron_amiplus/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
},
"init": {
"title": "Enter the connection parameters to the TAURON eLicznik.",
"description": "We will add sensors to get energy usage data from TAURON eLicznik.\n\n {error_info} ",
"description": "We will add sensors to get energy usage data from TAURON eLicznik.\n\n {error_info}",
"data": {
"username": "Username used to login at eLicznik",
"password": "Password used to login at eLicznik"
}
},
"select_meter": {
"title": "Energy meter",
"description": "Choose an energy meter you want to configure\n\n {error_info} ",
"description": "Choose an energy meter you want to configure\n\n {error_info}",
"data": {
"energy_meter_id": "Available energy meters"
}
Expand Down
4 changes: 2 additions & 2 deletions custom_components/tauron_amiplus/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
},
"init": {
"title": "Enter the connection parameters to the TAURON eLicznik.",
"description": "We will add sensors to get energy usage data from TAURON eLicznik.\n\n {error_info} ",
"description": "We will add sensors to get energy usage data from TAURON eLicznik.\n\n {error_info}",
"data": {
"username": "Username used to login at eLicznik",
"password": "Password used to login at eLicznik"
}
},
"select_meter": {
"title": "Energy meter",
"description": "Choose an energy meter you want to configure\n\n {error_info} ",
"description": "Choose an energy meter you want to configure\n\n {error_info}",
"data": {
"energy_meter_id": "Available energy meters"
}
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tauron_amiplus/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"select_meter": {
"title": "Punkt poboru",
"description": "Wybierz punkt poboru, który chcesz skonfigurować\n\n {error_info} ",
"description": "Wybierz punkt poboru, który chcesz skonfigurować\n\n {error_info}",
"data": {
"energy_meter_id": "Dostępne punkty poboru"
}
Expand Down
Loading