2019-04-03 15:40:03 +00:00
|
|
|
"""Support for Template fans."""
|
2018-05-02 21:45:31 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import voluptuous as vol
|
|
|
|
|
|
|
|
import homeassistant.helpers.config_validation as cv
|
2018-05-14 20:37:49 +00:00
|
|
|
from homeassistant.components.fan import (
|
2019-07-31 19:25:30 +00:00
|
|
|
SPEED_LOW,
|
|
|
|
SPEED_MEDIUM,
|
|
|
|
SPEED_HIGH,
|
|
|
|
SUPPORT_SET_SPEED,
|
|
|
|
SUPPORT_OSCILLATE,
|
|
|
|
FanEntity,
|
|
|
|
ATTR_SPEED,
|
|
|
|
ATTR_OSCILLATING,
|
|
|
|
ENTITY_ID_FORMAT,
|
|
|
|
SUPPORT_DIRECTION,
|
|
|
|
DIRECTION_FORWARD,
|
|
|
|
DIRECTION_REVERSE,
|
|
|
|
ATTR_DIRECTION,
|
|
|
|
)
|
2018-07-30 11:44:31 +00:00
|
|
|
from homeassistant.const import (
|
2019-07-31 19:25:30 +00:00
|
|
|
CONF_FRIENDLY_NAME,
|
|
|
|
CONF_VALUE_TEMPLATE,
|
|
|
|
CONF_ENTITY_ID,
|
|
|
|
STATE_ON,
|
|
|
|
STATE_OFF,
|
|
|
|
MATCH_ALL,
|
|
|
|
EVENT_HOMEASSISTANT_START,
|
|
|
|
STATE_UNKNOWN,
|
|
|
|
)
|
2018-07-30 11:44:31 +00:00
|
|
|
from homeassistant.core import callback
|
|
|
|
from homeassistant.exceptions import TemplateError
|
2018-05-02 21:45:31 +00:00
|
|
|
from homeassistant.helpers.entity import async_generate_entity_id
|
|
|
|
from homeassistant.helpers.script import Script
|
2019-09-28 11:59:40 +00:00
|
|
|
from .const import CONF_AVAILABILITY_TEMPLATE
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
CONF_FANS = "fans"
|
|
|
|
CONF_SPEED_LIST = "speeds"
|
|
|
|
CONF_SPEED_TEMPLATE = "speed_template"
|
|
|
|
CONF_OSCILLATING_TEMPLATE = "oscillating_template"
|
|
|
|
CONF_DIRECTION_TEMPLATE = "direction_template"
|
|
|
|
CONF_ON_ACTION = "turn_on"
|
|
|
|
CONF_OFF_ACTION = "turn_off"
|
|
|
|
CONF_SET_SPEED_ACTION = "set_speed"
|
|
|
|
CONF_SET_OSCILLATING_ACTION = "set_oscillating"
|
|
|
|
CONF_SET_DIRECTION_ACTION = "set_direction"
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
_VALID_STATES = [STATE_ON, STATE_OFF]
|
|
|
|
_VALID_OSC = [True, False]
|
2018-05-14 20:37:49 +00:00
|
|
|
_VALID_DIRECTIONS = [DIRECTION_FORWARD, DIRECTION_REVERSE]
|
2018-05-02 21:45:31 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
FAN_SCHEMA = vol.Schema(
|
|
|
|
{
|
|
|
|
vol.Optional(CONF_FRIENDLY_NAME): cv.string,
|
|
|
|
vol.Required(CONF_VALUE_TEMPLATE): cv.template,
|
|
|
|
vol.Optional(CONF_SPEED_TEMPLATE): cv.template,
|
|
|
|
vol.Optional(CONF_OSCILLATING_TEMPLATE): cv.template,
|
|
|
|
vol.Optional(CONF_DIRECTION_TEMPLATE): cv.template,
|
2019-09-28 11:59:40 +00:00
|
|
|
vol.Optional(CONF_AVAILABILITY_TEMPLATE): cv.template,
|
2019-07-31 19:25:30 +00:00
|
|
|
vol.Required(CONF_ON_ACTION): cv.SCRIPT_SCHEMA,
|
|
|
|
vol.Required(CONF_OFF_ACTION): cv.SCRIPT_SCHEMA,
|
|
|
|
vol.Optional(CONF_SET_SPEED_ACTION): cv.SCRIPT_SCHEMA,
|
|
|
|
vol.Optional(CONF_SET_OSCILLATING_ACTION): cv.SCRIPT_SCHEMA,
|
|
|
|
vol.Optional(CONF_SET_DIRECTION_ACTION): cv.SCRIPT_SCHEMA,
|
|
|
|
vol.Optional(
|
|
|
|
CONF_SPEED_LIST, default=[SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
|
|
|
|
): cv.ensure_list,
|
|
|
|
vol.Optional(CONF_ENTITY_ID): cv.entity_ids,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend(
|
|
|
|
{vol.Required(CONF_FANS): cv.schema_with_slug_keys(FAN_SCHEMA)}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
2018-05-02 21:45:31 +00:00
|
|
|
"""Set up the Template Fans."""
|
|
|
|
fans = []
|
|
|
|
|
|
|
|
for device, device_config in config[CONF_FANS].items():
|
|
|
|
friendly_name = device_config.get(CONF_FRIENDLY_NAME, device)
|
|
|
|
|
|
|
|
state_template = device_config[CONF_VALUE_TEMPLATE]
|
|
|
|
speed_template = device_config.get(CONF_SPEED_TEMPLATE)
|
2019-07-31 19:25:30 +00:00
|
|
|
oscillating_template = device_config.get(CONF_OSCILLATING_TEMPLATE)
|
2018-05-14 20:37:49 +00:00
|
|
|
direction_template = device_config.get(CONF_DIRECTION_TEMPLATE)
|
2019-09-28 11:59:40 +00:00
|
|
|
availability_template = device_config.get(CONF_AVAILABILITY_TEMPLATE)
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
on_action = device_config[CONF_ON_ACTION]
|
|
|
|
off_action = device_config[CONF_OFF_ACTION]
|
|
|
|
set_speed_action = device_config.get(CONF_SET_SPEED_ACTION)
|
|
|
|
set_oscillating_action = device_config.get(CONF_SET_OSCILLATING_ACTION)
|
2018-05-14 20:37:49 +00:00
|
|
|
set_direction_action = device_config.get(CONF_SET_DIRECTION_ACTION)
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
speed_list = device_config[CONF_SPEED_LIST]
|
|
|
|
|
|
|
|
entity_ids = set()
|
|
|
|
manual_entity_ids = device_config.get(CONF_ENTITY_ID)
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
for template in (
|
|
|
|
state_template,
|
|
|
|
speed_template,
|
|
|
|
oscillating_template,
|
|
|
|
direction_template,
|
2019-09-28 11:59:40 +00:00
|
|
|
availability_template,
|
2019-07-31 19:25:30 +00:00
|
|
|
):
|
2018-05-02 21:45:31 +00:00
|
|
|
if template is None:
|
|
|
|
continue
|
|
|
|
template.hass = hass
|
|
|
|
|
|
|
|
if entity_ids == MATCH_ALL or manual_entity_ids is not None:
|
|
|
|
continue
|
|
|
|
|
|
|
|
template_entity_ids = template.extract_entities()
|
|
|
|
if template_entity_ids == MATCH_ALL:
|
|
|
|
entity_ids = MATCH_ALL
|
|
|
|
else:
|
|
|
|
entity_ids |= set(template_entity_ids)
|
|
|
|
|
|
|
|
if manual_entity_ids is not None:
|
|
|
|
entity_ids = manual_entity_ids
|
|
|
|
elif entity_ids != MATCH_ALL:
|
|
|
|
entity_ids = list(entity_ids)
|
|
|
|
|
|
|
|
fans.append(
|
|
|
|
TemplateFan(
|
2019-07-31 19:25:30 +00:00
|
|
|
hass,
|
|
|
|
device,
|
|
|
|
friendly_name,
|
|
|
|
state_template,
|
|
|
|
speed_template,
|
|
|
|
oscillating_template,
|
|
|
|
direction_template,
|
2019-09-28 11:59:40 +00:00
|
|
|
availability_template,
|
2019-07-31 19:25:30 +00:00
|
|
|
on_action,
|
|
|
|
off_action,
|
|
|
|
set_speed_action,
|
|
|
|
set_oscillating_action,
|
|
|
|
set_direction_action,
|
|
|
|
speed_list,
|
|
|
|
entity_ids,
|
2018-05-02 21:45:31 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2018-08-24 14:37:30 +00:00
|
|
|
async_add_entities(fans)
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TemplateFan(FanEntity):
|
|
|
|
"""A template fan component."""
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
hass,
|
|
|
|
device_id,
|
|
|
|
friendly_name,
|
|
|
|
state_template,
|
|
|
|
speed_template,
|
|
|
|
oscillating_template,
|
|
|
|
direction_template,
|
2019-09-28 11:59:40 +00:00
|
|
|
availability_template,
|
2019-07-31 19:25:30 +00:00
|
|
|
on_action,
|
|
|
|
off_action,
|
|
|
|
set_speed_action,
|
|
|
|
set_oscillating_action,
|
|
|
|
set_direction_action,
|
|
|
|
speed_list,
|
|
|
|
entity_ids,
|
|
|
|
):
|
2018-05-02 21:45:31 +00:00
|
|
|
"""Initialize the fan."""
|
|
|
|
self.hass = hass
|
|
|
|
self.entity_id = async_generate_entity_id(
|
2019-07-31 19:25:30 +00:00
|
|
|
ENTITY_ID_FORMAT, device_id, hass=hass
|
|
|
|
)
|
2018-05-02 21:45:31 +00:00
|
|
|
self._name = friendly_name
|
|
|
|
|
|
|
|
self._template = state_template
|
|
|
|
self._speed_template = speed_template
|
|
|
|
self._oscillating_template = oscillating_template
|
2018-05-14 20:37:49 +00:00
|
|
|
self._direction_template = direction_template
|
2019-09-28 11:59:40 +00:00
|
|
|
self._availability_template = availability_template
|
|
|
|
self._available = True
|
2018-05-02 21:45:31 +00:00
|
|
|
self._supported_features = 0
|
|
|
|
|
|
|
|
self._on_script = Script(hass, on_action)
|
|
|
|
self._off_script = Script(hass, off_action)
|
|
|
|
|
|
|
|
self._set_speed_script = None
|
|
|
|
if set_speed_action:
|
|
|
|
self._set_speed_script = Script(hass, set_speed_action)
|
|
|
|
|
|
|
|
self._set_oscillating_script = None
|
|
|
|
if set_oscillating_action:
|
|
|
|
self._set_oscillating_script = Script(hass, set_oscillating_action)
|
|
|
|
|
2018-05-14 20:37:49 +00:00
|
|
|
self._set_direction_script = None
|
|
|
|
if set_direction_action:
|
|
|
|
self._set_direction_script = Script(hass, set_direction_action)
|
|
|
|
|
2018-05-02 21:45:31 +00:00
|
|
|
self._state = STATE_OFF
|
|
|
|
self._speed = None
|
|
|
|
self._oscillating = None
|
2018-05-14 20:37:49 +00:00
|
|
|
self._direction = None
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
self._template.hass = self.hass
|
|
|
|
if self._speed_template:
|
|
|
|
self._speed_template.hass = self.hass
|
|
|
|
self._supported_features |= SUPPORT_SET_SPEED
|
|
|
|
if self._oscillating_template:
|
|
|
|
self._oscillating_template.hass = self.hass
|
|
|
|
self._supported_features |= SUPPORT_OSCILLATE
|
2018-05-14 20:37:49 +00:00
|
|
|
if self._direction_template:
|
|
|
|
self._direction_template.hass = self.hass
|
|
|
|
self._supported_features |= SUPPORT_DIRECTION
|
2019-09-28 11:59:40 +00:00
|
|
|
if self._availability_template:
|
|
|
|
self._availability_template.hass = self.hass
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
self._entities = entity_ids
|
|
|
|
# List of valid speeds
|
|
|
|
self._speed_list = speed_list
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
"""Return the display name of this fan."""
|
|
|
|
return self._name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def supported_features(self) -> int:
|
|
|
|
"""Flag supported features."""
|
|
|
|
return self._supported_features
|
|
|
|
|
|
|
|
@property
|
2018-07-30 11:44:31 +00:00
|
|
|
def speed_list(self) -> list:
|
2018-05-02 21:45:31 +00:00
|
|
|
"""Get the list of available speeds."""
|
|
|
|
return self._speed_list
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_on(self):
|
|
|
|
"""Return true if device is on."""
|
|
|
|
return self._state == STATE_ON
|
|
|
|
|
|
|
|
@property
|
|
|
|
def speed(self):
|
|
|
|
"""Return the current speed."""
|
|
|
|
return self._speed
|
|
|
|
|
|
|
|
@property
|
|
|
|
def oscillating(self):
|
|
|
|
"""Return the oscillation state."""
|
|
|
|
return self._oscillating
|
|
|
|
|
2018-05-14 20:37:49 +00:00
|
|
|
@property
|
2019-09-02 04:42:57 +00:00
|
|
|
def current_direction(self):
|
2018-05-14 20:37:49 +00:00
|
|
|
"""Return the oscillation state."""
|
|
|
|
return self._direction
|
|
|
|
|
2018-05-02 21:45:31 +00:00
|
|
|
@property
|
|
|
|
def should_poll(self):
|
|
|
|
"""Return the polling state."""
|
|
|
|
return False
|
|
|
|
|
2019-09-28 11:59:40 +00:00
|
|
|
@property
|
|
|
|
def available(self):
|
|
|
|
"""Return availability of Device."""
|
|
|
|
return self._available
|
|
|
|
|
2018-05-02 21:45:31 +00:00
|
|
|
# pylint: disable=arguments-differ
|
|
|
|
async def async_turn_on(self, speed: str = None) -> None:
|
|
|
|
"""Turn on the fan."""
|
2019-10-04 19:07:19 +00:00
|
|
|
await self._on_script.async_run({ATTR_SPEED: speed}, context=self._context)
|
2018-05-02 21:45:31 +00:00
|
|
|
self._state = STATE_ON
|
|
|
|
|
|
|
|
if speed is not None:
|
|
|
|
await self.async_set_speed(speed)
|
|
|
|
|
|
|
|
# pylint: disable=arguments-differ
|
|
|
|
async def async_turn_off(self) -> None:
|
|
|
|
"""Turn off the fan."""
|
2018-10-15 09:38:49 +00:00
|
|
|
await self._off_script.async_run(context=self._context)
|
2018-05-02 21:45:31 +00:00
|
|
|
self._state = STATE_OFF
|
|
|
|
|
|
|
|
async def async_set_speed(self, speed: str) -> None:
|
|
|
|
"""Set the speed of the fan."""
|
|
|
|
if self._set_speed_script is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
if speed in self._speed_list:
|
|
|
|
self._speed = speed
|
2018-10-15 09:38:49 +00:00
|
|
|
await self._set_speed_script.async_run(
|
2019-07-31 19:25:30 +00:00
|
|
|
{ATTR_SPEED: speed}, context=self._context
|
|
|
|
)
|
2018-05-02 21:45:31 +00:00
|
|
|
else:
|
|
|
|
_LOGGER.error(
|
2019-07-31 19:25:30 +00:00
|
|
|
"Received invalid speed: %s. Expected: %s.", speed, self._speed_list
|
|
|
|
)
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
async def async_oscillate(self, oscillating: bool) -> None:
|
|
|
|
"""Set oscillation of the fan."""
|
|
|
|
if self._set_oscillating_script is None:
|
|
|
|
return
|
|
|
|
|
2018-05-14 20:37:49 +00:00
|
|
|
if oscillating in _VALID_OSC:
|
|
|
|
self._oscillating = oscillating
|
|
|
|
await self._set_oscillating_script.async_run(
|
2019-07-31 19:25:30 +00:00
|
|
|
{ATTR_OSCILLATING: oscillating}, context=self._context
|
|
|
|
)
|
2018-05-14 20:37:49 +00:00
|
|
|
else:
|
|
|
|
_LOGGER.error(
|
2019-07-31 19:25:30 +00:00
|
|
|
"Received invalid oscillating value: %s. Expected: %s.",
|
|
|
|
oscillating,
|
|
|
|
", ".join(_VALID_OSC),
|
|
|
|
)
|
2018-05-14 20:37:49 +00:00
|
|
|
|
|
|
|
async def async_set_direction(self, direction: str) -> None:
|
|
|
|
"""Set the direction of the fan."""
|
|
|
|
if self._set_direction_script is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
if direction in _VALID_DIRECTIONS:
|
|
|
|
self._direction = direction
|
|
|
|
await self._set_direction_script.async_run(
|
2019-07-31 19:25:30 +00:00
|
|
|
{ATTR_DIRECTION: direction}, context=self._context
|
|
|
|
)
|
2018-05-14 20:37:49 +00:00
|
|
|
else:
|
|
|
|
_LOGGER.error(
|
2019-07-31 19:25:30 +00:00
|
|
|
"Received invalid direction: %s. Expected: %s.",
|
|
|
|
direction,
|
|
|
|
", ".join(_VALID_DIRECTIONS),
|
|
|
|
)
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
async def async_added_to_hass(self):
|
|
|
|
"""Register callbacks."""
|
2019-07-31 19:25:30 +00:00
|
|
|
|
2018-05-02 21:45:31 +00:00
|
|
|
@callback
|
|
|
|
def template_fan_state_listener(entity, old_state, new_state):
|
|
|
|
"""Handle target device state changes."""
|
|
|
|
self.async_schedule_update_ha_state(True)
|
|
|
|
|
|
|
|
@callback
|
|
|
|
def template_fan_startup(event):
|
|
|
|
"""Update template on startup."""
|
|
|
|
self.hass.helpers.event.async_track_state_change(
|
2019-07-31 19:25:30 +00:00
|
|
|
self._entities, template_fan_state_listener
|
|
|
|
)
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
self.async_schedule_update_ha_state(True)
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, template_fan_startup)
|
2018-05-02 21:45:31 +00:00
|
|
|
|
|
|
|
async def async_update(self):
|
|
|
|
"""Update the state from the template."""
|
|
|
|
# Update state
|
|
|
|
try:
|
|
|
|
state = self._template.async_render()
|
|
|
|
except TemplateError as ex:
|
|
|
|
_LOGGER.error(ex)
|
|
|
|
state = None
|
|
|
|
self._state = None
|
|
|
|
|
|
|
|
# Validate state
|
|
|
|
if state in _VALID_STATES:
|
|
|
|
self._state = state
|
|
|
|
elif state == STATE_UNKNOWN:
|
|
|
|
self._state = None
|
|
|
|
else:
|
|
|
|
_LOGGER.error(
|
2019-07-31 19:25:30 +00:00
|
|
|
"Received invalid fan is_on state: %s. Expected: %s.",
|
|
|
|
state,
|
|
|
|
", ".join(_VALID_STATES),
|
|
|
|
)
|
2018-05-02 21:45:31 +00:00
|
|
|
self._state = None
|
|
|
|
|
|
|
|
# Update speed if 'speed_template' is configured
|
|
|
|
if self._speed_template is not None:
|
|
|
|
try:
|
|
|
|
speed = self._speed_template.async_render()
|
|
|
|
except TemplateError as ex:
|
|
|
|
_LOGGER.error(ex)
|
|
|
|
speed = None
|
|
|
|
self._state = None
|
|
|
|
|
|
|
|
# Validate speed
|
|
|
|
if speed in self._speed_list:
|
|
|
|
self._speed = speed
|
|
|
|
elif speed == STATE_UNKNOWN:
|
|
|
|
self._speed = None
|
|
|
|
else:
|
|
|
|
_LOGGER.error(
|
2019-07-31 19:25:30 +00:00
|
|
|
"Received invalid speed: %s. Expected: %s.", speed, self._speed_list
|
|
|
|
)
|
2018-05-02 21:45:31 +00:00
|
|
|
self._speed = None
|
|
|
|
|
|
|
|
# Update oscillating if 'oscillating_template' is configured
|
|
|
|
if self._oscillating_template is not None:
|
|
|
|
try:
|
|
|
|
oscillating = self._oscillating_template.async_render()
|
|
|
|
except TemplateError as ex:
|
|
|
|
_LOGGER.error(ex)
|
2018-05-14 20:37:49 +00:00
|
|
|
oscillating = None
|
2018-05-02 21:45:31 +00:00
|
|
|
self._state = None
|
|
|
|
|
|
|
|
# Validate osc
|
2019-07-31 19:25:30 +00:00
|
|
|
if oscillating == "True" or oscillating is True:
|
2018-05-02 21:45:31 +00:00
|
|
|
self._oscillating = True
|
2019-07-31 19:25:30 +00:00
|
|
|
elif oscillating == "False" or oscillating is False:
|
2018-05-02 21:45:31 +00:00
|
|
|
self._oscillating = False
|
|
|
|
elif oscillating == STATE_UNKNOWN:
|
|
|
|
self._oscillating = None
|
|
|
|
else:
|
|
|
|
_LOGGER.error(
|
2019-07-31 19:25:30 +00:00
|
|
|
"Received invalid oscillating: %s. Expected: True/False.",
|
|
|
|
oscillating,
|
|
|
|
)
|
2018-05-02 21:45:31 +00:00
|
|
|
self._oscillating = None
|
2018-05-14 20:37:49 +00:00
|
|
|
|
|
|
|
# Update direction if 'direction_template' is configured
|
|
|
|
if self._direction_template is not None:
|
|
|
|
try:
|
|
|
|
direction = self._direction_template.async_render()
|
|
|
|
except TemplateError as ex:
|
|
|
|
_LOGGER.error(ex)
|
|
|
|
direction = None
|
|
|
|
self._state = None
|
|
|
|
|
|
|
|
# Validate speed
|
|
|
|
if direction in _VALID_DIRECTIONS:
|
|
|
|
self._direction = direction
|
|
|
|
elif direction == STATE_UNKNOWN:
|
|
|
|
self._direction = None
|
|
|
|
else:
|
|
|
|
_LOGGER.error(
|
2019-07-31 19:25:30 +00:00
|
|
|
"Received invalid direction: %s. Expected: %s.",
|
|
|
|
direction,
|
|
|
|
", ".join(_VALID_DIRECTIONS),
|
|
|
|
)
|
2018-05-14 20:37:49 +00:00
|
|
|
self._direction = None
|
2019-09-28 11:59:40 +00:00
|
|
|
|
|
|
|
# Update Availability if 'availability_template' is defined
|
|
|
|
if self._availability_template is not None:
|
|
|
|
try:
|
|
|
|
self._available = (
|
|
|
|
self._availability_template.async_render().lower() == "true"
|
|
|
|
)
|
|
|
|
except (TemplateError, ValueError) as ex:
|
|
|
|
_LOGGER.error(
|
|
|
|
"Could not render %s template %s: %s",
|
|
|
|
CONF_AVAILABILITY_TEMPLATE,
|
|
|
|
self._name,
|
|
|
|
ex,
|
|
|
|
)
|