Skip to content

Commit

Permalink
fix: fan error / entity duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
lunDreame authored Aug 9, 2024
1 parent a55b456 commit 19f3a57
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 8 deletions.
4 changes: 3 additions & 1 deletion custom_components/kocom_smart_home/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for coordinator in coordinators:
devices = await coordinator.get_devices()
entities_to_add.extend(
KocomClimate(coordinator, device) for device in devices
KocomClimate(coordinator, device)
for device in devices
if device["device_id"] not in hass.data[DOMAIN]
)

if entities_to_add:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/kocom_smart_home/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

NAME = "Kocom Smart Home"
DOMAIN = "kocom_smart_home"
VERSION = "1.1.5"
VERSION = "1.1.7"

TIMEOUT_SEC = 10

Expand Down
2 changes: 1 addition & 1 deletion custom_components/kocom_smart_home/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def get_devices(self) -> list:
elif self.name in ["gas", "vent", "totalcontrol"]:
single_device = await self.get_single_device()
entry_device_info = {
"device_id": f"{self.name}_{single_device['data']['attr']['id'].lower()}",
"device_id": f"{single_device['data']['attr']['id'].lower()}_00",
"device_name": {"gas": "가스", "vent": "환기", "totalcontrol": "일괄소등"}[self.name],
"device_room": "00",
"device_type": single_device["data"]["attr"]["type"],
Expand Down
6 changes: 5 additions & 1 deletion custom_components/kocom_smart_home/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
devices = await coordinator.get_devices()

entities_to_add: list = [
KocomFan(coordinator, devices[0])
KocomFan(coordinator, device)
for device in devices
if device["device_id"] not in hass.data[DOMAIN]
]

if entities_to_add:
Expand Down Expand Up @@ -63,6 +65,8 @@ def supported_features(self) -> int:
def percentage(self) -> Optional[int]:
"""Return the current speed percentage."""
status = self.coordinator.get_device_status(function="wind")
if status == "0":
return 0
return ordered_list_item_to_percentage(SPEED_LIST, status)

@property
Expand Down
4 changes: 3 additions & 1 deletion custom_components/kocom_smart_home/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for coordinator in coordinators:
devices = await coordinator.get_devices()
entities_to_add.extend(
KocomLight(coordinator, device) for device in devices
KocomLight(coordinator, device)
for device in devices
if device["device_id"] not in hass.data[DOMAIN]
)

if entities_to_add:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/kocom_smart_home/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
],
"config_flow": true,
"iot_class": "cloud_polling",
"version": "1.1.5"
"version": "1.1.7"
}
4 changes: 3 additions & 1 deletion custom_components/kocom_smart_home/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for coordinator in coordinators:
devices = await coordinator.get_devices()
entities_to_add.extend(
KocomSensor(coordinator, device) for device in devices
KocomSensor(coordinator, device)
for device in devices
if device["device_id"] not in hass.data[DOMAIN]
)

if entities_to_add:
Expand Down
4 changes: 3 additions & 1 deletion custom_components/kocom_smart_home/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for coordinator in coordinators:
devices = await coordinator.get_devices()
entities_to_add.extend(
KocomSwitch(coordinator, device) for device in devices
KocomSwitch(coordinator, device)
for device in devices
if device["device_id"] not in hass.data[DOMAIN]
)

if entities_to_add:
Expand Down
10 changes: 10 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### V1.1.7
- 환기 오류 수정
- 중복 엔티티 등록 체크

### V1.1.6
- ...

### V1.1.5
- ...

### V1.1.4
- Climate 경고 로그 해결

Expand Down

0 comments on commit 19f3a57

Please sign in to comment.