mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
Use brightness for dimmable lights
This commit is contained in:
parent
5b9d5f45e3
commit
3dadfa606d
@ -200,8 +200,9 @@ static void dispatch_output(const char* topic, const char* payload)
|
||||
return;
|
||||
}
|
||||
|
||||
JsonVariant state = json[F("state")];
|
||||
JsonVariant value = json[F("val")];
|
||||
JsonVariant state = json[F("state")];
|
||||
JsonVariant value = json[F("val")];
|
||||
JsonVariant brightness = json[F("brightness")];
|
||||
|
||||
// Check if the state needs to change
|
||||
if(!state.isNull() && power_state != state.as<bool>()) {
|
||||
@ -212,6 +213,9 @@ static void dispatch_output(const char* topic, const char* payload)
|
||||
if(!value.isNull() && state_value != value.as<int32_t>()) {
|
||||
state_value = value.as<int32_t>();
|
||||
updated = true;
|
||||
} else if(!brightness.isNull() && state_value != brightness.as<int32_t>()) {
|
||||
state_value = brightness.as<int32_t>();
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// Set new state
|
||||
|
@ -393,6 +393,12 @@ void gpio_output_state(hasp_gpio_config_t* gpio)
|
||||
case POWER_RELAY:
|
||||
snprintf_P(payload, sizeof(payload), PSTR("{\"state\":\"%s\"}"), statename);
|
||||
break;
|
||||
case LED:
|
||||
case SERIAL_DIMMER:
|
||||
case SERIAL_DIMMER_AU:
|
||||
case SERIAL_DIMMER_EU:
|
||||
snprintf_P(payload, sizeof(payload), PSTR("{\"state\":\"%s\",\"brightness\":%d}"), statename, gpio->val);
|
||||
break;
|
||||
default:
|
||||
snprintf_P(payload, sizeof(payload), PSTR("{\"state\":\"%s\",\"val\":%d}"), statename, gpio->val);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user