Device from MQTT light

I have created an entry under light: for a custom built light with brightness control:

- platform: mqtt
  name: "uk_hall_deco_controller"
  state_topic:   "home-uk/hall/deco/switch"
  command_topic: "home-uk/hall/deco/switch/set"
  brightness_state_topic: "home-uk/hall/deco/brightness"
  brightness_command_topic: "home-uk/hall/deco/brightness/set"
  brightness_scale: 100
  unique_id: "uk_hall_deco_controller"
    identifiers: "uk_hall_deco_controller"
    name: "uk_hall_deco_controller"

I can make a light widget for this just fine, but it does not show up as a device, which seems to prohibit me from using it in scenes and automations. How do I deal with this?

I also have tried using YAML for mqtt light/switch to get HA to derive a “device”, but no luck. The documentation says that the device config portion only works with discovery, so that would explain why YAML can’t be used to create a “device”.

However there is a work around that you can read about here where a script is use to publish an MQTT topic/data that emulates discovery:

I have played with this some using the developer’s tool->Services using mqtt.publish instead of a script mentioned in that thread.

That’s an overstatement. It only prohibits you from creating Device Automations via the UI. Other than that, all entities can be used in scenes and automations.

The concept of “Device” serves as a way to organize entities (to group them by common purpose). For example, my printer is rendered as a Device with many entities such as Toner Remaining, Drum Remaining, Page Count, etc. It also offers the ability to create a Device Automation for any its “child entities”. However, with or without a “parent” Device, entities can be referenced by scripts, scenes, and automations.

If you like the organizational benefit of a the Device concept, and the ability to create Device Automations, then you cannot define an MQTT Light via YAML. This part you added here is invalid:

    identifiers: "uk_hall_deco_controller"
    name: "uk_hall_deco_controller"

You must define the MQTT Light using MQTT Discovery because it supports the definition of Devices. For an example, follow the link wmaker posted above.

Ok, thanks. I have found the possibility for entries by now. I didn’t find them particularly intuitive. For dimming, I was successful with “Call service” -> “light.turn_on” and specify brightness in the data section.

I don’t see a possibility to put it in scenes in the gui, though?

You can use entities in a scene, not devices (not via the Scene Editor or in YAML). A device’s entities have states and scenes control an entity’s state.

That would make a lot of sense to me, but the Scene Editor looks like this:

You’re conflating what the Scene Editor presents in the UI to represent what it actually uses within a scene. It may present Devices as a choice but it will only use the entities associated with the device. I suggest you examine the YAML code of a scene created by the Scene Editor. You won’t find references to the device, only to its associated entities.

The only place you will find a reference to a device is when you create a Device Automation (i.e. an automation with a Device Trigger).

That is fine and all, but it doesn’t change the fact that using this editor, I don’t see how I would use an entity without a device in a scene.

The Scene Editor allows you to select entities.

Mine doesn’t ( Home Assistant 2021.1.1)

I’m running the same version on two instances of Home Assistant (one is Home Assistant OS and the other is Home Assistant Supervised) and the Scene Editor in both shows Entity selection.

Try refreshing the web page (Ctrl+F5).

1 Like

Weird. Refresh didn’t help. It’s also not in mobile client.

I see the problem now, I believe you don’t have Advanced Mode enabled.

You need to modify your user profile. Click on the user-icon (last choice in the main menu) and enable Advanced Mode.

1 Like

Just was about to write the same :wink:

Found it, thanks. That’s confusing.
Now I could add the entity.
Next task: Find out how to assign an actual status. But I guess I’ll read up on that before I bother you guys :slight_smile: