diff --git a/homeassistant/components/number/__init__.py b/homeassistant/components/number/__init__.py index 8c1800697a3..5ab1eaa7be4 100644 --- a/homeassistant/components/number/__init__.py +++ b/homeassistant/components/number/__init__.py @@ -200,7 +200,7 @@ class NumberEntity(Entity): _attr_native_max_value: float _attr_native_min_value: float _attr_native_step: float - _attr_native_value: float + _attr_native_value: float | None = None _attr_native_unit_of_measurement: str | None _deprecated_number_entity_reported = False _number_option_unit_of_measurement: str | None = None diff --git a/homeassistant/components/template/number.py b/homeassistant/components/template/number.py index d41bdee597b..89f4d22b957 100644 --- a/homeassistant/components/template/number.py +++ b/homeassistant/components/template/number.py @@ -14,6 +14,7 @@ from homeassistant.components.number.const import ( ATTR_VALUE, DEFAULT_MAX_VALUE, DEFAULT_MIN_VALUE, + DEFAULT_STEP, DOMAIN as NUMBER_DOMAIN, ) from homeassistant.const import CONF_NAME, CONF_OPTIMISTIC, CONF_STATE, CONF_UNIQUE_ID @@ -119,10 +120,9 @@ class TemplateNumber(TemplateEntity, NumberEntity): self._min_value_template = config[ATTR_MIN] self._max_value_template = config[ATTR_MAX] self._attr_assumed_state = self._optimistic = config[CONF_OPTIMISTIC] - self._attr_native_value = None - self._attr_native_step = None - self._attr_native_min_value = None - self._attr_native_max_value = None + self._attr_native_step = DEFAULT_STEP + self._attr_native_min_value = DEFAULT_MIN_VALUE + self._attr_native_max_value = DEFAULT_MAX_VALUE async def async_added_to_hass(self) -> None: """Register callbacks.""" diff --git a/homeassistant/components/template/sensor.py b/homeassistant/components/template/sensor.py index 8dcda988e9f..b52953c1a8a 100644 --- a/homeassistant/components/template/sensor.py +++ b/homeassistant/components/template/sensor.py @@ -205,7 +205,7 @@ class SensorTemplate(TemplateSensor): ) -> None: """Initialize the sensor.""" super().__init__(hass, config=config, fallback_name=None, unique_id=unique_id) - self._template = config.get(CONF_STATE) + self._template: template.Template = config[CONF_STATE] if (object_id := config.get(CONF_OBJECT_ID)) is not None: self.entity_id = async_generate_entity_id( ENTITY_ID_FORMAT, object_id, hass=hass diff --git a/mypy.ini b/mypy.ini index b936eab1fd0..d92cca692a4 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2701,8 +2701,3 @@ ignore_errors = true [mypy-homeassistant.components.sonos.statistics] ignore_errors = true -[mypy-homeassistant.components.template.number] -ignore_errors = true - -[mypy-homeassistant.components.template.sensor] -ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index c7bdd8e6c2b..d2c11d4744d 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -31,8 +31,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.sonos.sensor", "homeassistant.components.sonos.speaker", "homeassistant.components.sonos.statistics", - "homeassistant.components.template.number", - "homeassistant.components.template.sensor", ] # Component modules which should set no_implicit_reexport = true.