Skip to content

Commit

Permalink
Merge pull request #10 from mypal/test
Browse files Browse the repository at this point in the history
version 1.2.1
  • Loading branch information
mypal authored Jul 19, 2021
2 parents aa9ea91 + bacb364 commit 7ad154d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 2 additions & 0 deletions custom_components/ds_air/ds_air_service/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Sensor(Device):
"humidity_lower", "pm25_upper", "pm25_lower", "co2_upper", "co2_lower", "voc_lower", "tvoc_upper",
"hcho_upper", "connected", "sleep_mode_count", "time_millis"]

UNINITIALIZED_VALUE = -1000

def __init__(self):
Device.__init__(self)
self.mac: str = ''
Expand Down
12 changes: 6 additions & 6 deletions custom_components/ds_air/ds_air_service/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,24 @@ def load_bytes(self, b):
sensor.name = sensor.alias
sensor.type1 = d.read1()
sensor.type2 = d.read1()
humidity = -10000
hcho = -1000
temp = -1000
humidity = Sensor.UNINITIALIZED_VALUE
hcho = Sensor.UNINITIALIZED_VALUE
temp = Sensor.UNINITIALIZED_VALUE
if (sensor.type1 & 1) == 1:
temp = d.read2()
if ((sensor.type1 >> 1) & 1) == 1:
humidity = d.read2()
pm25 = -1000
pm25 = Sensor.UNINITIALIZED_VALUE
if (sensor.type1 >> 2) & 1 == 1:
pm25 = d.read2()
co2 = -1000
co2 = Sensor.UNINITIALIZED_VALUE
if (sensor.type1 >> 3) & 1 == 1:
co2 = d.read2()
voc = EnumSensor.Voc.STEP_UNUSE
if (sensor.type1 >> 4) & 1 == 1:
f = d.read1()
voc = EnumSensor.Voc(f)
tvoc = -1000
tvoc = Sensor.UNINITIALIZED_VALUE
if (sensor.type1 >> 5) & 1 == 1:
tvoc = d.read2()
if (sensor.type1 >> 6) & 1 == 1:
Expand Down
3 changes: 0 additions & 3 deletions custom_components/ds_air/ds_air_service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ def run(self) -> None:
if cnt == 5:
cnt = 0
Service.poll_status()
p = Sensor2InfoParam()
Service.send_msg(p)
time.sleep(60)


Expand Down Expand Up @@ -274,7 +272,6 @@ def set_sensors_status(sensors: typing.List[Sensor]):
func(newSensor)
except Exception as e:
_log(str(e))
break

@staticmethod
def poll_status():
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ds_air/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"dependencies": [],
"codeowners": [],
"requirements": [],
"version": "1.2.0",
"version": "1.2.1",
"config_flow": true
}
3 changes: 2 additions & 1 deletion custom_components/ds_air/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def state(self):
def parse_data(self, device: Sensor, not_update: bool = False):
"""Parse data sent by gateway."""
self._is_available = device.connected and device.switch_on_off
self._state = getattr(device, self._data_key) / SENSOR_TYPES.get(self._data_key)[3]
if Sensor.UNINITIALIZED_VALUE != getattr(device, self._data_key):
self._state = getattr(device, self._data_key) / SENSOR_TYPES.get(self._data_key)[3]
if not not_update:
self.schedule_update_ha_state()
return True

0 comments on commit 7ad154d

Please sign in to comment.