Hi,
I added my Solar Inverter into Home Assistant through MQTT…
And its working perfectly, I’m getting entity data from my Solar Inverter…
I would like to group these entities into a single device, so it’s easier to handle in Home assistant, and I’m not finding how to do this???
This is my current YAML code:
mqtt:
sensor:
- name: "Inverter Timestamp"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.Timestamp }}"
- name: "Inverter Sunrise"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunRise }}"
- name: "Inverter Sunset"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunSet }}"
- name: "Inverter Serial"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvSerial }}"
- name: "Inverter Name"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvName }}"
- name: "Inverter Time"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvTime }}"
- name: "Inverter Status"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvStatus }}"
- name: "Inverter Temperature"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvTemperature }}"
unit_of_measurement: "°C"
device_class: temperature
- name: "Inverter Grid Relay/Contactor"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvGridRelay }}"
- name: "Inverter Today Energy"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.EToday }}"
unit_of_measurement: "kWh"
icon: mdi:solar-power
- name: "Inverter Total Energy"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.ETotal }}"
unit_of_measurement: "kWh"
icon: mdi:solar-power
- name: "Inverter Instant Power"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PACTot | int }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
- name: "Inverter DC Power String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PDC1 }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
- name: "Inverter DC Power String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PDC2 }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
- name: "Inverter DC Voltage String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.UDC1 }}"
unit_of_measurement: "V"
icon: mdi:solar-power
- name: "Inverter DC Voltage String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.UDC2 }}"
unit_of_measurement: "V"
icon: mdi:solar-power
- name: "Inverter DC Current String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.IDC1 }}"
unit_of_measurement: "A"
icon: mdi:solar-power
- name: "Inverter DC Current String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.IDC2 }}"
unit_of_measurement: "A"
icon: mdi:solar-power
rossk
June 18, 2023, 7:07pm
2
If you add under each sensor the same device data then it will tie them each one to the same device:
Thanks, not sure how to do that…
Could you give a small YAML example?
You can define via script as well. See here:
I would not do this, if you want to change anyway. Just use the publish service and the discovery way) to avoid all the yaml-loads, etc. Put it in a script, run it once (!) and you have all the entities and on top a device (which is not possible with yaml config). Here my config.
alias: MQTT Discovery Huqvarna Automower 330x
sequence:
- service: mqtt.publish
data:
topic: homeassistant/sensor/mahroboter_gps_breitengrad/config
retain: true
payload: |
{
"s…
rossk
June 18, 2023, 7:34pm
5
mqtt:
sensor:
- name: "Inverter Timestamp"
state_topic: "sbfspot/123456"
device:
identifiers: 12345
manufacturer: Who Knows
name: My Inverter
model: V1
- name: "Inverter Sunrise"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunRise }}"
device:
identifiers: 12345
manufacturer: Who Knows
name: My Inverter
model: V1
The list of acceptable fields under the device heading are in the above link.
You can put as many or as little fields as you like and you can put what you like.
To tie sensors together under the same device just add the device heading and some fields of you choice and make sure that each sensor has the same info like my yaml example above.
Edit: Or you can do it via a script like @arganto says
1 Like
Thanks!
Edited the code as you showed to the following, but there is no device that get created in HomeAssistant…
Entities still update as before, so it keeps working, but seeing the device nowhere…
mqtt:
sensor:
- name: "Inverter Timestamp"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.Timestamp }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Sunrise"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunRise }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Sunset"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunSet }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Serial"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvSerial }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Name"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvName }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Time"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvTime }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Status"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvStatus }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Temperature"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvTemperature }}"
unit_of_measurement: "°C"
device_class: temperature
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Grid Relay/Contactor"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvGridRelay }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Today Energy"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.EToday }}"
unit_of_measurement: "kWh"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Total Energy"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.ETotal }}"
unit_of_measurement: "kWh"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Instant Power"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PACTot | int }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Power String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PDC1 }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Power String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PDC2 }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Voltage String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.UDC1 }}"
unit_of_measurement: "V"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Voltage String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.UDC2 }}"
unit_of_measurement: "V"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Current String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.IDC1 }}"
unit_of_measurement: "A"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Current String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.IDC2 }}"
unit_of_measurement: "A"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
rossk
June 18, 2023, 9:13pm
7
Have you restarted home assistant?
The devices should be found / shown as a device in your mqtt integration.
francisp
(Francis)
June 19, 2023, 5:41am
8
You need to use a discovery script to create a device.
rossk
June 19, 2023, 12:58pm
9
Is this to make the device show up in HA natively? if so where would the device be shown in HA?
I thought it would only ever show up in HA as a device under the MQTT integration itself or am I missing something here?
rossk
June 19, 2023, 1:53pm
11
Yeah that’s what I thought we were talking about - that is exactly what I have by simply adding the device info in to the MQTT template sensors I created - no script run.
Hi,
tried several things and restarts, but with the YAML I’m seeing the entities in Home Assistant, but no device…
YAML content:
mqtt:
sensor:
- name: "Inverter Timestamp"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.Timestamp }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Sunrise"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunRise }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Sunset"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunSet }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Serial"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvSerial }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Name"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvName }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Time"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvTime }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Status"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvStatus }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Temperature"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvTemperature }}"
unit_of_measurement: "°C"
device_class: temperature
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Grid Relay/Contactor"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvGridRelay }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Today Energy"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.EToday }}"
unit_of_measurement: "kWh"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Total Energy"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.ETotal }}"
unit_of_measurement: "kWh"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Instant Power"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PACTot | int }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Power String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PDC1 }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Power String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PDC2 }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Voltage String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.UDC1 }}"
unit_of_measurement: "V"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Voltage String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.UDC2 }}"
unit_of_measurement: "V"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Current String 1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.IDC1 }}"
unit_of_measurement: "A"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Current String 2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.IDC2 }}"
unit_of_measurement: "A"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
Now tried the alternative and started to make a script carefully with one entity:
But how do I link the value_template into this script?
value_template: "{{ value_json.Timestamp }}
DRAFT SCRIPT:
alias: MQTT Discovery SBFSpot
sequence:
- service: mqtt.publish
data:
topic: homeassistant/sensor/inverter_timestamp/config
retain: true
payload: |
{
"state_topic": "sbfspot/123456",
"name": "Inverter Timestamp",
"unique_id": "unique_id_inverter_timestamp",
"object_id": "inverter_timestamp",
"device": {
"identifiers": ["SBFSpot-SB4000"],
"name": "SBFSpot-SB4000",
"model": "V1",
"manufacturer": "SBFSpot",
}
}
mode: single
rossk
June 19, 2023, 2:07pm
13
You have no “unique_id” set so i dont think it will show - try adding a unique_id also.
Cant help on the script side as I have never needed to do this to create an MQTT device before.
I have approx 30 MQTT sensors set up for my workshop / garage heater and they all show up under 1 MQTT device, as you can see from the following, each sensor has its own unique ID and each sensor also has the exactly the same device info - this should be all that is needed to group them as the same device - or at least this is how I have always done it - no scripts ever used to achieve this…
sensor:
- name: Garage Heater Desired Temp
unique_id: garage_heater_desired_temp
state_topic: "AfterburnerBB2F90/sts/TempDesired"
device_class: temperature
unit_of_measurement: °C
state_class: measurement
device:
identifiers: BB2F90
manufacturer: MrJones
name: Workshop Afterburner
model: Afterburner V2
availability:
topic: "AfterburnerBB2F90/status"
payload_available: "online"
payload_not_available: "offline"
- name: Garage Heater Internal Temperature Sensor
unique_id: garage_heater_internal_temp
state_topic: "AfterburnerBB2F90/sts/TempBody"
device_class: temperature
unit_of_measurement: °C
state_class: measurement
device:
identifiers: BB2F90
manufacturer: MrJones
name: Workshop Afterburner
model: Afterburner V2
availability:
topic: "AfterburnerBB2F90/status"
payload_available: "online"
payload_not_available: "offline"
2 Likes
Yes!
Thank you, it’s working now…
My code:
mqtt:
sensor:
- name: "Inverter Timestamp"
unique_id: "inverter_timestamp"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.Timestamp }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Sunrise"
unique_id: "inverter_sunrise"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunRise }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Sunset"
unique_id: "inverter_sunset"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.SunSet }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Serial"
unique_id: "inverter_serial"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvSerial }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Name"
unique_id: "inverter_name"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvName }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Time"
unique_id: "inverter_time"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvTime }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Status"
unique_id: "inverter_status"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvStatus }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Temperature"
unique_id: "inverter_temperature"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvTemperature }}"
unit_of_measurement: "°C"
device_class: temperature
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Grid Relay/Contactor"
unique_id: "inverter_grid_relay_contactor"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.InvGridRelay }}"
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Today Energy"
unique_id: "inverter_today_energy"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.EToday }}"
unit_of_measurement: "kWh"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Total Energy"
unique_id: "inverter_total_energy"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.ETotal }}"
unit_of_measurement: "kWh"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter Instant Power"
unique_id: "inverter_instant_power"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PACTot | int }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Power String 1"
unique_id: "inverter_dc_power_string_1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PDC1 }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Power String 2"
unique_id: "inverter_dc_power_string_2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.PDC2 }}"
unit_of_measurement: "W"
device_class: power
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Voltage String 1"
unique_id: "inverter_dc_voltage_string_1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.UDC1 }}"
unit_of_measurement: "V"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Voltage String 2"
unique_id: "inverter_dc_voltage_string_2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.UDC2 }}"
unit_of_measurement: "V"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Current String 1"
unique_id: "inverter_dc_current_string_1"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.IDC1 }}"
unit_of_measurement: "A"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
- name: "Inverter DC Current String 2"
unique_id: "inverter_dc_current_string_2"
state_topic: "sbfspot/123456"
value_template: "{{ value_json.IDC2 }}"
unit_of_measurement: "A"
icon: mdi:solar-power
device:
identifiers: "SBFSpot-SB4000"
manufacturer: "SBFSpot"
name: "SBFSpot-SB4000"
model: "V1"
4 Likes
123
(Taras)
June 22, 2023, 12:29pm
16
The documentation for MQTT Discovery has always claimed it’s not possible to define a device using YAML configuration.
Documentation for MQTT Binary Sensor :
Are you saying that the documentation is no longer correct and it’s possible to define a device in YAML?
rossk
June 22, 2023, 1:18pm
17
Yes, 100% - I have multiple MQTT devices setup all containing multiple sensors that were simply created in mqtt.yaml and as long as each sensor has its own unique_id, then its simply a case of adding exactly the same device info to each sensor you want grouped.
This is how I have always done it, I have never used a script to achieve this functionality.
123
(Taras)
June 22, 2023, 1:51pm
18
Do you recall approximately when you first started to use it?
FWIW, it didn’t work in the distant past (logged it as an error; there are posts by users who tried it but failed) so it has changed since then.
In addition, whoever changed it overlooked to update the documentation because, as seen in the screenshot above, it still warns that device
is only supported via MQTT Discovery.
There have been a lot of changes made to the MQTT integration so it’s challenging to pinpoint which PR added the ability to define device
in YAML.
https://github.com/home-assistant/core/pulls?q=is%3Apr+is%3Aclosed+label%3A"integration%3A+mqtt"+
Skimming the titles of PRs merged in the past few months hasn’t revealed anything obvious. In addition, I don’t recall this new capability mentioned in recent (i e. last 6 months) Release Notes. Either I missed it or it’s older than a half-year.
It’s a welcome change, but a seemingly stealthy one.
rossk
June 22, 2023, 2:11pm
19
Difficult to remember, but if it helps I can tell you that the last time I set up a new MQTT device was 05/02/2023 - so it must have been changed prior to that.
123
(Taras)
June 22, 2023, 10:02pm
20
I contacted the MQTT integration’s most prolific contributor (jbouwh) and he has confirmed that the long-standing inability to define a device in YAML was eliminated some time ago. The exact date is unclear but it may have been a year ago when the format for defining MQTT entities was changed significantly. Anyway, he has updated the documentation and it no longer makes the claim that the device
option is exclusively supported by MQTT Discovery.
tl;dr
To all long-standing users who still remember when you could not define a device in YAML, and only via MQTT Discovery, that limitation no longer exists.
1 Like