Skip to content

Commit

Permalink
gateway: cleanup SensorHT and Plug class (#735)
Browse files Browse the repository at this point in the history
* Update SensorHT and Plug class

Remove properties that do not apply to these devices

* fix wrong model for SensorHT

apprently i mixed this one up when filling in all the models....

* add unit to Plug device
  • Loading branch information
starkillerOG authored Jun 25, 2020
1 parent de28e85 commit f3255e3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions miio/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,9 +951,9 @@ class SensorHT(SubDevice):
"""Subdevice SensorHT specific properties and methods."""

accessor = "get_prop_sensor_ht"
properties = ["temperature", "humidity", "pressure"]
properties = ["temperature", "humidity"]
_zigbee_model = "lumi.sensor_ht"
_model = "RTCGQ01LM"
_model = "WSDCGQ01LM"
_name = "Weather sensor"

@attr.s(auto_attribs=True)
Expand All @@ -962,7 +962,6 @@ class props:

temperature: int = None # in degrees celsius
humidity: int = None # in %
pressure: int = None # in hPa

@command()
def update(self):
Expand All @@ -971,7 +970,6 @@ def update(self):
try:
self._props.temperature = values[0] / 100
self._props.humidity = values[1] / 100
self._props.pressure = values[2] / 100
except Exception as ex:
raise GatewayException(
"One or more unexpected results while "
Expand All @@ -983,7 +981,7 @@ class Plug(SubDevice):
"""Subdevice Plug specific properties and methods."""

accessor = "get_prop_plug"
properties = ["power", "neutral_0", "load_power"]
properties = ["neutral_0", "load_power"]
_zigbee_model = "lumi.plug"
_model = "ZNCZ02LM"
_name = "Plug"
Expand All @@ -993,16 +991,14 @@ class props:
"""Device specific properties."""

status: str = None # 'on' / 'off'
power: int = None # diffrent power consumption?? in ?unit?
load_power: int = None # power consumption in ?unit?
load_power: int = None # power consumption in Watt

@command()
def update(self):
"""Update all device properties."""
values = self.get_property_exp(self.properties)
self._props.power = values[0]
self._props.status = values[1]
self._props.load_power = values[2]
self._props.status = values[0]
self._props.load_power = values[1]


class RemoteSwitchDoubleV1(SubDevice):
Expand Down

0 comments on commit f3255e3

Please sign in to comment.