Closed grzegorz914 closed 4 years ago
Hi, after some test Your code not fixed #43, fixed only #13. With Your code send value 100 or 0/OFF, with my code send ON/100 and 0/OFF always. If U look on my rule the state ON enabled light and set to the latest state of brightness(value 100 is ignored), with Your code the light is enabled with 100% of brightness always, because You do not send ON command if value is 100.
Check this code please:
this._log.debug(`Committing light state with vectors (B,H,S,B): ${binary},${hue},${saturation},${brightness}`);
if(binary === undefined && hue === undefined && saturation === undefined && brightness === undefined) {
command = new Error("Unable to commit state, since necessary information are missing");
} else if (hue === undefined && saturation === undefined && brightness === undefined) {
command = binary ? "ON" : "OFF";
} else if (hue === undefined && saturation === undefined) {
if(binary && (brightness === 0 || brightness === 100)) { // For some reaason when invoking Siri to turn on a light brightness is sometimes set to '0'
command = "ON";
} else {
command = binary ? `${brightness}` : "OFF";
}
} else {
if(binary && (brightness === 0 || brightness === 100)) { // For some reaason when invoking Siri to turn on a light brightness is sometimes set to '0'
command = "ON";
} else {
command = binary ? `${hue},${saturation},${brightness}` : "OFF";
}
}
}
return command;
Hi, this fixed issue #13 and #43 Tested with HomeKit app and Siri.
Rule in OH2:
Command - HomeKit app:
Press button - switch ON the light:
Update brightness to the last state:
Change brightness using dimer:
Press button - switch OFF the light:
Command - Siri:
Siri switch ON the light:
Update the brightness to the last state:
Siri set the light to 20%:
Siri switch OFF the light: