Disable extra=vol.ALLOW_EXTRA for MQTT platforms. (#20562)
This commit is contained in:
parent
48f0e8311b
commit
89fc3b2a1b
22 changed files with 67 additions and 56 deletions
|
@ -234,7 +234,7 @@ MQTT_JSON_ATTRS_SCHEMA = vol.Schema({
|
|||
vol.Optional(CONF_JSON_ATTRS_TOPIC): valid_subscribe_topic,
|
||||
})
|
||||
|
||||
MQTT_BASE_PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend(SCHEMA_BASE)
|
||||
MQTT_BASE_PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA_2.extend(SCHEMA_BASE)
|
||||
|
||||
# Sensor type platforms subscribe to MQTT events
|
||||
MQTT_RO_PLATFORM_SCHEMA = MQTT_BASE_PLATFORM_SCHEMA.extend({
|
||||
|
@ -985,6 +985,7 @@ class MqttDiscoveryUpdate(Entity):
|
|||
elif self._discovery_update:
|
||||
# Non-empty payload: Notify component
|
||||
_LOGGER.info("Updating component: %s", self.entity_id)
|
||||
payload.pop(ATTR_DISCOVERY_HASH)
|
||||
self.hass.async_create_task(self._discovery_update(payload))
|
||||
|
||||
if self._discovery_hash:
|
||||
|
|
|
@ -40,6 +40,7 @@ DEPENDENCIES = ['mqtt']
|
|||
|
||||
PLATFORM_SCHEMA = mqtt.MQTT_BASE_PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_COMMAND_TOPIC): mqtt.valid_publish_topic,
|
||||
vol.Optional(CONF_RETAIN, default=mqtt.DEFAULT_RETAIN): cv.boolean,
|
||||
vol.Required(CONF_STATE_TOPIC): mqtt.valid_subscribe_topic,
|
||||
vol.Optional(CONF_CODE): cv.string,
|
||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||
|
@ -63,7 +64,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover(discovery_payload):
|
||||
"""Discover and add an MQTT alarm control panel."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
|
|
@ -63,7 +63,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover(discovery_payload):
|
||||
"""Discover and add a MQTT binary sensor."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
|
|
@ -135,7 +135,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover(discovery_payload):
|
||||
"""Discover and add an MQTT cover."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
|
|
@ -216,8 +216,8 @@ async def async_start(hass: HomeAssistantType, discovery_topic, hass_config,
|
|||
key = ABBREVIATIONS.get(key, key)
|
||||
payload[key] = payload.pop(abbreviated_key)
|
||||
|
||||
if TOPIC_BASE in payload:
|
||||
base = payload[TOPIC_BASE]
|
||||
base = payload.pop(TOPIC_BASE, None)
|
||||
if base:
|
||||
for key, value in payload.items():
|
||||
if isinstance(value, str) and value:
|
||||
if value[0] == TOPIC_BASE and key.endswith('_topic'):
|
||||
|
|
|
@ -93,7 +93,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover(discovery_payload):
|
||||
"""Discover and add a MQTT fan."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
|
|
@ -15,10 +15,6 @@ from homeassistant.components.mqtt.discovery import (
|
|||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.typing import HomeAssistantType, ConfigType
|
||||
|
||||
from . import schema_basic
|
||||
from . import schema_json
|
||||
from . import schema_template
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['mqtt']
|
||||
|
@ -28,6 +24,10 @@ CONF_SCHEMA = 'schema'
|
|||
|
||||
def validate_mqtt_light(value):
|
||||
"""Validate MQTT light schema."""
|
||||
from . import schema_basic
|
||||
from . import schema_json
|
||||
from . import schema_template
|
||||
|
||||
schemas = {
|
||||
'basic': schema_basic.PLATFORM_SCHEMA_BASIC,
|
||||
'json': schema_json.PLATFORM_SCHEMA_JSON,
|
||||
|
@ -36,9 +36,12 @@ def validate_mqtt_light(value):
|
|||
return schemas[value[CONF_SCHEMA]](value)
|
||||
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(vol.Schema({
|
||||
MQTT_LIGHT_SCHEMA_SCHEMA = vol.Schema({
|
||||
vol.Optional(CONF_SCHEMA, default='basic'): vol.All(
|
||||
vol.Lower, vol.Any('basic', 'json', 'template'))
|
||||
})
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(MQTT_LIGHT_SCHEMA_SCHEMA.extend({
|
||||
}, extra=vol.ALLOW_EXTRA), validate_mqtt_light)
|
||||
|
||||
|
||||
|
@ -53,7 +56,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover(discovery_payload):
|
||||
"""Discover and add a MQTT light."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
@ -70,6 +73,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def _async_setup_entity(config, async_add_entities, config_entry=None,
|
||||
discovery_hash=None):
|
||||
"""Set up a MQTT Light."""
|
||||
from . import schema_basic
|
||||
from . import schema_json
|
||||
from . import schema_template
|
||||
|
||||
setup_entity = {
|
||||
'basic': schema_basic.async_setup_entity_basic,
|
||||
'json': schema_json.async_setup_entity_json,
|
||||
|
|
|
@ -26,6 +26,8 @@ from homeassistant.helpers.restore_state import RestoreEntity
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
import homeassistant.util.color as color_util
|
||||
|
||||
from . import MQTT_LIGHT_SCHEMA_SCHEMA
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DEPENDENCIES = ['mqtt']
|
||||
|
@ -108,7 +110,7 @@ PLATFORM_SCHEMA_BASIC = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({
|
|||
vol.In(VALUES_ON_COMMAND_TYPE),
|
||||
vol.Optional(CONF_DEVICE): mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA,
|
||||
}).extend(mqtt.MQTT_AVAILABILITY_SCHEMA.schema).extend(
|
||||
mqtt.MQTT_JSON_ATTRS_SCHEMA.schema)
|
||||
mqtt.MQTT_JSON_ATTRS_SCHEMA.schema).extend(MQTT_LIGHT_SCHEMA_SCHEMA.schema)
|
||||
|
||||
|
||||
async def async_setup_entity_basic(config, async_add_entities, config_entry,
|
||||
|
|
|
@ -28,6 +28,7 @@ from homeassistant.helpers.restore_state import RestoreEntity
|
|||
from homeassistant.helpers.typing import ConfigType
|
||||
import homeassistant.util.color as color_util
|
||||
|
||||
from . import MQTT_LIGHT_SCHEMA_SCHEMA
|
||||
from .schema_basic import CONF_BRIGHTNESS_SCALE
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -81,7 +82,7 @@ PLATFORM_SCHEMA_JSON = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({
|
|||
vol.Required(CONF_COMMAND_TOPIC): mqtt.valid_publish_topic,
|
||||
vol.Optional(CONF_DEVICE): mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA,
|
||||
}).extend(mqtt.MQTT_AVAILABILITY_SCHEMA.schema).extend(
|
||||
mqtt.MQTT_JSON_ATTRS_SCHEMA.schema)
|
||||
mqtt.MQTT_JSON_ATTRS_SCHEMA.schema).extend(MQTT_LIGHT_SCHEMA_SCHEMA.schema)
|
||||
|
||||
|
||||
async def async_setup_entity_json(config: ConfigType, async_add_entities,
|
||||
|
|
|
@ -24,6 +24,8 @@ import homeassistant.helpers.config_validation as cv
|
|||
import homeassistant.util.color as color_util
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from . import MQTT_LIGHT_SCHEMA_SCHEMA
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DOMAIN = 'mqtt_template'
|
||||
|
@ -67,7 +69,7 @@ PLATFORM_SCHEMA_TEMPLATE = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({
|
|||
vol.Optional(CONF_UNIQUE_ID): cv.string,
|
||||
vol.Optional(CONF_DEVICE): mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA,
|
||||
}).extend(mqtt.MQTT_AVAILABILITY_SCHEMA.schema).extend(
|
||||
mqtt.MQTT_JSON_ATTRS_SCHEMA.schema)
|
||||
mqtt.MQTT_JSON_ATTRS_SCHEMA.schema).extend(MQTT_LIGHT_SCHEMA_SCHEMA.schema)
|
||||
|
||||
|
||||
async def async_setup_entity_template(config, async_add_entities, config_entry,
|
||||
|
|
|
@ -58,7 +58,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover(discovery_payload):
|
||||
"""Discover and add an MQTT lock."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
|
|
@ -66,7 +66,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover_sensor(discovery_payload):
|
||||
"""Discover and add a discovered MQTT sensor."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
|
|
@ -62,7 +62,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover(discovery_payload):
|
||||
"""Discover and add a MQTT switch."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
|
|
@ -162,7 +162,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
async def async_discover(discovery_payload):
|
||||
"""Discover and add a MQTT vacuum."""
|
||||
try:
|
||||
discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
|
||||
discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
|
||||
config = PLATFORM_SCHEMA(discovery_payload)
|
||||
await _async_setup_entity(config, async_add_entities, config_entry,
|
||||
discovery_hash)
|
||||
|
|
|
@ -379,7 +379,7 @@ async def test_discovery_removal_alarm(hass, mqtt_mock, caplog):
|
|||
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
@ -409,12 +409,12 @@ async def test_discovery_update_alarm(hass, mqtt_mock, caplog):
|
|||
|
||||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
@ -451,7 +451,7 @@ async def test_discovery_broken(hass, mqtt_mock, caplog):
|
|||
)
|
||||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
|
|
@ -344,12 +344,12 @@ async def test_discovery_update_attr(hass, mqtt_mock, caplog):
|
|||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
' "command_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "json_attributes_topic": "attr-topic1" }'
|
||||
)
|
||||
data2 = (
|
||||
'{ "name": "Beer",'
|
||||
' "command_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "json_attributes_topic": "attr-topic2" }'
|
||||
)
|
||||
async_fire_mqtt_message(hass, 'homeassistant/binary_sensor/bla/config',
|
||||
|
@ -540,7 +540,6 @@ async def test_entity_device_info_update(hass, mqtt_mock):
|
|||
'platform': 'mqtt',
|
||||
'name': 'Test 1',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test-command-topic',
|
||||
'device': {
|
||||
'identifiers': ['helloworld'],
|
||||
'connections': [
|
||||
|
|
|
@ -1177,13 +1177,13 @@ async def test_unique_id(hass):
|
|||
light.DOMAIN: [{
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 1',
|
||||
'status_topic': 'test-topic',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test_topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}, {
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 2',
|
||||
'status_topic': 'test-topic',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test_topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}]
|
||||
|
@ -1200,7 +1200,7 @@ async def test_discovery_removal_light(hass, mqtt_mock, caplog):
|
|||
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
@ -1245,12 +1245,12 @@ async def test_discovery_update_light(hass, mqtt_mock, caplog):
|
|||
|
||||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
@ -1284,7 +1284,7 @@ async def test_discovery_broken(hass, mqtt_mock, caplog):
|
|||
)
|
||||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
|
|
@ -649,14 +649,14 @@ async def test_unique_id(hass):
|
|||
'platform': 'mqtt',
|
||||
'name': 'Test 1',
|
||||
'schema': 'json',
|
||||
'status_topic': 'test-topic',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test_topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}, {
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 2',
|
||||
'schema': 'json',
|
||||
'status_topic': 'test-topic',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test_topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}]
|
||||
|
@ -714,13 +714,13 @@ async def test_discovery_update_light(hass, mqtt_mock, caplog):
|
|||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
' "schema": "json",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "schema": "json",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
@ -755,7 +755,7 @@ async def test_discovery_broken(hass, mqtt_mock, caplog):
|
|||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "schema": "json",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
|
|
@ -265,7 +265,6 @@ async def test_optimistic(hass, mqtt_mock):
|
|||
'{{ blue|d }}',
|
||||
'command_off_template': 'off',
|
||||
'effect_list': ['colorloop', 'random'],
|
||||
'effect_command_topic': 'test_light_rgb/effect/set',
|
||||
'qos': 2
|
||||
}
|
||||
})
|
||||
|
@ -608,7 +607,7 @@ async def test_unique_id(hass):
|
|||
'platform': 'mqtt',
|
||||
'name': 'Test 1',
|
||||
'schema': 'template',
|
||||
'status_topic': 'test-topic',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test_topic',
|
||||
'command_on_template': 'on,{{ transition }}',
|
||||
'command_off_template': 'off,{{ transition|d }}',
|
||||
|
@ -617,7 +616,7 @@ async def test_unique_id(hass):
|
|||
'platform': 'mqtt',
|
||||
'name': 'Test 2',
|
||||
'schema': 'template',
|
||||
'status_topic': 'test-topic',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test_topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}]
|
||||
|
@ -679,7 +678,7 @@ async def test_discovery_update_light(hass, mqtt_mock, caplog):
|
|||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
' "schema": "template",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic",'
|
||||
' "command_on_template": "on",'
|
||||
' "command_off_template": "off"}'
|
||||
|
@ -687,7 +686,7 @@ async def test_discovery_update_light(hass, mqtt_mock, caplog):
|
|||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "schema": "template",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic",'
|
||||
' "command_on_template": "on",'
|
||||
' "command_off_template": "off"}'
|
||||
|
@ -724,7 +723,7 @@ async def test_discovery_broken(hass, mqtt_mock, caplog):
|
|||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "schema": "template",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic",'
|
||||
' "command_on_template": "on",'
|
||||
' "command_off_template": "off"}'
|
||||
|
|
|
@ -246,13 +246,13 @@ async def test_unique_id(hass):
|
|||
lock.DOMAIN: [{
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 1',
|
||||
'status_topic': 'test-topic',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test_topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}, {
|
||||
'platform': 'mqtt',
|
||||
'name': 'Test 2',
|
||||
'status_topic': 'test-topic',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test_topic',
|
||||
'unique_id': 'TOTALLY_UNIQUE'
|
||||
}]
|
||||
|
|
|
@ -428,12 +428,12 @@ async def test_discovery_update_attr(hass, mqtt_mock, caplog):
|
|||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
' "command_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "json_attributes_topic": "attr-topic1" }'
|
||||
)
|
||||
data2 = (
|
||||
'{ "name": "Beer",'
|
||||
' "command_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "json_attributes_topic": "attr-topic2" }'
|
||||
)
|
||||
async_fire_mqtt_message(hass, 'homeassistant/sensor/bla/config',
|
||||
|
@ -495,7 +495,7 @@ async def test_discovery_removal_sensor(hass, mqtt_mock, caplog):
|
|||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic" }'
|
||||
' "state_topic": "test_topic" }'
|
||||
)
|
||||
async_fire_mqtt_message(hass, 'homeassistant/sensor/bla/config',
|
||||
data)
|
||||
|
@ -517,11 +517,11 @@ async def test_discovery_update_sensor(hass, mqtt_mock, caplog):
|
|||
await async_start(hass, 'homeassistant', {}, entry)
|
||||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic" }'
|
||||
' "state_topic": "test_topic" }'
|
||||
)
|
||||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "status_topic": "test_topic" }'
|
||||
' "state_topic": "test_topic" }'
|
||||
)
|
||||
async_fire_mqtt_message(hass, 'homeassistant/sensor/bla/config',
|
||||
data1)
|
||||
|
@ -626,7 +626,6 @@ async def test_entity_device_info_update(hass, mqtt_mock):
|
|||
'platform': 'mqtt',
|
||||
'name': 'Test 1',
|
||||
'state_topic': 'test-topic',
|
||||
'command_topic': 'test-command-topic',
|
||||
'device': {
|
||||
'identifiers': ['helloworld'],
|
||||
'connections': [
|
||||
|
|
|
@ -392,7 +392,7 @@ async def test_discovery_removal_switch(hass, mqtt_mock, caplog):
|
|||
|
||||
data = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
@ -421,12 +421,12 @@ async def test_discovery_update_switch(hass, mqtt_mock, caplog):
|
|||
|
||||
data1 = (
|
||||
'{ "name": "Beer",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
@ -460,7 +460,7 @@ async def test_discovery_broken(hass, mqtt_mock, caplog):
|
|||
)
|
||||
data2 = (
|
||||
'{ "name": "Milk",'
|
||||
' "status_topic": "test_topic",'
|
||||
' "state_topic": "test_topic",'
|
||||
' "command_topic": "test_topic" }'
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue