Skip to content

Commit

Permalink
Merge pull request #28 from dingusdk/wave2
Browse files Browse the repository at this point in the history
Added support for ware 2nd gen.
  • Loading branch information
MartyTremblay authored Aug 26, 2020
2 parents 789d71f + ea05a50 commit 9b9e6a9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions custom_components/airthings_wave/airthings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
CHAR_UUID_RADON_LONG_TERM_AVG = UUID('b42e0a4c-ade7-11e4-89d3-123b93f75cba')
CHAR_UUID_ILLUMINANCE_ACCELEROMETER = UUID('b42e1348-ade7-11e4-89d3-123b93f75cba')
CHAR_UUID_WAVE_PLUS_DATA = UUID('b42e2a68-ade7-11e4-89d3-123b93f75cba')
CHAR_UUID_WAVE_2_DATA = UUID('b42e4dcc-ade7-11e4-89d3-123b93f75cba')

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

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

sensors_characteristics_uuid = [CHAR_UUID_DATETIME, CHAR_UUID_TEMPERATURE, CHAR_UUID_HUMIDITY, CHAR_UUID_RADON_1DAYAVG,
CHAR_UUID_RADON_LONG_TERM_AVG, CHAR_UUID_ILLUMINANCE_ACCELEROMETER,
CHAR_UUID_WAVE_PLUS_DATA]
CHAR_UUID_WAVE_PLUS_DATA,CHAR_UUID_WAVE_2_DATA]

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

Expand Down Expand Up @@ -86,6 +87,19 @@ def decode_data(self, raw_data):
return data


class Wave2Decode(BaseDecode):
def decode_data(self, raw_data):
val = super().decode_data(raw_data)
val = val[self.name]
data = {}
data['date_time'] = str(datetime.isoformat(datetime.now()))
data['humidity'] = val[1]/2.0
data['radon_1day_avg'] = val[4] if 0 <= val[4] <= 16383 else None
data['radon_longterm_avg'] = val[5] if 0 <= val[5] <= 16383 else None
data['temperature'] = val[6]/100.0
return data


class WaveDecodeDate(BaseDecode):
def decode_data(self, raw_data):
val = super().decode_data(raw_data)[self.name]
Expand All @@ -108,7 +122,8 @@ def decode_data(self, raw_data):
str(CHAR_UUID_RADON_1DAYAVG):BaseDecode(name="radon_1day_avg", format_type='H', scale=1.0),
str(CHAR_UUID_RADON_LONG_TERM_AVG):BaseDecode(name="radon_longterm_avg", format_type='H', scale=1.0),
str(CHAR_UUID_ILLUMINANCE_ACCELEROMETER):WaveDecodeIluminAccel(name="illuminance_accelerometer", format_type='BB', scale=1.0),
str(CHAR_UUID_TEMPERATURE):BaseDecode(name="temperature", format_type='h', scale=1.0/100.0),}
str(CHAR_UUID_TEMPERATURE):BaseDecode(name="temperature", format_type='h', scale=1.0/100.0),
str(CHAR_UUID_WAVE_2_DATA):Wave2Decode(name="Wave2", format_type='<4B8H', scale=1.0),}


class AirthingsWaveDetect:
Expand Down

0 comments on commit 9b9e6a9

Please sign in to comment.