-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split features and move battery to base entity
- Loading branch information
Showing
19 changed files
with
150 additions
and
81 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
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,39 @@ | ||
"""The humidity device class.""" | ||
# -*- coding: utf-8 -*- | ||
|
||
import logging | ||
|
||
from .fritzhomedevicebase import FritzhomeDeviceBase | ||
from .fritzhomedevicefeatures import FritzhomeDeviceFeatures | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class FritzhomeDeviceHumidity(FritzhomeDeviceBase): | ||
"""The Fritzhome Device class.""" | ||
|
||
rel_humidity = None | ||
|
||
def _update_from_node(self, node): | ||
super()._update_from_node(node) | ||
if self.present is False: | ||
return | ||
|
||
if self.has_humidity_sensor: | ||
self._update_humidity_from_node(node) | ||
|
||
# Humidity | ||
@property | ||
def has_humidity_sensor(self): | ||
"""Check if the device has humidity function.""" | ||
return self._has_feature(FritzhomeDeviceFeatures.HUMIDITY) | ||
|
||
def _update_humidity_from_node(self, node): | ||
_LOGGER.debug("update humidity device") | ||
humidity_element = node.find("humidity") | ||
try: | ||
self.rel_humidity = self.get_node_value_as_int( | ||
humidity_element, "rel_humidity" | ||
) | ||
except ValueError: | ||
pass |
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,57 @@ | ||
"""The level device class.""" | ||
# -*- coding: utf-8 -*- | ||
|
||
import logging | ||
|
||
from .fritzhomedevicebase import FritzhomeDeviceBase | ||
from .fritzhomedevicefeatures import FritzhomeDeviceFeatures | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class FritzhomeDeviceLevel(FritzhomeDeviceBase): | ||
"""The Fritzhome Device class.""" | ||
|
||
level = None | ||
levelpercentage = None | ||
|
||
def _update_from_node(self, node): | ||
super()._update_from_node(node) | ||
if self.present is False: | ||
return | ||
|
||
if self.has_level: | ||
self._update_level_from_node(node) | ||
|
||
# Level | ||
@property | ||
def has_level(self): | ||
"""Check if the device has level function.""" | ||
return self._has_feature(FritzhomeDeviceFeatures.LEVEL) | ||
|
||
def _update_level_from_node(self, node): | ||
_LOGGER.debug("update level device") | ||
levelcontrol_element = node.find("levelcontrol") | ||
try: | ||
self.level = self.get_node_value_as_int(levelcontrol_element, "level") | ||
self.levelpercentage = self.get_node_value_as_int( | ||
levelcontrol_element, "levelpercentage" | ||
) | ||
except Exception: | ||
pass | ||
|
||
def get_level(self): | ||
"""Get the level.""" | ||
return self.level | ||
|
||
def get_level_percentage(self): | ||
"""Get the level in percentage.""" | ||
return self.levelpercentage | ||
|
||
def set_level(self, level): | ||
"""Set the level.""" | ||
self._fritz.set_level(self.ain, level) | ||
|
||
def set_level_percentage(self, levelpercentage): | ||
"""Set the level in percentage.""" | ||
self._fritz.set_level_percentage(self.ain, levelpercentage) |
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
Oops, something went wrong.