unixorn / ha-mqtt-discoverable

Python module to create MQTT entities that are automatically discovered by Home Assistant
Apache License 2.0
89 stars 21 forks source link

Feature: light entity #140

Closed ha-enthus1ast closed 9 months ago

ha-enthus1ast commented 9 months ago

This change introduces support for light entities

Description

In this PR support for light entities are introduced. Light entities support toggling the light on/off, setting the brightness, setting the color and turning on effects. This new entity is somewhat more complex than previous entities as it requires more data to be passed in the state payload. Previously entities did not support setting the schema of the state payload, as states consisted of either "ON"/"OFF". However, lights require passing json formatted data in the state payload. One downside of introducing this is that the "schema" keyword is reserved by the pydantic basemodel. This has been solved by introducing an alias for said keyword. I don't really like this approach but it is probably the easiest way to fix this without tearing up the model hierarchy.

Tests have also been added for the light entity.

README has been updated with a usage example for the new entity.

License Acceptance

Type of changes

Checklist