Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HA MQTT Discovery creates Unnamed devices #292

Open
kickouille opened this issue Mar 7, 2025 · 3 comments
Open

HA MQTT Discovery creates Unnamed devices #292

kickouille opened this issue Mar 7, 2025 · 3 comments

Comments

@kickouille
Copy link

Describe the bug
An unnamed MQTT device is created in Home Assistant for each gateway and the devices the gateway detected go under "Connected devices" section.

To Reproduce
Simply enable ha discovery and get some devices discovered.

Expected behavior
This unnamed device should not be created, or if it represents the gateway, it should get the name the gateway, along with the firmware version for example, and eventually information about its status, and show the devices it is connected (linked) to).

Screenshots

Image Image

Environment
Using gateway 1.5.0 with Home Assistant 2025.2.5

Additional context
My guess is that cns list below is not properly formatted and maybe misused:

{
  "stat_t": "+/+/BTtoMQTT/AABBCCDDEEFF",
  "dev_cla": "illuminance",
  "unit_of_meas": "lx",
  "state_class": "measurement",
  "name": "CGPR1-lux",
  "uniq_id": "AABBCCDDEEFF-lux",
  "val_tpl": "{{ value_json.lux | is_defined }}",
  "device": {
    "ids": [
      "AABBCCDDEEFF"
    ],
    "cns": [
      [
        "mac",
        "AABBCCDDEEFF"
      ]
    ],
    "mf": "Qingping",
    "mdl": "CGPR1",
    "name": "Motion & Light-DDEEFF",
    "via_device": "TheengsGateway2"
  }
}

cns should be used to link the discovered device to another device which represents the gateway itself.

@kickouille
Copy link
Author

Actually it not the cns which is causing the problem, but the via_device, please see PR #293

After this fix, no unnamed device will be created.

I will be working on creating the gateway device, when I have time. The problem I see is if multiple gateways are used the via_device doesn't make much sense because the config is sent only once, on first discovery. This would represent the last gateway which as seen the device after a restart... Considering gateways are being given a unique name each.

@1technophile
Copy link
Member

For consistency with OpenMQTTGateway I would prefer to keep the via_device and add a name to it. I understand the point when using multiple gateways but it is still useful for single gateway installations.

@kickouille
Copy link
Author

Ok, then I will revert the change back and try to add some code to create the gateway device somewhere in https://github.com/kickouille/gateway/blob/development/TheengsGateway/ble_gateway.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants