Skip to content

Commit

Permalink
Merge branch 'master' into Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG authored Nov 14, 2022
2 parents 7120c8f + 10464c9 commit 70cac3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 14 additions & 8 deletions miio/devicestatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __getattr__(self, item):
return getattr(self._embedded[embed], prop)


def sensor(name: str, *, unit: str = "", **kwargs):
def sensor(name: str, *, unit: Optional[str] = None, **kwargs):
"""Syntactic sugar to create SensorDescriptor objects.
The information can be used by users of the library to programmatically find out what
Expand All @@ -144,7 +144,8 @@ def sensor(name: str, *, unit: str = "", **kwargs):
"""

def decorator_sensor(func):
property_name = func.__name__
property_name = str(func.__name__)
qualified_name = str(func.__qualname__)

def _sensor_type_for_return_type(func):
rtype = get_type_hints(func).get("return")
Expand All @@ -158,8 +159,8 @@ def _sensor_type_for_return_type(func):

sensor_type = _sensor_type_for_return_type(func)
descriptor = SensorDescriptor(
id=str(property_name),
property=str(property_name),
id=qualified_name,
property=property_name,
name=name,
unit=unit,
type=sensor_type,
Expand Down Expand Up @@ -197,14 +198,19 @@ def setting(
"""

def decorator_setting(func):
property_name = func.__name__
property_name = str(func.__name__)
qualified_name = str(func.__qualname__)

if setter is None and setter_name is None:
raise Exception("Either setter or setter_name needs to be defined")
raise Exception("setter_name needs to be defined")
if setter_name is None:
raise NotImplementedError(
"setter not yet implemented, use setter_name instead"
)

common_values = {
"id": str(property_name),
"property": str(property_name),
"id": qualified_name,
"property": property_name,
"name": name,
"unit": unit,
"setter": setter,
Expand Down
2 changes: 2 additions & 0 deletions miio/integrations/light/philips/philips_bulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

MODEL_PHILIPS_LIGHT_BULB = "philips.light.bulb"
MODEL_PHILIPS_LIGHT_HBULB = "philips.light.hbulb"
MODEL_PHILIPS_LIGHT_CBULB = "philips.light.cbulb"
MODEL_PHILIPS_ZHIRUI_DOWNLIGHT = "philips.light.downlight"
MODEL_PHILIPS_CANDLE = "philips.light.candle"
MODEL_PHILIPS_CANDLE2 = "philips.light.candle2"
Expand All @@ -21,6 +22,7 @@
AVAILABLE_PROPERTIES = {
MODEL_PHILIPS_LIGHT_HBULB: AVAILABLE_PROPERTIES_COMMON + ["bri"],
MODEL_PHILIPS_LIGHT_BULB: AVAILABLE_PROPERTIES_COLORTEMP,
MODEL_PHILIPS_LIGHT_CBULB: AVAILABLE_PROPERTIES_COLORTEMP,
MODEL_PHILIPS_ZHIRUI_DOWNLIGHT: AVAILABLE_PROPERTIES_COLORTEMP,
MODEL_PHILIPS_CANDLE: AVAILABLE_PROPERTIES_COLORTEMP,
MODEL_PHILIPS_CANDLE2: AVAILABLE_PROPERTIES_COLORTEMP,
Expand Down

0 comments on commit 70cac3e

Please sign in to comment.