feat!: Use type alias instead of generic parameters in device macro
All checks were successful
Build and deploy / build (push) Successful in 10m11s
Build and deploy / Deploy container (push) Successful in 2m8s

This enforced the idea that all generics must be specified for the type
when using the device macro. It will also come into play later when the
Typed macro gets introduced, as the name will be used when generating
definitions.
This commit is contained in:
2025-09-17 00:35:30 +02:00
parent 580a5187bd
commit 06b3154733
4 changed files with 30 additions and 32 deletions

View File

@@ -89,9 +89,9 @@ impl From<StateColorTemperature> for StateBrightness {
}
#[derive(Debug, Clone, Device)]
#[device(traits(OnOff for <StateOnOff>, <StateBrightness>, <StateColorTemperature>))]
#[device(traits(Brightness for <StateBrightness>, <StateColorTemperature>))]
#[device(traits(ColorSetting for <StateColorTemperature>))]
#[device(traits(OnOff for LightOnOff, LightBrightness, LightColorTemperature))]
#[device(traits(Brightness for LightBrightness, LightColorTemperature))]
#[device(traits(ColorSetting for LightColorTemperature))]
pub struct Light<T: LightState> {
config: Config<T>,
@@ -144,7 +144,7 @@ impl<T: LightState> Device for Light<T> {
}
#[async_trait]
impl OnMqtt for Light<StateOnOff> {
impl OnMqtt for LightOnOff {
async fn on_mqtt(&self, message: Publish) {
// Check if the message is from the device itself or from a remote
if matches(&message.topic, &self.config.mqtt.topic) {
@@ -177,7 +177,7 @@ impl OnMqtt for Light<StateOnOff> {
}
#[async_trait]
impl OnMqtt for Light<StateBrightness> {
impl OnMqtt for LightBrightness {
async fn on_mqtt(&self, message: Publish) {
// Check if the message is from the deviec itself or from a remote
if matches(&message.topic, &self.config.mqtt.topic) {
@@ -216,7 +216,7 @@ impl OnMqtt for Light<StateBrightness> {
}
#[async_trait]
impl OnMqtt for Light<StateColorTemperature> {
impl OnMqtt for LightColorTemperature {
async fn on_mqtt(&self, message: Publish) {
// Check if the message is from the deviec itself or from a remote
if matches(&message.topic, &self.config.mqtt.topic) {