Refactor Enocean part 1 (#35927)
* First step of an EnOcean integration refactoring, including code reorganisation and support of a setup config flow * Moved title to root of strings file * Fixed pre-commit checks failures * Fixed linter errors * Updated formatted string format in logs * Removed leftover comment * Multiple changes after PR change requests. Using an import flow for yaml config, removed unnecessary logs, added proper unload in __init__ and EnOceanDongle Replaced config state machine by several flows. Serial port validity check done in the EnOceanDongle class asynchronously, removed unique ID from config flow Multiple cosmetic changes * Multiple changes after PR change requests * Added variable to store default value, as setdefault was caught returning None when the empty dict literal was passed as an argument * Literal used directly * Added tests for EnOcean config flows, changed static methods to bundle methods for bundle * Updated variable name * Added missing mock to test, replaced repeated magic strings by constants * Changed imports to avoid an unused import warning from pylint on DOMAIN * Adding pylint exception for unused import * Added proper propagation of setup and unload to platforms, removed dead code, some syntax changes * Removed setup_entry forwarding as the entities can only be configured using yaml * Removed forwarding of unload * Enabled code coverage for config flow only * Clean up coveragerc Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
872140123d
commit
af6a4bb6cf
17 changed files with 514 additions and 82 deletions
|
@ -3,7 +3,6 @@ import logging
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import enocean
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE_CLASS,
|
||||
|
@ -21,6 +20,8 @@ from homeassistant.const import (
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from .device import EnOceanEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_MAX_TEMP = "max_temp"
|
||||
|
@ -62,7 +63,6 @@ SENSOR_TYPES = {
|
|||
},
|
||||
}
|
||||
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_ID): vol.All(cv.ensure_list, [vol.Coerce(int)]),
|
||||
|
@ -105,7 +105,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
add_entities([EnOceanWindowHandle(dev_id, dev_name)])
|
||||
|
||||
|
||||
class EnOceanSensor(enocean.EnOceanDevice, RestoreEntity):
|
||||
class EnOceanSensor(EnOceanEntity, RestoreEntity):
|
||||
"""Representation of an EnOcean sensor device such as a power meter."""
|
||||
|
||||
def __init__(self, dev_id, dev_name, sensor_type):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue