Anyone had success converting MQTT discovery to manual sensor yaml entities?
I am able to add the same sensor, yet with yaml the device discovery is not working and the sensors lack the “related” settings, while with mqtt discovery device is added as well.
Sensor added, device added
alias: MQTT manual add
sequence:
- service: mqtt.publish
data:
topic: homeassistant/switch/computherm_3/config
retain: true
payload: |-
{
"name": "computherm-3-extra",
"uniq_id": "wifito868gw_computherm_ABCDEF",
"stat_t": "wifito868gw/computherm/ABCDEF/status",
"cmd_t": "wifito868gw/computherm/ABCDEF/control",
"avty_t": "wifito868gw/availability",
"icon": "mdi:thermometer-lines",
"device": {
"identifiers": ["(ESP8266MOD, wifito868gw)"],
"manufacturer": "WEMOS",
"model": "D1 Mini",
"name": "wifito868gw"
}
}
core\homeassistant\components\mqtt\discovery.py | async_discovery_message_received | if CONF_DEVICE in payload is called
→ async_forward_entry_setup → async_setup
Sensor added, device is not added
- platform: mqtt
name: "wifito868gw Temperature"
unit_of_measurement: "°C"
state_topic: "wifito868gw/sensor/status"
icon: "mdi:temperature-celsius"
availability_topic: "wifito868gw/availability"
device_class: "temperature"
state_class: "measurement"
value_template: "{{ value_json.temp }}"
device:
connections: [["mac", "98:CD:XX:XX:XX:XX"]]
identifiers: ["(ESP8266MOD, wifito868gw)"]
manufacturer: "WEMOS"
model: "D1 Mini"
name: "wifito868gw"
core\homeassistant\components\mqtt\sensor.py | async def async_setup_entry is called