mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
parent
a1884ed821
commit
cb563f25fa
@ -6,9 +6,12 @@ from homeassistant.components import mqtt
|
|||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
from .definitions import SENSORS, DSMRReaderSensorEntityDescription
|
from .definitions import SENSORS, DSMRReaderSensorEntityDescription
|
||||||
|
|
||||||
|
|
||||||
@ -53,6 +56,20 @@ class DSMRSensor(SensorEntity):
|
|||||||
|
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
await mqtt.async_subscribe(
|
try:
|
||||||
self.hass, self.entity_description.key, message_received, 1
|
await mqtt.async_subscribe(
|
||||||
)
|
self.hass, self.entity_description.key, message_received, 1
|
||||||
|
)
|
||||||
|
except HomeAssistantError:
|
||||||
|
async_create_issue(
|
||||||
|
self.hass,
|
||||||
|
DOMAIN,
|
||||||
|
f"cannot_subscribe_mqtt_topic_{self.entity_description.key}",
|
||||||
|
is_fixable=False,
|
||||||
|
severity=IssueSeverity.WARNING,
|
||||||
|
translation_key="cannot_subscribe_mqtt_topic",
|
||||||
|
translation_placeholders={
|
||||||
|
"topic": self.entity_description.key,
|
||||||
|
"topic_title": self.entity_description.key.split("/")[-1],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
@ -259,5 +259,11 @@
|
|||||||
"name": "Quarter-hour peak end time"
|
"name": "Quarter-hour peak end time"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"issues": {
|
||||||
|
"cannot_subscribe_mqtt_topic": {
|
||||||
|
"title": "Cannot subscribe to MQTT topic {topic_title}",
|
||||||
|
"description": "The DSMR Reader integration cannot subscribe to the MQTT topic: `{topic}`. Please check the configuration of the MQTT broker and the topic.\nDSMR Reader needs to be running, before starting this integration."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user