mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Review comments
This commit is contained in:
parent
b9ad19acbf
commit
21197fb968
@ -840,6 +840,7 @@ class MqttAttributes(Entity):
|
|||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
"""
|
"""
|
||||||
|
await super().async_added_to_hass()
|
||||||
await self._attributes_subscribe_topics()
|
await self._attributes_subscribe_topics()
|
||||||
|
|
||||||
async def attributes_discovery_update(self, config: dict):
|
async def attributes_discovery_update(self, config: dict):
|
||||||
@ -861,15 +862,15 @@ class MqttAttributes(Entity):
|
|||||||
self._attributes = json_dict
|
self._attributes = json_dict
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug("JSON result was not a dictionary")
|
_LOGGER.warning("JSON result was not a dictionary")
|
||||||
self._attributes = None
|
self._attributes = None
|
||||||
except ValueError:
|
except ValueError:
|
||||||
_LOGGER.debug("Erroneous JSON: %s", payload)
|
_LOGGER.warning("Erroneous JSON: %s", payload)
|
||||||
self._attributes = None
|
self._attributes = None
|
||||||
|
|
||||||
self._attributes_sub_state = await async_subscribe_topics(
|
self._attributes_sub_state = await async_subscribe_topics(
|
||||||
self.hass, self._attributes_sub_state,
|
self.hass, self._attributes_sub_state,
|
||||||
{'attributes_topic': {
|
{CONF_JSON_ATTRS_TOPIC: {
|
||||||
'topic': self._attributes_config.get(CONF_JSON_ATTRS_TOPIC),
|
'topic': self._attributes_config.get(CONF_JSON_ATTRS_TOPIC),
|
||||||
'msg_callback': attributes_message_received,
|
'msg_callback': attributes_message_received,
|
||||||
'qos': self._attributes_config.get(CONF_QOS)}})
|
'qos': self._attributes_config.get(CONF_QOS)}})
|
||||||
|
@ -293,7 +293,7 @@ class TestSensorMQTT(unittest.TestCase):
|
|||||||
state = self.hass.states.get('binary_sensor.test')
|
state = self.hass.states.get('binary_sensor.test')
|
||||||
|
|
||||||
assert state.attributes.get('val') is None
|
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')
|
'JSON result was not a dictionary')
|
||||||
|
|
||||||
@patch('homeassistant.components.mqtt._LOGGER')
|
@patch('homeassistant.components.mqtt._LOGGER')
|
||||||
@ -314,7 +314,7 @@ class TestSensorMQTT(unittest.TestCase):
|
|||||||
|
|
||||||
state = self.hass.states.get('binary_sensor.test')
|
state = self.hass.states.get('binary_sensor.test')
|
||||||
assert state.attributes.get('val') is None
|
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')
|
'Erroneous JSON: %s', 'This is not JSON')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user