Skip to content

Commit

Permalink
Bump version to 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
qqaatw committed Apr 21, 2022
1 parent bd7f3ce commit eb39c93
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 61 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ A home assistant integration for retrieving Taipower data, using [libtaipower](h
## Supported devices

- Taipower AMI electric meter 臺電 AMI 電錶
- AMI info AMI 資訊
- AMI info (quarter/hourly/daily/monthly) AMI 資訊 (十五分/每小時/每日/每月)
- Bill records 帳單紀錄
- ~~Taipower electric meter 臺電一般電錶~~
- ~~Bill records 帳單紀錄~~

## Tested devices

Expand Down
5 changes: 3 additions & 2 deletions custom_components/taipower_tw/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Taipower integration."""
import asyncio
import logging
import functools
from dataclasses import dataclass, field
from datetime import timedelta
from typing import Optional
Expand Down Expand Up @@ -85,7 +86,7 @@ async def async_update_data():
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
# handled by the data update coordinator.
async with async_timeout.timeout(BASE_TIMEOUT + len(api.meters) * 2):
await hass.async_add_executor_job(api.refresh_status)
await hass.async_add_executor_job(functools.partial(api.refresh_status, refresh_ami_bill=False))

except asyncio.TimeoutError as err:
raise UpdateFailed(f"Command executed timed out when regularly fetching data.")
Expand Down Expand Up @@ -172,7 +173,7 @@ async def _async_update_data():
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
# handled by the data update coordinator.
async with async_timeout.timeout(BASE_TIMEOUT + len(api.meters) * 2):
await hass.async_add_executor_job(api.refresh_status)
await hass.async_add_executor_job(functools.partial(api.refresh_status, refresh_ami_bill=False))

except asyncio.TimeoutError as err:
raise UpdateFailed(f"Command executed timed out when regularly fetching data.")
Expand Down
2 changes: 1 addition & 1 deletion custom_components/taipower_tw/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.0.1",
"documentation": "https://github.com/qqaatw/taipowerha",
"issue_tracker": "https://github.com/qqaatw/taipowerha/issues",
"requirements": ["libtaipower==0.0.1"],
"requirements": ["libtaipower==0.0.2"],
"codeowners": ["@qqaatw"],
"iot_class": "cloud_polling"
}
12 changes: 5 additions & 7 deletions custom_components/taipower_tw/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(
[
TaipowerAMISelectorNumberEntity(meter, coordinator),
TaipowerMonthlyDataSelectorNumberEntity(meter, coordinator)
TaipowerBillMonthSelectorNumberEntity(meter, coordinator)
],
update_before_add=True
)


Expand All @@ -34,21 +33,20 @@ async def async_setup_entry(hass, config_entry, async_add_devices):
async_add_devices(
[
TaipowerAMISelectorNumberEntity(meter, coordinator),
TaipowerMonthlyDataSelectorNumberEntity(meter, coordinator)
TaipowerBillMonthSelectorNumberEntity(meter, coordinator)
],
update_before_add=True
)


class TaipowerMonthlyDataSelectorNumberEntity(TaipowerEntity, NumberEntity):
class TaipowerBillMonthSelectorNumberEntity(TaipowerEntity, NumberEntity):
def __init__(self, meter, coordinator):
super().__init__(meter, coordinator)
self._value = 0

@property
def name(self):
"""Return the name of the entity."""
return f"{self._meter.name} {self._meter.number} Month Selector"
return f"{self._meter.name} {self._meter.number} Bill Month Selector"

@property
def value(self):
Expand All @@ -67,7 +65,7 @@ def max_value(self):

@property
def unique_id(self):
return f"{self._meter.number}_monthly_data_selector_number"
return f"{self._meter.number}_bill_month_selector_number"

def set_value(self, value):
"""Set new month."""
Expand Down
Loading

0 comments on commit eb39c93

Please # to comment.