core/homeassistant/components/renson/entity.py

49 lines
1.5 KiB
Python
Raw Normal View History

Renson integration (#56374) * Implemented Renson integration * - renamed component to a better name - Made cleaner code by splitting up files into different one - Fixed issues regarding getting data from library - Added service.yaml file * Added Renson services * cleanup translations * added config_flow tests * changed config_flow, removed all services * use SensorEntityDescription + introduced new binarySensor * fixed config_flow test * renamed renson_endura_delta to renson * refactored sensors and implemented binary_sensor * Changed some sensors to non measurement and added entity_registery_enabled_default for config sensors * Enabled binary_sensor * changed import to new renamed module * Merge files into correct files + cleaned some code * Change use of EntityDescription * Update codeowners * Fixed lint issues * Fix sensor * Create test.yml * Update test.yml * add github action tests * Format json files * Remove deprecated code * Update homeassistant/components/renson/binary_sensor.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Use Coordinqte in Sensor * Migrated binary sensor to use coordinate * Removed firmwareSensor * Add entity_catogory to binary_sensor * Add services * Revert "Add services" This reverts commit 028760d8d8454ce98cf14eed0c7927d228ccd5e6. * update requirements of Renson integration * Add services and fan * Fixed some issue + fixed PR comments * Cleanup code * Go back 2 years ago to the bare minimum for PR approval * Refactored code and added a lot of device classes to the entities * Fix some bugs * Add unique Id and some device class * Show the level value for CURRENT_LEVEL_FIELD instead of the raw data * Remove FILTER_PRESET_FIELD for now * Make the _attr_unique_id unique * Changed Renson tests * Moved Renson hass data into @dataclass * Changed test + added files to .coveragerc * Add device_class=SensorDeviceClass.Duration * Fix syntax --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-10 07:21:33 +00:00
"""Entity class for Renson ventilation unit."""
Renson integration (#56374) * Implemented Renson integration * - renamed component to a better name - Made cleaner code by splitting up files into different one - Fixed issues regarding getting data from library - Added service.yaml file * Added Renson services * cleanup translations * added config_flow tests * changed config_flow, removed all services * use SensorEntityDescription + introduced new binarySensor * fixed config_flow test * renamed renson_endura_delta to renson * refactored sensors and implemented binary_sensor * Changed some sensors to non measurement and added entity_registery_enabled_default for config sensors * Enabled binary_sensor * changed import to new renamed module * Merge files into correct files + cleaned some code * Change use of EntityDescription * Update codeowners * Fixed lint issues * Fix sensor * Create test.yml * Update test.yml * add github action tests * Format json files * Remove deprecated code * Update homeassistant/components/renson/binary_sensor.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Use Coordinqte in Sensor * Migrated binary sensor to use coordinate * Removed firmwareSensor * Add entity_catogory to binary_sensor * Add services * Revert "Add services" This reverts commit 028760d8d8454ce98cf14eed0c7927d228ccd5e6. * update requirements of Renson integration * Add services and fan * Fixed some issue + fixed PR comments * Cleanup code * Go back 2 years ago to the bare minimum for PR approval * Refactored code and added a lot of device classes to the entities * Fix some bugs * Add unique Id and some device class * Show the level value for CURRENT_LEVEL_FIELD instead of the raw data * Remove FILTER_PRESET_FIELD for now * Make the _attr_unique_id unique * Changed Renson tests * Moved Renson hass data into @dataclass * Changed test + added files to .coveragerc * Add device_class=SensorDeviceClass.Duration * Fix syntax --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-10 07:21:33 +00:00
from __future__ import annotations
from renson_endura_delta.field_enum import (
DEVICE_NAME_FIELD,
FIRMWARE_VERSION_FIELD,
HARDWARE_VERSION_FIELD,
MAC_ADDRESS,
)
from renson_endura_delta.renson import RensonVentilation
from homeassistant.helpers.device_registry import DeviceInfo
Renson integration (#56374) * Implemented Renson integration * - renamed component to a better name - Made cleaner code by splitting up files into different one - Fixed issues regarding getting data from library - Added service.yaml file * Added Renson services * cleanup translations * added config_flow tests * changed config_flow, removed all services * use SensorEntityDescription + introduced new binarySensor * fixed config_flow test * renamed renson_endura_delta to renson * refactored sensors and implemented binary_sensor * Changed some sensors to non measurement and added entity_registery_enabled_default for config sensors * Enabled binary_sensor * changed import to new renamed module * Merge files into correct files + cleaned some code * Change use of EntityDescription * Update codeowners * Fixed lint issues * Fix sensor * Create test.yml * Update test.yml * add github action tests * Format json files * Remove deprecated code * Update homeassistant/components/renson/binary_sensor.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Use Coordinqte in Sensor * Migrated binary sensor to use coordinate * Removed firmwareSensor * Add entity_catogory to binary_sensor * Add services * Revert "Add services" This reverts commit 028760d8d8454ce98cf14eed0c7927d228ccd5e6. * update requirements of Renson integration * Add services and fan * Fixed some issue + fixed PR comments * Cleanup code * Go back 2 years ago to the bare minimum for PR approval * Refactored code and added a lot of device classes to the entities * Fix some bugs * Add unique Id and some device class * Show the level value for CURRENT_LEVEL_FIELD instead of the raw data * Remove FILTER_PRESET_FIELD for now * Make the _attr_unique_id unique * Changed Renson tests * Moved Renson hass data into @dataclass * Changed test + added files to .coveragerc * Add device_class=SensorDeviceClass.Duration * Fix syntax --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-10 07:21:33 +00:00
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN
from .coordinator import RensonCoordinator
Renson integration (#56374) * Implemented Renson integration * - renamed component to a better name - Made cleaner code by splitting up files into different one - Fixed issues regarding getting data from library - Added service.yaml file * Added Renson services * cleanup translations * added config_flow tests * changed config_flow, removed all services * use SensorEntityDescription + introduced new binarySensor * fixed config_flow test * renamed renson_endura_delta to renson * refactored sensors and implemented binary_sensor * Changed some sensors to non measurement and added entity_registery_enabled_default for config sensors * Enabled binary_sensor * changed import to new renamed module * Merge files into correct files + cleaned some code * Change use of EntityDescription * Update codeowners * Fixed lint issues * Fix sensor * Create test.yml * Update test.yml * add github action tests * Format json files * Remove deprecated code * Update homeassistant/components/renson/binary_sensor.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Use Coordinqte in Sensor * Migrated binary sensor to use coordinate * Removed firmwareSensor * Add entity_catogory to binary_sensor * Add services * Revert "Add services" This reverts commit 028760d8d8454ce98cf14eed0c7927d228ccd5e6. * update requirements of Renson integration * Add services and fan * Fixed some issue + fixed PR comments * Cleanup code * Go back 2 years ago to the bare minimum for PR approval * Refactored code and added a lot of device classes to the entities * Fix some bugs * Add unique Id and some device class * Show the level value for CURRENT_LEVEL_FIELD instead of the raw data * Remove FILTER_PRESET_FIELD for now * Make the _attr_unique_id unique * Changed Renson tests * Moved Renson hass data into @dataclass * Changed test + added files to .coveragerc * Add device_class=SensorDeviceClass.Duration * Fix syntax --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-10 07:21:33 +00:00
2023-06-11 00:28:32 +00:00
class RensonEntity(CoordinatorEntity[RensonCoordinator]):
Renson integration (#56374) * Implemented Renson integration * - renamed component to a better name - Made cleaner code by splitting up files into different one - Fixed issues regarding getting data from library - Added service.yaml file * Added Renson services * cleanup translations * added config_flow tests * changed config_flow, removed all services * use SensorEntityDescription + introduced new binarySensor * fixed config_flow test * renamed renson_endura_delta to renson * refactored sensors and implemented binary_sensor * Changed some sensors to non measurement and added entity_registery_enabled_default for config sensors * Enabled binary_sensor * changed import to new renamed module * Merge files into correct files + cleaned some code * Change use of EntityDescription * Update codeowners * Fixed lint issues * Fix sensor * Create test.yml * Update test.yml * add github action tests * Format json files * Remove deprecated code * Update homeassistant/components/renson/binary_sensor.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Use Coordinqte in Sensor * Migrated binary sensor to use coordinate * Removed firmwareSensor * Add entity_catogory to binary_sensor * Add services * Revert "Add services" This reverts commit 028760d8d8454ce98cf14eed0c7927d228ccd5e6. * update requirements of Renson integration * Add services and fan * Fixed some issue + fixed PR comments * Cleanup code * Go back 2 years ago to the bare minimum for PR approval * Refactored code and added a lot of device classes to the entities * Fix some bugs * Add unique Id and some device class * Show the level value for CURRENT_LEVEL_FIELD instead of the raw data * Remove FILTER_PRESET_FIELD for now * Make the _attr_unique_id unique * Changed Renson tests * Moved Renson hass data into @dataclass * Changed test + added files to .coveragerc * Add device_class=SensorDeviceClass.Duration * Fix syntax --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-10 07:21:33 +00:00
"""Renson entity."""
def __init__(
self, name: str, api: RensonVentilation, coordinator: RensonCoordinator
) -> None:
"""Initialize the Renson entity."""
super().__init__(coordinator)
self._attr_device_info = DeviceInfo(
identifiers={
(DOMAIN, api.get_field_value(coordinator.data, MAC_ADDRESS.name))
},
manufacturer="Renson",
model=api.get_field_value(coordinator.data, DEVICE_NAME_FIELD.name),
name="Ventilation",
sw_version=api.get_field_value(
coordinator.data, FIRMWARE_VERSION_FIELD.name
),
hw_version=api.get_field_value(
coordinator.data, HARDWARE_VERSION_FIELD.name
),
)
self.api = api
self._attr_unique_id = (
api.get_field_value(coordinator.data, MAC_ADDRESS.name) + f"{name}"
)