#need help with custom mqtt thermostat, and parent device to group many entities

1 messages · Page 1 of 1 (latest)

cold gull
#

ive got a custom thermostat system talking to HA over MQTT, it has one climate entity to adjust the setpoint and monitor one zone, and it has a dozen sensor entities to monitor other uncontrolled zones

but i want to group them all into one device

#

currently, all of the entities just fal into an ungrouped section within HA

#

for extra context, the topic homeassistant/sensor/outdoors/config is getting a payload of:

{
 "device":{"identifiers":["outdoors"],"name":"Outside","serial_number":"28e7065f02000023","via_device":"temp_daemon"},
 "device_class":"temperature",
 "expire_after":60,
 "name":"Outside",
 "object_id":"outdoors",
 "state_topic":"homeassistant/sensor/outdoors/temp",
 "suggested_display_precision":1,
 "unique_id":"outdoors",
 "unit_of_measurement":"\u00b0C",
 "value_template":"{{ value_json.temperature}}"}
#

while zigbee2mqtt is grouping multiple entities together:

cold gull
#

ive re-organized the code some, it now has these 2 payloads:

#

homeassistant/sensor/outdoors/config
with:

{
    "availability": [
        {
            "topic": "temp_daemon/state",
            "value_template": "{{ value_json.state }}"
        }
    ],
    "device": {
        "identifiers": [
            "outdoors"
        ],
        "name": "Outside",
        "serial_number": "28e7065f02000023",
        "via_device": "temp_daemon"
    },
    "device_class": "temperature",
    "expire_after": 60,
    "name": "Outside",
    "object_id": "outdoors",
    "state_topic": "temp_daemon/state",
    "suggested_display_precision": 1,
    "unique_id": "outdoors",
    "unit_of_measurement": "°C",
    "value_template": "{{ value_json.outdoors}}"
}```
#

and temp_daemon/state with:

{
    "bedroom": 21.1875,
    "hallway": 21.8125,
    "kitchen": 20.5,
    "living_room": 19.6875,
    "mode": "auto",
    "outdoors": -11,
    "server_room": 21.875,
    "setpoint": 18,
    "state": "online"
}
#

both verified to be reaching HA, via the "listen to a topic" option in the HA settings

#

and there is also a homeassistant/climate/living_room/config where i'm having a different issue:

{
    "availability": [
        {
            "topic": "temp_daemon/state",
            "value_template": "{{ value_json.state }}"
        }
    ],
    "current_temperature_template": "{{value_json.living_room}}",
    "current_temperature_topic": "temp_daemon/state",
    "device": {
        "identifiers": [
            "temp_daemon"
        ]
    },
    "expire_after": 60,
    "mode_state_template": "{{ json_value.mode }}",
    "mode_state_topic": "temp_daemon/state",
    "modes": [
        "auto"
    ],
    "name": "Living Room",
    "optimistic": true,
    "retain": true,
    "temperature_command_topic": "temp_daemon/living_room/set_temp",
    "temperature_state_template": "{{ json_value.setpoint }}",
    "temperature_state_topic": "temp_daemon/state",
    "unique_id": "living_room"
}
#

when i post updates to the temperature_state_topic (due to changing it outside HA), the current setpoint in HA isnt updating

cold gull
#

🤦 {{ json_value.mode }} vs {{ value_json.state }}, one of these isnt like the other!

#

lets see what happens if i fix those...

#

yep, that explains half the problem, the temperature_state_topic is working now

#

that just leaves the entity grouping

bitter lagoon
#

YOu have to provide the same device information to all the config topics

#

Your device information differs from the 2 or 3 that you've posted so far

#

meaning HA will see them as different devices

cold gull
#

let me try with them all matching...

#
{
    "availability": [
        {
            "topic": "temp_daemon/state",
            "value_template": "{{ value_json.state }}"
        }
    ],
    "device": {
        "identifiers": [
            "temp_daemon"
        ],
        "name": "temp daemon",
        "via_device": "temp_daemon"
    },
    "device_class": "temperature",
    "expire_after": 60,
    "name": "Outside",
    "object_id": "outdoors",
    "state_topic": "temp_daemon/state",
    "suggested_display_precision": 1,
    "unique_id": "outdoors",
    "unit_of_measurement": "°C",
    "value_template": "{{ value_json.outdoors}}"
}
``` for `homeassistant/sensor/outdoors/config`
#
{
    "availability": [
        {
            "topic": "temp_daemon/state",
            "value_template": "{{ value_json.state }}"
        }
    ],
    "current_temperature_template": "{{value_json.living_room}}",
    "current_temperature_topic": "temp_daemon/state",
    "device": {
        "identifiers": [
            "temp_daemon"
        ],
        "name": "temp daemon",
        "via_device": "temp_daemon"
    },
    "expire_after": 60,
    "mode_state_template": "{{ value_json.mode }}",
    "mode_state_topic": "temp_daemon/state",
    "modes": [
        "auto"
    ],
    "name": "Living Room",
    "optimistic": true,
    "retain": true,
    "temperature_command_topic": "temp_daemon/living_room/set_temp",
    "temperature_state_template": "{{ value_json.setpoint }}",
    "temperature_state_topic": "temp_daemon/state",
    "unique_id": "living_room"
}
``` for `homeassistant/climate/living_room/config`
cold gull
#

but i do also see a new device, with some connected devices

#

but each of those devices, then has zero entities within it

bitter lagoon
#

Then you're doing something wrong, look at the documentation again and verify you're supplying the correct information for a device

cold gull
bitter lagoon
#

All I provide is name, identifiers, and manufacturer and it works 🤷‍♂️

#

Not sure where you're getting via_device either

cold gull
#

i tweaked some things, and now its working better

#

"device":{"identifiers":["temp_daemon"],"name":"temp daemon"} for both and now its grouping things

#

thats looking much better, its now on the devices list, and shows all of the controls/sensors, like any other device!

#

thanks!