Skip to content

Commit 772eba0

Browse files
committed
feat: adds support for reporting unknown devices.
- adds the ThreeSixty2 to the correct type - looks for supported types from know values - adds issue template and HA issue reporting
1 parent b7b5473 commit 772eba0

File tree

5 files changed

+132
-13
lines changed

5 files changed

+132
-13
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: Device Not Supported
3+
about: This is to submit details of a device not being supported.
4+
title: ''
5+
labels: User Reported
6+
assignees: ''
7+
body:
8+
- id: device_name
9+
type: textarea
10+
attributes:
11+
label: The device name from Duux
12+
- id: device_type_id
13+
type: textarea
14+
attributes:
15+
label: The device type ID
16+
- id: sensor_type_id
17+
type: textarea
18+
attributes:
19+
label: The sensor type ID
20+
- id: reported_type
21+
type: textarea
22+
attributes:
23+
label: The device type Duux reports to Google
24+
---
25+
26+
<!-- Please aim to complete all sections -->
27+
28+
**Describe the device**
29+
30+
<!-- A clear and concise description of what the device is. A URL to the product page and manual would be helpful -->
31+
32+
**Screenshots**
33+
34+
<!-- Screenshots of the device as shown in the Duux app -->
35+
36+
**Supported Commands**
37+
38+
<!-- Please paste the output from following this guide: https://github.com/SSmale/Duux-Home-Assistant/wiki/Getting-the-sensor-data-from-Home-Assistant -->
39+
40+
```
41+
{}
42+
```
43+
44+
**Additional context**
45+
46+
<!-- Add any other context about the problem here. -->
47+
48+
**Are you willing to help test?**
49+
50+
<!-- Getting the device setup properly requires some testing, are you up for helping? -->

custom_components/duux/__init__.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
from homeassistant.const import Platform
88
from homeassistant.core import HomeAssistant
99
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
10+
from homeassistant.helpers import issue_registry as ir
11+
1012

1113
from .const import (
1214
DOMAIN,
1315
DUUX_DTID_HEATER,
1416
DUUX_DTID_THERMOSTAT,
1517
DUUX_DTID_HUMIDIFIER,
1618
DUUX_DTID_OTHER_HEATER,
19+
DUUX_SUPPORTED_TYPES,
1720
)
1821
from .duux_api import DuuxAPI
1922

@@ -48,22 +51,55 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
4851
for device in devices:
4952
sensor_type_id = device.get("sensorTypeId")
5053
device_type_id = device.get("sensorType").get("type")
54+
google_type = device.get("sensorType").get("googleDeviceType")
55+
last_word = google_type.split(".")[-1] # "HEATER" OR ""THERMOSTAT"
56+
device_name = device.get("displayName") or device.get("name")
57+
model = device.get("sensorType", {}).get("name", "Unknown")
58+
5159
if device_type_id not in [
5260
*DUUX_DTID_HEATER,
5361
*DUUX_DTID_THERMOSTAT,
5462
*DUUX_DTID_HUMIDIFIER,
5563
*DUUX_DTID_OTHER_HEATER,
5664
]:
65+
ir.async_create_issue(
66+
hass,
67+
DOMAIN,
68+
"device_not_recognised",
69+
is_fixable=False,
70+
severity=ir.IssueSeverity.WARNING,
71+
translation_key="device_not_recognised",
72+
learn_more_url=f"https://github.com/SSmale/Duux-Home-Assistant/issues/new?template=device_not_recognised.md&title=Device+not+recognised+-+{model}&device_name={model}&device_type_id={device_type_id}&sensor_type_id={sensor_type_id}&reported_type={google_type}",
73+
translation_placeholders={
74+
"device_name": model,
75+
"device_type_id": device_type_id,
76+
"sensor_type_id": sensor_type_id,
77+
"reported_type": google_type,
78+
},
79+
)
80+
_LOGGER.warning("Your device has not been recognised.")
81+
_LOGGER.warning(
82+
f"It is classified as type {last_word}, so maybe loaded as such.",
83+
)
84+
_LOGGER.warning(
85+
"Please report this to the integration developer so they can update the supported device list.",
86+
)
5787
_LOGGER.warning(
58-
f"Unknown device type {device_type_id}:{sensor_type_id}, skipping.."
88+
f"Required details: Device Name: {model}, Device Type ID: {device_type_id}, Sensor Type ID: {sensor_type_id}, Google Device Type: {google_type}",
5989
)
60-
continue
90+
if last_word in DUUX_SUPPORTED_TYPES:
91+
_LOGGER.warning(
92+
f"Attempting to load device as type {last_word}.",
93+
)
94+
95+
else:
96+
continue
6197

6298
coordinator = DuuxDataUpdateCoordinator(
6399
hass,
64100
api=api,
65101
device_id=device.get("deviceId"),
66-
device_name=device.get("displayName") or device.get("name"),
102+
device_name=device_name,
67103
)
68104

69105
await coordinator.async_config_entry_first_refresh()

custom_components/duux/climate.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from homeassistant.helpers.update_coordinator import CoordinatorEntity
1919

2020
from .const import (
21+
DUUX_CLIMATE_TYPES,
2122
DUUX_DTID_THERMOSTAT,
2223
DUUX_DTID_HEATER,
2324
DOMAIN,
@@ -44,12 +45,32 @@ async def async_setup_entry(
4445
entities = []
4546
for device in devices:
4647
device_type_id = device.get("sensorType").get("type")
47-
if device_type_id not in [*DUUX_DTID_HEATER, *DUUX_DTID_THERMOSTAT]:
48-
continue
49-
48+
google_type = device.get("sensorType").get("googleDeviceType")
49+
last_word = google_type.split(".")[-1] # "HEATER" OR ""THERMOSTAT"
5050
sensor_type_id = device.get("sensorTypeId")
5151
device_id = device["deviceId"]
5252
coordinator = coordinators[device_id]
53+
54+
model = device.get("sensorType", {}).get("name", "Unknown")
55+
56+
if device_type_id not in [*DUUX_DTID_HEATER, *DUUX_DTID_THERMOSTAT]:
57+
if last_word in DUUX_CLIMATE_TYPES:
58+
_LOGGER.warning(
59+
"Your device has not been officially catagorised as supporting the climate platform."
60+
)
61+
_LOGGER.warning(
62+
f"It is classified as type {last_word}, so attempting to set up as a climate device.",
63+
)
64+
_LOGGER.warning(
65+
"Please report this to the integration developer so they can update the supported device list.",
66+
)
67+
_LOGGER.warning(
68+
f"Required details: Device Name: {model}, Device Type ID: {device_type_id}, Sensor Type ID: {sensor_type_id}, Google Device Type: {google_type}",
69+
)
70+
71+
else:
72+
continue
73+
5374
# Create the appropriate climate entity based on heater type
5475
if sensor_type_id == DUUX_STID_THREESIXTY_2023:
5576
entities.append(DuuxThreesixtyClimate(coordinator, api, device))
@@ -68,6 +89,7 @@ async def async_setup_entry(
6889

6990
async_add_entities(entities)
7091

92+
7193
class DuuxClimate(CoordinatorEntity, ClimateEntity):
7294
"""Representation of a Duux climate device."""
7395

@@ -95,7 +117,7 @@ def __init__(self, coordinator, api, device):
95117
| ClimateEntityFeature.TURN_OFF
96118
| ClimateEntityFeature.TURN_ON
97119
)
98-
120+
99121
@property
100122
def device_info(self):
101123
"""Return device information."""
@@ -105,7 +127,7 @@ def device_info(self):
105127
"manufacturer": self._device.get("manufacturer", "Duux"),
106128
"model": self._device.get("sensorType", {}).get("name", "Unknown"),
107129
}
108-
130+
109131
@property
110132
def current_temperature(self):
111133
"""Return the current temperature."""
@@ -121,7 +143,7 @@ def hvac_mode(self):
121143
"""Return current operation."""
122144
power = self.coordinator.data.get("power", 0)
123145
return HVACMode.HEAT if power == 1 else HVACMode.OFF
124-
146+
125147
@property
126148
def preset_mode(self):
127149
"""Return current preset mode."""
@@ -133,7 +155,7 @@ def preset_modes(self):
133155
"""Return available preset modes."""
134156
# Base implementation - override in subclasses
135157
return []
136-
158+
137159
async def async_set_temperature(self, **kwargs):
138160
"""Set new target temperature."""
139161
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:

custom_components/duux/const.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
DUUX_STID_BORA_2024 = 62
2020

2121
# Device Type IDs
22-
2322
DUUX_DTID_THERMOSTAT = [50, 52]
24-
DUUX_DTID_HEATER = [51]
23+
DUUX_DTID_HEATER = [51, 21]
2524
DUUX_DTID_HUMIDIFIER = [56]
2625

27-
DUUX_DTID_OTHER_HEATER = [21, 23]
26+
DUUX_DTID_OTHER_HEATER = [23]
27+
28+
DUUX_CLIMATE_TYPES = ["THERMOSTAT", "HEATER"]
29+
DUUX_HUMIDIFIER_TYPES = ["HUMIDIFIER"]
2830

31+
DUUX_SUPPORTED_TYPES = DUUX_CLIMATE_TYPES + DUUX_HUMIDIFIER_TYPES
2932

3033
# {
3134
# "data": [
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"issues": {
3+
"device_not_recognised": {
4+
"description": "Duux has detected a device that is not officially supported. \n\rPlease check the device type and report it to the integration developer. \n\rDetails needed are: \n\rDevice Name: {device_name}\n\rDevice Type ID: {device_type_id}\n\rSensor Type ID: {sensor_type_id}\n\rDevice Type: {reported_type}.",
5+
"title": "Device not recognised"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)