Create Input Select with Mqtt

I’m trying to create an input select programmatically using mqtt, but my attempts seem to fail and I can’t see any logs to say why it has failed.

Here is an example of the request sent:

MQTT sending to homeassistant/input_select/test_mode/config:
{
    "name": "Test Mode",
    "unique_id": "homeassistant_input_select_test_mode_config",
    "object_id": "test_mode",
    "command_topic": "homeassistant/input_select/test_mode/set",
    "state_topic": "homeassistant/input_select/test_mode/state",
    "json_attributes_topic": "homeassistant/input_select/test_mode/attributes",
    "platform": "select",
    "options": [
        "Normal",
        "Motion",
        "Sleeping"
    ]
}

If I try creating something like a switch in the same way, that works:

MQTT sending to homeassistant/switch/test/config:
{
    "name": "Test switch",
    "device_class": "switch",
    "unique_id": "homeassistant_switch_test_config",
    "object_id": "test",
    "command_topic": "homeassistant/switch/test/set",
    "state_topic": "homeassistant/switch/test/state",
    "json_attributes_topic": "homeassistant/switch/test/attributes"
}

I can’t seem to find much in the way of documentation or examples of other people creating select entites, this is all I could find and what I’ve tried to use as inspiration for my attempts so far with no success.

Any help would be much appreciated :slight_smile:

Andy

There is no mqtt “input_select”. It is the mqtt select:

It does the same thing. Follow that documentation.

1 Like

Hello Andy McInnes,

Another thing could be syntax and formatting.

Troubleshooting MQTT? MQTT-Explorer can help you be successful!
If you have Add-ons available, try adding this Add-on repository to your Add-on list. GitHub - GollumDom/addon-repository.
With this you can see that the broker sees and likely find the bug.
HINT: I have found using this, if you look at the JSON string and it is in color, the JSON is valid. If it is monochrome, the JSON is invalid and it will not work.

1 Like

Hmm ok that wasn’t completely obvious. I’ve changed my code to just create an entity called “select.test_mode” and that has created an entity.

I guess my confusion is that there are the input type entities i.e. an “input_select” which can be seen below along side my select.test_mode. I was trying to create an input select, rather than a select that is part of a device. I.e. the use case in my scenario is creating a Room Mode select for each room, so that I can use it in my room and light automations in my code.

Is it not possible to generate an input_select then from outside of home assistant? (I’m doing this in c# btw not that that has any real bearing on if/how it’s possible to do this).

Thanks for helping :slight_smile:

Input selects are helpers created within home assistant by the user. There are actions to change the list of options and select the active option.

Selects are a similar thing but created by integrations. There is only an action to select the active option from a set list (you don’t want the end user changing the list, that is a function of the integration/device, e.g. HVAC heat modes).

1 Like

Thanks that clarifies it, I’ve updated my code now and seem able to achieve what I wanted.