diff --git a/custom_components/myhome/__init__.py b/custom_components/myhome/__init__.py index 0c0f03f..935c54d 100644 --- a/custom_components/myhome/__init__.py +++ b/custom_components/myhome/__init__.py @@ -44,8 +44,11 @@ async def async_setup(hass, config): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): if entry.data[CONF_MAC] not in hass.data[DOMAIN]: hass.data[DOMAIN][entry.data[CONF_MAC]] = {} + + system_config_dir = hass.config.config_dir + default_config_path = f"{system_config_dir}/myhome.yaml" - _config_file_path = str(entry.options[CONF_FILE_PATH]) if CONF_FILE_PATH in entry.options else "/config/myhome.yaml" + _config_file_path = str(entry.options[CONF_FILE_PATH]) if CONF_FILE_PATH in entry.options else default_config_path _generate_events = entry.options[CONF_GENERATE_EVENTS] if CONF_GENERATE_EVENTS in entry.options else False try: diff --git a/custom_components/myhome/button.py b/custom_components/myhome/button.py index bcb91bb..f04573c 100644 --- a/custom_components/myhome/button.py +++ b/custom_components/myhome/button.py @@ -20,7 +20,7 @@ CONF_NAME, CONF_MAC, CONF_ENTITIES, - ENTITY_CATEGORY_CONFIG, + EntityCategory as Const_EntityCategory, ) from .const import ( @@ -114,7 +114,7 @@ def __init__( self._attr_has_entity_name = True self._attr_icon = "mdi:lock-alert" - self._attr_entity_category = EntityCategory(ENTITY_CATEGORY_CONFIG) + self._attr_entity_category = EntityCategory(Const_EntityCategory.CONFIG) self._attr_unique_id = f"{gateway.mac}-{self._device_id}-disable" self._interface = interface @@ -170,7 +170,7 @@ def __init__( self._attr_has_entity_name = True self._attr_icon = "mdi:lock-open-variant-outline" - self._attr_entity_category = EntityCategory(ENTITY_CATEGORY_CONFIG) + self._attr_entity_category = EntityCategory(Const_EntityCategory.CONFIG) self._attr_unique_id = f"{gateway.mac}-{self._device_id}-enable" self._interface = interface diff --git a/custom_components/myhome/gateway.py b/custom_components/myhome/gateway.py index 821a20d..89bcd1d 100644 --- a/custom_components/myhome/gateway.py +++ b/custom_components/myhome/gateway.py @@ -377,12 +377,9 @@ async def sending_loop(self, worker_id: int): while not self._terminate_sender: task = await self.send_buffer.get() + msg = task['message'] LOGGER.debug( - "%s Message `%s` was successfully unqueued by worker %s.", - self.name, - self.gateway.host, - task["message"], - worker_id, + f"{self.name} {self.gateway.host} Message `{msg}` was successfully unqueued by worker {worker_id}." ) await _command_session.send(message=task["message"], is_status_request=task["is_status_request"]) self.send_buffer.task_done() diff --git a/custom_components/myhome/sensor.py b/custom_components/myhome/sensor.py index 3dc4539..c98835c 100644 --- a/custom_components/myhome/sensor.py +++ b/custom_components/myhome/sensor.py @@ -18,10 +18,10 @@ CONF_ENTITIES, CONF_NAME, CONF_MAC, - ENERGY_WATT_HOUR, + UnitOfEnergy, + UnitOfPower, LIGHT_LUX, - POWER_WATT, - TEMP_CELSIUS, + UnitOfTemperature ) from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_registry as er @@ -208,7 +208,7 @@ def __init__( self._attr_device_class = device_class self._attr_unique_id = f"{gateway.mac}-{self._device_id}-{self._attr_device_class}" - self._attr_native_unit_of_measurement = POWER_WATT + self._attr_native_unit_of_measurement = UnitOfPower.WATT self._attr_state_class = SensorStateClass.MEASUREMENT self._attr_native_value = None @@ -289,7 +289,7 @@ def __init__( self._attr_unique_id = f"{gateway.mac}-{self._device_id}-{self._entity_specific_id}" self._attr_device_class = device_class - self._attr_native_unit_of_measurement = ENERGY_WATT_HOUR + self._attr_native_unit_of_measurement = UnitOfEnergy.WATT_HOUR self._attr_state_class = SensorStateClass.TOTAL_INCREASING self._attr_should_poll = True self._attr_native_value = None @@ -380,7 +380,7 @@ def __init__( self._attr_device_class = device_class self._attr_unique_id = f"{gateway.mac}-{self._device_id}-{self._attr_device_class}" - self._attr_native_unit_of_measurement = TEMP_CELSIUS + self._attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS self._attr_state_class = SensorStateClass.MEASUREMENT self._attr_should_poll = True self._attr_native_value = None