MQTT discovery for custom device properties

Hi, I’m pretty new to homassistant, and currently trying to port my devices to the new environment. They’ve been using the homie convention, which isn’t supperted in HA, so I adapted then for mqtt discovery, which basically is working fine, as long as the device properties fit to anything like switch, fan, sensor etc.

However, I couldn’t find a way how to discover simple properties like

  • a list of states, e.g. [“left”, “right”, “stop”], which can be selected and read back via HA
  • a numeric input

There are a number of device types supported by MQTT discovery, which comprise properties very close to my needs. HVAC devices support modes, though limited to [“auto”, “off”, “cool”, “heat”, “dry”, “fan_only”], but essentially this is what I need, just for custom values. Lights support a brightness property - but I don’t need a complete light device, just a numeric input with a custom range, lets say: 1…42.

I can’t figure out how to do that, and I can’t believe it’s not possible.

Any hints? Thanks in advance!

From the documentation for MQTT Discovery, here’s what it supports:

Supported by MQTT discovery:

You can’t use it to discover what are known as ‘helpers’ such as input_datetime, input_select, input_text, input_number, timers, etc.

Thanks, Taras, that’s what I’ve already found. But I really can’t believe, there’s no way; most (all?) of these devices support even configuration of where to find the command an state topic, and how to map the value, making this approach pretty flexible - just to be choked off by a very limited set of supported devices, not even including those little helper elements…

Any workaround at least, like a way of extending the discovery, or any other kind of mechanism for realizing this purpose?

Not sure what else to say other than MQTT Discovery doesn’t do what you want. Extending it would, I suspect, require submitting a proposal to the Architecture repo.

Feel free to explore the REST and Websocket APIs. As far as I know neither offers services to create an entity. The Native App integration offers a means to register a sensor via a webhook but that’s the limit of my knowledge of it. Beyond that, only integrations have the ability to create entities but that’s a non-trivial way of addressing your request.

Just make sensors and use the mqtt.publish service. You can literally make any of those ‘helpers’ that way.

Could you please explain this a bit further, petro? I’m not sure how a device could be discovered this way.