Skip to content

Commit 9b9e6a9

Browse files
Merge pull request #28 from dingusdk/wave2
Added support for ware 2nd gen.
2 parents 789d71f + ea05a50 commit 9b9e6a9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

custom_components/airthings_wave/airthings.py

Lines changed: 17 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,19 @@ 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+
data = {}
95+
data['date_time'] = str(datetime.isoformat(datetime.now()))
96+
data['humidity'] = val[1]/2.0
97+
data['radon_1day_avg'] = val[4] if 0 <= val[4] <= 16383 else None
98+
data['radon_longterm_avg'] = val[5] if 0 <= val[5] <= 16383 else None
99+
data['temperature'] = val[6]/100.0
100+
return data
101+
102+
89103
class WaveDecodeDate(BaseDecode):
90104
def decode_data(self, raw_data):
91105
val = super().decode_data(raw_data)[self.name]
@@ -108,7 +122,8 @@ def decode_data(self, raw_data):
108122
str(CHAR_UUID_RADON_1DAYAVG):BaseDecode(name="radon_1day_avg", format_type='H', scale=1.0),
109123
str(CHAR_UUID_RADON_LONG_TERM_AVG):BaseDecode(name="radon_longterm_avg", format_type='H', scale=1.0),
110124
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),}
125+
str(CHAR_UUID_TEMPERATURE):BaseDecode(name="temperature", format_type='h', scale=1.0/100.0),
126+
str(CHAR_UUID_WAVE_2_DATA):Wave2Decode(name="Wave2", format_type='<4B8H', scale=1.0),}
112127

113128

114129
class AirthingsWaveDetect:

0 commit comments

Comments
 (0)