-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support toggling Ionizer, UILight and SafetyLock * Add Swedish translation * Small fix for translations * Handle incorrect fan speed percentage ( hopefully fixing #66) Tested on A9/AX9
- Loading branch information
1 parent
95c66b3
commit 3532990
Showing
9 changed files
with
112 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Switch platform for Wellbeing.""" | ||
from homeassistant.components.switch import SwitchEntity | ||
from .const import DOMAIN | ||
from .entity import WellbeingEntity | ||
|
||
async def async_setup_entry(hass, entry, async_add_devices): | ||
"""Setup switch platform.""" | ||
coordinator = hass.data[DOMAIN][entry.entry_id] | ||
appliances = coordinator.data.get('appliances', None) | ||
|
||
if appliances is not None: | ||
for pnc_id, appliance in appliances.appliances.items(): | ||
# Assuming that the appliance supports these features | ||
async_add_devices([ | ||
WellbeingSwitch(coordinator, entry, pnc_id, "Ionizer"), | ||
WellbeingSwitch(coordinator, entry, pnc_id, "UILight"), | ||
WellbeingSwitch(coordinator, entry, pnc_id, "SafetyLock"), | ||
]) | ||
|
||
class WellbeingSwitch(WellbeingEntity, SwitchEntity): | ||
"""Wellbeing Switch class.""" | ||
|
||
def __init__(self, coordinator, config_entry, pnc_id, function): | ||
super().__init__(coordinator, config_entry, pnc_id, "binary_sensor", function) | ||
self._function = function | ||
self._is_on = self.get_entity.state | ||
|
||
@property | ||
def is_on(self): | ||
"""Return true if switch is on.""" | ||
return self._is_on | ||
|
||
async def async_turn_on(self, **kwargs): | ||
"""Turn the switch on.""" | ||
await self.coordinator.api.set_feature_state(self.pnc_id, self._function, True) | ||
self._is_on = True | ||
self.async_write_ha_state() | ||
await self.coordinator.async_request_refresh() | ||
|
||
async def async_turn_off(self, **kwargs): | ||
"""Turn the switch off.""" | ||
await self.coordinator.api.set_feature_state(self.pnc_id, self._function, False) | ||
self._is_on = False | ||
self.async_write_ha_state() | ||
await self.coordinator.async_request_refresh() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"config": { | ||
"step": { | ||
"user": { | ||
"description": "Om du behöver hjälp med konfigurationen, se här: https://github.com/JohNan/homeassistant-wellbeing", | ||
"data": { | ||
"username": "Användarnamn", | ||
"password": "Lösenord" | ||
} | ||
}, | ||
"reauth_validate": { | ||
"data": { | ||
"password": "Lösenord" | ||
}, | ||
"description": "Ange lösenord för {username}.", | ||
"title": "Återautentisera Electrolux-kontot" | ||
} | ||
}, | ||
"error": { | ||
"auth": "Användarnamn eller lösenord är felaktigt." | ||
}, | ||
"abort": { | ||
"single_instance_allowed": "Endast en instans är tillåten." | ||
} | ||
}, | ||
"options": { | ||
"step": { | ||
"user": { | ||
"data": { | ||
"scan_interval": "API-uppdateringsintervall (sekunder)", | ||
"binary_sensor": "Binär sensor aktiverad", | ||
"sensor": "Sensor aktiverad", | ||
"switch": "Brytare aktiverad" | ||
} | ||
} | ||
} | ||
} | ||
} |