diff --git a/custom_components/ledfx/core/device.py b/custom_components/ledfx/core/device.py index 1638b25..c23da06 100644 --- a/custom_components/ledfx/core/device.py +++ b/custom_components/ledfx/core/device.py @@ -97,19 +97,20 @@ def entities(self) -> dict: @property def md5(self) -> str: - return hashlib.md5( - json.dumps({ - "id": self._id, - "name": self._name, - "version": self._version, - "model": self._model, - "effects": dict(self._effects) if self._effects is not None else None, - "is_available": self._is_available, - "entities_data": self._entities_data, - "effect_properties": self._effect_properties, - "last_effect": dict(self._last_effect) if self._last_effect is not None else None - }).encode('utf-8') - ).hexdigest() + return hashlib.md5(self.to_json()).hexdigest() + + def to_json(self) -> bytes: + return json.dumps({ + "id": self._id, + "name": self._name, + "version": self._version, + "model": self._model, + "effects": dict(self._effects) if self._effects is not None else None, + "is_available": self._is_available, + "entities_data": self._entities_data, + "effect_properties": self._effect_properties, + "last_effect": dict(self._last_effect) if self._last_effect is not None else None + }).encode('utf-8') async def async_update_available(self, is_available: bool) -> None: self._is_available = is_available @@ -130,9 +131,9 @@ async def async_append_entity(self, entity: Entity, options: dict = {}) -> None: self._entities[entity.id] = entity if entity.id in self._entities_data and "support_effects" in options: - options["support_effects"] = list(set( + options["support_effects"] = sorted(list(set( self._entities_data[entity.id]["support_effects"] + options["support_effects"] - )) + ))) self._entities_data[entity.id] = options diff --git a/custom_components/ledfx/manifest.json b/custom_components/ledfx/manifest.json index dbb8ddc..8b908f7 100644 --- a/custom_components/ledfx/manifest.json +++ b/custom_components/ledfx/manifest.json @@ -1,7 +1,7 @@ { "domain": "ledfx", "name": "LedFx", - "version": "1.3.0", + "version": "1.3.1", "documentation": "https://github.com/dmamontov/hass-ledfx", "issue_tracker": "https://github.com/dmamontov/hass-ledfx/issues", "config_flow": true,