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