Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion custom_components/myhome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions custom_components/myhome/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
CONF_NAME,
CONF_MAC,
CONF_ENTITIES,
ENTITY_CATEGORY_CONFIG,
EntityCategory as Const_EntityCategory,
)

from .const import (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions custom_components/myhome/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions custom_components/myhome/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down