mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Use TargetKey in water_heater (#193999)
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
"""Provides device automations for Water Heater."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
import probatio
|
||||
|
||||
from homeassistant.components.device_automation import async_validate_entity_schema
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
CONF_DEVICE_ID,
|
||||
CONF_DOMAIN,
|
||||
CONF_ENTITY_ID,
|
||||
CONF_TYPE,
|
||||
TargetKey,
|
||||
)
|
||||
from homeassistant.core import Context, HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||
@@ -63,7 +65,7 @@ async def async_call_action_from_config(
|
||||
context: Context | None,
|
||||
) -> None:
|
||||
"""Execute a device action."""
|
||||
service_data = {ATTR_ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
service_data: dict[str, Any] = {TargetKey.ENTITY_ID: config[CONF_ENTITY_ID]}
|
||||
|
||||
if config[CONF_TYPE] == "turn_on":
|
||||
service = WaterHeaterService.TURN_ON
|
||||
|
||||
@@ -5,7 +5,7 @@ from collections.abc import Iterable
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, TargetKey
|
||||
from homeassistant.core import Context, HomeAssistant, State
|
||||
|
||||
from . import (
|
||||
@@ -65,7 +65,7 @@ async def _async_reproduce_state(
|
||||
):
|
||||
return
|
||||
|
||||
service_data = {ATTR_ENTITY_ID: state.entity_id}
|
||||
service_data: dict[str, Any] = {TargetKey.ENTITY_ID: state.entity_id}
|
||||
|
||||
if state.state != cur_state.state:
|
||||
if state.state == STATE_ON:
|
||||
@@ -90,7 +90,7 @@ async def _async_reproduce_state(
|
||||
DOMAIN,
|
||||
WaterHeaterService.SET_TEMPERATURE,
|
||||
{
|
||||
ATTR_ENTITY_ID: state.entity_id,
|
||||
TargetKey.ENTITY_ID: state.entity_id,
|
||||
WaterHeaterServiceArgument.TEMPERATURE: state.attributes.get(
|
||||
WaterHeaterStateAttribute.TARGET_TEMPERATURE
|
||||
),
|
||||
@@ -108,7 +108,7 @@ async def _async_reproduce_state(
|
||||
DOMAIN,
|
||||
WaterHeaterService.SET_AWAY_MODE,
|
||||
{
|
||||
ATTR_ENTITY_ID: state.entity_id,
|
||||
TargetKey.ENTITY_ID: state.entity_id,
|
||||
WaterHeaterServiceArgument.AWAY_MODE: state.attributes.get(
|
||||
WaterHeaterStateAttribute.AWAY_MODE
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user