Skip to content

Commit

Permalink
A bunch of fixes (JohNan#27)
Browse files Browse the repository at this point in the history
* Set correct speed count

* Remove title from user step

* Include appliance name in entity id
  • Loading branch information
JohNan authored Apr 4, 2022
1 parent e98cd3c commit 710ff8f
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 19 deletions.
6 changes: 3 additions & 3 deletions custom_components/wellbeing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ def setup(self, data):
]

@property
def speed_range(self):
def speed_range(self) -> tuple:
if self.model == "WELLA7":
return 1, 5
if self.model == "PUREA9":
return 1, 9

return 0
return 0, 0


class Appliances:
def __init__(self, appliances) -> None:
self.appliances = appliances

def get_appliance(self, pnc_id):
def get_appliance(self, pnc_id) -> Appliance | None:
return self.appliances.get(pnc_id, None)


Expand Down
4 changes: 0 additions & 4 deletions custom_components/wellbeing/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""
self._errors = {}

# Uncomment the next 2 lines if only a single instance of the integration is allowed:
# if self._async_current_entries():
# return self.async_abort(reason="single_instance_allowed")

if user_input is not None:
valid = await self._test_credentials(
user_input[CONF_USERNAME], user_input[CONF_PASSWORD]
Expand Down
2 changes: 1 addition & 1 deletion custom_components/wellbeing/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, coordinator: WellbeingDataUpdateCoordinator, config_entry, pn
self.entity_type = entity_type
self.config_entry = config_entry
self.pnc_id = pnc_id
self.entity_id = ENTITY_ID_FORMAT.format(f"{DEFAULT_NAME}_{self.entity_attr}")
self.entity_id = ENTITY_ID_FORMAT.format(f"{DEFAULT_NAME}_{self.get_appliance.name}_{self.entity_attr}")

@property
def name(self):
Expand Down
9 changes: 2 additions & 7 deletions custom_components/wellbeing/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ def __init__(self, coordinator: WellbeingDataUpdateCoordinator, config_entry, pn
self._speed = self.get_entity.state

@property
def _speed_range(self):
def _speed_range(self) -> tuple:
return self.get_appliance.speed_range

@property
def name(self):
"""Return the name of the sensor."""
return self.get_entity.name

@property
def speed_count(self) -> int:
"""Return the number of speeds the fan supports."""
return len(self.speed_list)
return self._speed_range[1]

@property
def percentage(self):
Expand Down
1 change: 0 additions & 1 deletion custom_components/wellbeing/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"config": {
"step": {
"user": {
"title": "Wellbeing",
"description": "If you need help with the configuration have a look here: https://github.com/JohNan/homeassistant-wellbeing",
"data": {
"username": "Username",
Expand Down
1 change: 0 additions & 1 deletion custom_components/wellbeing/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"config": {
"step": {
"user": {
"title": "Wellbeing",
"description": "Si vous avez besoin d'aide pour la configuration, regardez ici: https://github.com/JohNan/homeassistant-wellbeing",
"data": {
"username": "Identifiant",
Expand Down
1 change: 0 additions & 1 deletion custom_components/wellbeing/translations/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"config": {
"step": {
"user": {
"title": "Wellbeing",
"description": "Hvis du trenger hjep til konfigurasjon ta en titt her: https://github.com/JohNan/homeassistant-wellbeing",
"data": {
"username": "Brukernavn",
Expand Down
1 change: 0 additions & 1 deletion custom_components/wellbeing/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"config": {
"step": {
"user": {
"title": "Wellbeing",
"description": "Jeśli potrzebujesz pomocy z konfiguracją zajrzyj tutaj: https://github.com/JohNan/homeassistant-wellbeing",
"data": {
"username": "Nazwa użytkownika",
Expand Down

0 comments on commit 710ff8f

Please sign in to comment.