Skip to content

Commit a543d39

Browse files
committed
Added support for ware 2nd gen.
1 parent 789d71f commit a543d39

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

custom_components/airthings_wave/airthings.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
CHAR_UUID_RADON_LONG_TERM_AVG = UUID('b42e0a4c-ade7-11e4-89d3-123b93f75cba')
2626
CHAR_UUID_ILLUMINANCE_ACCELEROMETER = UUID('b42e1348-ade7-11e4-89d3-123b93f75cba')
2727
CHAR_UUID_WAVE_PLUS_DATA = UUID('b42e2a68-ade7-11e4-89d3-123b93f75cba')
28+
CHAR_UUID_WAVE_2_DATA = UUID('b42e4dcc-ade7-11e4-89d3-123b93f75cba')
2829

2930
Characteristic = namedtuple('Characteristic', ['uuid', 'name', 'format'])
3031

@@ -48,7 +49,7 @@ def __str__(self):
4849

4950
sensors_characteristics_uuid = [CHAR_UUID_DATETIME, CHAR_UUID_TEMPERATURE, CHAR_UUID_HUMIDITY, CHAR_UUID_RADON_1DAYAVG,
5051
CHAR_UUID_RADON_LONG_TERM_AVG, CHAR_UUID_ILLUMINANCE_ACCELEROMETER,
51-
CHAR_UUID_WAVE_PLUS_DATA]
52+
CHAR_UUID_WAVE_PLUS_DATA,CHAR_UUID_WAVE_2_DATA]
5253

5354
sensors_characteristics_uuid_str = [str(x) for x in sensors_characteristics_uuid]
5455

@@ -86,6 +87,21 @@ def decode_data(self, raw_data):
8687
return data
8788

8889

90+
class Wave2Decode(BaseDecode):
91+
def decode_data(self, raw_data):
92+
val = super().decode_data(raw_data)
93+
val = val[self.name]
94+
# if val[0] != 1:
95+
# raise ValueError("Incompatible current values version (Expected 1, got {})".format(data[0]))
96+
data = {}
97+
data['date_time'] = str(datetime.isoformat(datetime.now()))
98+
data['humidity'] = val[1]/2.0
99+
data['radon_1day_avg'] = val[4] if 0 <= val[4] <= 16383 else None
100+
data['radon_longterm_avg'] = val[5] if 0 <= val[5] <= 16383 else None
101+
data['temperature'] = val[6]/100.0
102+
return data
103+
104+
89105
class WaveDecodeDate(BaseDecode):
90106
def decode_data(self, raw_data):
91107
val = super().decode_data(raw_data)[self.name]
@@ -108,7 +124,8 @@ def decode_data(self, raw_data):
108124
str(CHAR_UUID_RADON_1DAYAVG):BaseDecode(name="radon_1day_avg", format_type='H', scale=1.0),
109125
str(CHAR_UUID_RADON_LONG_TERM_AVG):BaseDecode(name="radon_longterm_avg", format_type='H', scale=1.0),
110126
str(CHAR_UUID_ILLUMINANCE_ACCELEROMETER):WaveDecodeIluminAccel(name="illuminance_accelerometer", format_type='BB', scale=1.0),
111-
str(CHAR_UUID_TEMPERATURE):BaseDecode(name="temperature", format_type='h', scale=1.0/100.0),}
127+
str(CHAR_UUID_TEMPERATURE):BaseDecode(name="temperature", format_type='h', scale=1.0/100.0),
128+
str(CHAR_UUID_WAVE_2_DATA):Wave2Decode(name="Wave2", format_type='<4B8H', scale=1.0),}
112129

113130

114131
class AirthingsWaveDetect:

0 commit comments

Comments
 (0)