Review comments
parent
b9ad19acbf
commit
21197fb968
homeassistant/components/mqtt
tests/components/binary_sensor
|
@ -840,6 +840,7 @@ class MqttAttributes(Entity):
|
|||
|
||||
This method must be run in the event loop and returns a coroutine.
|
||||
"""
|
||||
await super().async_added_to_hass()
|
||||
await self._attributes_subscribe_topics()
|
||||
|
||||
async def attributes_discovery_update(self, config: dict):
|
||||
|
@ -861,15 +862,15 @@ class MqttAttributes(Entity):
|
|||
self._attributes = json_dict
|
||||
self.async_schedule_update_ha_state()
|
||||
else:
|
||||
_LOGGER.debug("JSON result was not a dictionary")
|
||||
_LOGGER.warning("JSON result was not a dictionary")
|
||||
self._attributes = None
|
||||
except ValueError:
|
||||
_LOGGER.debug("Erroneous JSON: %s", payload)
|
||||
_LOGGER.warning("Erroneous JSON: %s", payload)
|
||||
self._attributes = None
|
||||
|
||||
self._attributes_sub_state = await async_subscribe_topics(
|
||||
self.hass, self._attributes_sub_state,
|
||||
{'attributes_topic': {
|
||||
{CONF_JSON_ATTRS_TOPIC: {
|
||||
'topic': self._attributes_config.get(CONF_JSON_ATTRS_TOPIC),
|
||||
'msg_callback': attributes_message_received,
|
||||
'qos': self._attributes_config.get(CONF_QOS)}})
|
||||
|
|
|
@ -293,7 +293,7 @@ class TestSensorMQTT(unittest.TestCase):
|
|||
state = self.hass.states.get('binary_sensor.test')
|
||||
|
||||
assert state.attributes.get('val') is None
|
||||
mock_logger.debug.assert_called_with(
|
||||
mock_logger.warning.assert_called_with(
|
||||
'JSON result was not a dictionary')
|
||||
|
||||
@patch('homeassistant.components.mqtt._LOGGER')
|
||||
|
@ -314,7 +314,7 @@ class TestSensorMQTT(unittest.TestCase):
|
|||
|
||||
state = self.hass.states.get('binary_sensor.test')
|
||||
assert state.attributes.get('val') is None
|
||||
mock_logger.debug.assert_called_with(
|
||||
mock_logger.warning.assert_called_with(
|
||||
'Erroneous JSON: %s', 'This is not JSON')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue