Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions homeassistant/components/mqtt/vacuum/schema_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@
SUPPORT_STOP,
StateVacuumDevice,
)
from homeassistant.const import (
ATTR_SUPPORTED_FEATURES,
CONF_DEVICE,
CONF_NAME,
CONF_VALUE_TEMPLATE,
)
from homeassistant.const import ATTR_SUPPORTED_FEATURES, CONF_DEVICE, CONF_NAME
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv

Expand Down Expand Up @@ -103,7 +98,6 @@
CONF_PAYLOAD_LOCATE = "payload_locate"
CONF_PAYLOAD_START = "payload_start"
CONF_PAYLOAD_PAUSE = "payload_pause"
CONF_STATE_TEMPLATE = "state_template"
CONF_SET_FAN_SPEED_TOPIC = "set_fan_speed_topic"
CONF_FAN_SPEED_LIST = "fan_speed_list"
CONF_SEND_COMMAND_TOPIC = "send_command_topic"
Expand Down Expand Up @@ -140,7 +134,6 @@
vol.Optional(CONF_PAYLOAD_STOP, default=DEFAULT_PAYLOAD_STOP): cv.string,
vol.Optional(CONF_SEND_COMMAND_TOPIC): mqtt.valid_publish_topic,
vol.Optional(CONF_SET_FAN_SPEED_TOPIC): mqtt.valid_publish_topic,
vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
vol.Optional(CONF_STATE_TOPIC): mqtt.valid_publish_topic,
vol.Optional(
CONF_SUPPORTED_FEATURES, default=DEFAULT_SERVICE_STRINGS
Expand Down Expand Up @@ -240,19 +233,12 @@ async def async_will_remove_from_hass(self):

async def _subscribe_topics(self):
"""(Re)Subscribe to topics."""
template = self._config.get(CONF_VALUE_TEMPLATE)
if template is not None:
template.hass = self.hass
topics = {}

@callback
def state_message_received(msg):
"""Handle state MQTT message."""
payload = msg.payload
if template is not None:
payload = template.async_render_with_possible_json_value(payload)
else:
payload = json.loads(payload)
payload = json.loads(msg.payload)
if STATE in payload and payload[STATE] in POSSIBLE_STATES:
self._state = POSSIBLE_STATES[payload[STATE]]
del payload[STATE]
Expand Down