Skip to content

Commit

Permalink
Fixes for version-splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsK1 committed Nov 24, 2024
1 parent f291b0b commit 92adecd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion custom_components/solvis_control/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/LarsK1/hass_solvis_control/issues",
"requirements": ["pymodbus"],
"version": "1.1.6"
"version": "1.1.7"
}
27 changes: 22 additions & 5 deletions custom_components/solvis_control/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import logging
import re


from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME, EntityCategory
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.helpers.device_registry import async_get

from .const import (
CONF_HOST,
Expand Down Expand Up @@ -161,12 +163,27 @@ def _handle_coordinator_update(self) -> None:
if len(str(response_data)) == 5:
response_data = str(response_data)
self._attr_native_value = (
f"{response_data[0]}.{response_data[1:2]}.{response_data[3:4]}"
f"{response_data[0]}.{response_data[1:3]}.{response_data[3:5]}"
)
if self._address == 32770:
self.device_info.sw_version = self._attr_native_value
elif self._address == 32771:
self.device_info.hw_version = self._attr_native_value
if self._address in (32770, 32771):
# Hole den Device-Registry
device_registry = async_get(self.hass)

# Aktualisiere Geräteinformationen
device = device_registry.async_get_device(
self.device_info.identifiers
)
if device is not None:
if self._address == 32770:
device_registry.async_update_device(
device.id,
sw_version=self._attr_native_value,
)
elif self._address == 32771:
device_registry.async_update_device(
device.id,
hw_version=self._attr_native_value,
)
else:
_LOGGER.warning("Couldn't process version string to Version.")
self._attr_native_value = response_data
Expand Down

0 comments on commit 92adecd

Please sign in to comment.