Hi all,
I’m a newbie in Home Assistant and MQTT. I have some Shelly devices and I’m trying to use MQTT since the current Shelly integration is very slow in answering or doesn’t answer at all with battery powered devices. I also tried ShellyForAss but without luck.
For example I have some Shelly “door and window 2” devices to detect open and close of windows ad doors.
That device has 3 sensors (battery level, lux level and tilt angle) and 2 binary sensors (state open/close and vibration on/off).
In configuration.yaml I defines in this way:
sensor:
- platform: mqtt
name: "door_blindata_lux"
unique_id: "shelly_door_blindata_lux"
state_topic: "shellies/door_blindata/sensor/lux"
value_template: '{{ value|round(0) }}'
qos: 0
device_class: illuminance
unit_of_measurement: 'lux'
- platform: mqtt
name: "door_blindata_battery"
unique_id: "shelly_door_blindata_battery"
state_topic: "shellies/door_blindata/sensor/battery"
value_template: '{{ value|round(0) }}'
qos: 0
device_class: battery
unit_of_measurement: '%'
icon: mdi:battery
- platform: mqtt
name: "door_blindata_tilt"
unique_id: "shelly_door_blindata_tilt"
state_topic: "shellies/door_blindata/sensor/tilt"
value_template: '{{ value|round(0) }}'
qos: 0
unit_of_measurement: '°'
icon: mdi:angle-acute
binary_sensor:
- platform: mqtt
state_topic: "shellies/door_blindata/sensor/state"
name: "door_blindata_state"
unique_id: "shelly_door_blindata_state"
payload_on: 'open'
payload_off: 'close'
qos: 0
device_class: door
- platform: mqtt
state_topic: "shellies/door_blindata/sensor/vibration"
name: "door_blindata_vibration"
unique_id: "shelly_door_blindata_vibration"
payload_on: '1'
payload_off: '0'
qos: 0
device_class: vibration
In dashbord they appared as single entities, so I group them in this way (groups.yaml):
Door Blindata:
entities:
- binary_sensor.door_blindata_state
- binary_sensor.door_blindata_vibration
- sensor.door_blindata_tilt
- sensor.door_blindata_lux
- sensor.door_blindata_battery
In this way I have a single tile in dashboard with all the above sensors and they work correctly if the state change.
But this isn’t what I would like to obtain. I would like that all the sensors would belong to a new device called e.g. “Main Door” and I would like to assign that new device “Main Door” to an already defined area e.g. Living Room.
I already googled a lot, really, but I only found this answer that seems similar to my problem:
https://community.home-assistant.io/t/how-to-turn-mqtt-entity-into-a-device/184451/8
but the only thing I understood is that I’d be really dumb since I do not understand the selected solution. BTW I do not know how to obtain the autodiscovery string.
So, how to use in configuration.yaml or whatever else and the mqtt autodiscovery message to build the device?
Thanks in advance