Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for water leak detector #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/tydom/MessageHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@

deviceSmokeKeywords = ['techSmokeDefect']

deviceWaterKeywords = ['techWaterDefect']

# Device dict for parsing
device_name = dict()
device_endpoint = dict()
Expand Down Expand Up @@ -405,6 +407,11 @@ async def parse_config_data(parsed):
device_type[device_unique_id] = 'boiler'
device_endpoint[device_unique_id] = i["id_endpoint"]

if i["last_usage"] == 'sensorDF':
device_name[device_unique_id] = i["name"]
device_type[device_unique_id] = 'water'
device_endpoint[device_unique_id] = i["id_endpoint"]

if i["last_usage"] == 'sensorDFR':
device_name[device_unique_id] = i["name"]
device_type[device_unique_id] = 'smoke'
Expand Down Expand Up @@ -491,6 +498,7 @@ async def parse_endpoint_data(self, endpoint, device_id):
attr_gate = {}
attr_boiler = {}
attr_sh_hvac = {}
attr_water = {}
attr_smoke = {}
endpoint_id = endpoint["id"]
unique_id = str(endpoint_id) + "_" + str(device_id)
Expand Down Expand Up @@ -626,6 +634,18 @@ async def parse_endpoint_data(self, endpoint, device_id):
attr_sh_hvac['device_type'] = 'sh_hvac'
attr_sh_hvac[element_name] = element_value

if type_of_id == 'water':
if element_name in deviceWaterKeywords and element_validity == 'upToDate':
attr_water['device_id'] = device_id
attr_water['device_class'] = 'moisture'
attr_water['endpoint_id'] = endpoint_id
attr_water['id'] = str(
device_id) + '_' + str(endpoint_id)
attr_water['name'] = print_id
attr_water['device_type'] = 'sensor'
attr_water['element_name'] = element_name
attr_water[element_name] = element_value

if type_of_id == 'smoke':
if element_name in deviceSmokeKeywords and element_validity == 'upToDate':
attr_smoke['device_id'] = device_id
Expand Down Expand Up @@ -713,6 +733,12 @@ async def parse_endpoint_data(self, endpoint, device_id):
tydom_attributes=attr_gate,
mqtt=self.mqtt_client)
await new_gate.update()
elif 'device_type' in attr_water and attr_water['device_type'] == 'sensor':
new_water = Sensor(
elem_name=attr_water['element_name'],
tydom_attributes_payload=attr_water,
mqtt=self.mqtt_client)
await new_water.update()
elif 'device_type' in attr_smoke and attr_smoke['device_type'] == 'sensor':
new_smoke = Sensor(
elem_name=attr_smoke['element_name'],
Expand Down