Compare commits

...

18 Commits

Author SHA1 Message Date
ted
4ecb6bf30a
Merge 02963a7f06 into e174a73f52 2025-03-24 18:07:00 +01:00
dw881114
e174a73f52
Update spec_modify.yaml (#921)
Some checks are pending
Tests / check-rule-format (push) Waiting to run
Validate / validate-hassfest (push) Waiting to run
Validate / validate-hacs (push) Waiting to run
Validate / validate-lint (push) Waiting to run
Validate / validate-setup (push) Waiting to run
2025-03-24 16:34:48 +08:00
ted
02963a7f06
Merge branch 'XiaoMi:main' into main 2025-03-16 10:46:15 +08:00
ted
ade18deb7e
Merge branch 'XiaoMi:main' into main 2025-03-13 14:47:08 +08:00
ted
4e1185f4e5
Merge branch 'XiaoMi:main' into main 2025-02-28 20:20:55 +08:00
ted
6ad8da42be
Merge branch 'XiaoMi:main' into main 2025-02-25 10:45:50 +08:00
ted
4aa6bb579f
Merge branch 'XiaoMi:main' into main 2025-02-19 14:05:50 +08:00
ted
e83aa9367e
Merge branch 'XiaoMi:main' into main 2025-01-31 15:25:58 +08:00
tedwang
04c44f36b1 Merge branch 'main' of https://github.com/zghnwsq/fork_ha_xiaomi_home into fix_vacuum_warn 2025-01-23 11:01:23 +08:00
ted
a40363d3e6
Merge branch 'XiaoMi:main' into main 2025-01-23 10:17:55 +08:00
tedwang
13e6863678 fix: Fix the HA warning in the logs related to vacuum state setting
Adapt to new vacuum state property, set the activity property instead of directly setting the state property.
2025-01-23 10:09:15 +08:00
ted
b0d0d6b107
Merge branch 'XiaoMi:main' into main 2025-01-21 16:27:32 +08:00
ted
085caff660
Merge branch 'XiaoMi:main' into main 2025-01-18 16:34:16 +08:00
ted
fe3756db9b
Merge branch 'XiaoMi:main' into main 2025-01-16 09:18:40 +08:00
ted
bf33f0c60d
Merge branch 'XiaoMi:main' into main 2025-01-13 13:58:58 +08:00
ted
72f3a5df3e
Merge branch 'XiaoMi:main' into main 2025-01-11 20:35:24 +08:00
ted
f452611b87
Merge branch 'XiaoMi:main' into main 2025-01-08 11:43:20 +08:00
tedwang
36d5a3e4de docs: fix table header misplacement
fix table header misplacement
2025-01-03 10:54:41 +08:00
3 changed files with 63 additions and 19 deletions

View File

@ -213,6 +213,12 @@ class MIoTSpecValueList:
return item.description
return None
def get_name_by_value(self, value: Any) -> Optional[str]:
for item in self.items:
if item.value == value:
return item.name
return None
def dump(self) -> list:
return [item.dump() for item in self.items]

View File

@ -85,37 +85,37 @@ urn:miot-spec-v2:device:thermostat:0000A031:suittc-wk168:1:
prop.2.3:
value-list:
- value: 1
description: one
description: '1'
- value: 2
description: two
description: '2'
- value: 3
description: three
description: '3'
- value: 4
description: four
description: '4'
- value: 5
description: five
description: '5'
- value: 6
description: six
description: '6'
- value: 7
description: seven
description: '7'
- value: 8
description: eight
description: '8'
- value: 9
description: nine
description: '9'
- value: 10
description: ten
description: '10'
- value: 11
description: eleven
description: '11'
- value: 12
description: twelve
description: '12'
- value: 13
description: thirteen
description: '13'
- value: 14
description: fourteen
description: '14'
- value: 15
description: fifteen
description: '15'
- value: 16
description: sixteen
description: '16'
urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:3:
prop.5.1:
expr: round(src_value*6/1000000, 3)

View File

@ -54,7 +54,8 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.components.vacuum import (
StateVacuumEntity,
VacuumEntityFeature
VacuumEntityFeature,
VacuumActivity
)
from .miot.const import DOMAIN
@ -191,10 +192,47 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
@property
def state(self) -> Optional[str]:
"""Return the current state of the vacuum cleaner."""
"""Return the current state of the vacuum cleaner.
To fix the HA warning below:
Detected that custom integration 'xiaomi_home' is setting state
directly.Entity XXX(<class 'custom_components.xiaomi_home.vacuum
.Vacuum'>)should implement the 'activity' property and return
its state using the VacuumActivity enum.This will stop working in
Home Assistant 2026.1.
Refer to
https://developers.home-assistant.io/blog/2024/12/08/new-vacuum-state-property
There are only 6 states in VacuumActivity enum. To be compatible with
more constants, try get matching VacuumActivity enum first, return state
string as before if there is no match. In Home Assistant 2026.1, every
state should map to a VacuumActivity enum.
"""
if (activity := self.activity) is not None:
return activity
return self.get_map_value(
map_=self._status_map,
key=self.get_prop_value(prop=self._prop_status))
key=self.get_prop_value(prop=self._prop_status)
)
@property
def activity(self) -> VacuumActivity | None:
"""Return the current vacuum activity."""
state_trans_map = {
'Sleep': VacuumActivity.IDLE,
'Idle': VacuumActivity.IDLE,
'Paused': VacuumActivity.PAUSED,
'Go Charging': VacuumActivity.RETURNING,
'Charging': VacuumActivity.DOCKED,
'Sweeping': VacuumActivity.CLEANING,
'Sweeping and Mopping': VacuumActivity.CLEANING,
'Mopping': VacuumActivity.CLEANING,
'Error': VacuumActivity.ERROR,
}
prop_value = self.get_prop_value(prop=self._prop_status)
state_name = self._prop_status.value_list.get_name_by_value(prop_value)
return state_trans_map.get(state_name)
@property
def battery_level(self) -> Optional[int]: