You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, would it be possible to modify the night/daylight function so that when I change this switch on the light, the light does not turn on? It just toggles the switch, without any further action.
For example:
params: ["on", "smooth", transition, state ? 1 : 0]
async setMoonlightMode(state) {
// Get transition time from config or use default 400ms
const { brightness: transition = 400 } = this.config.transitions || {};
// Log the mode change operation
this.log.debug( Setting ${state ? 'moon' : 'day'}light mode on device ${this.did}
);
// Get current power state of the light
const [power] = await this.getProperty(['power']);
const isOn = power === 'on';
// Only send power command if the light is currently on
// This prevents the light from turning on when we just want to change the mode
if (isOn) {
await this.sendCmd({
method: 'set_power',
params: [
'on', // power state
'smooth', // effect type
transition, // transition duration in ms
state ? 1 : 0 // 1 for moonlight mode, 0 for daylight mode
],
});
}
// Store the active mode regardless of power state
// This ensures the correct mode is remembered when turning on next time
this.activeMode = state ? MOONLIGHT_MODE : DAYLIGHT_MODE;
// Log the result
this.log.debug( Mode set to ${state ? 'moonlight' : 'daylight'}, light was ${isOn ? 'on' : 'off'}
);
}
This function will:
Change the mode without turning on the light if it's currently off
Change the mode and keep the light on if it's currently on
Remember the last mode setting for next time the light is turned on
Use proper mode values (1 for moonlight, 0 for daylight) as per Yeelight specification
Provide detailed debug logging
Thanks...
The text was updated successfully, but these errors were encountered:
Hi, would it be possible to modify the night/daylight function so that when I change this switch on the light, the light does not turn on? It just toggles the switch, without any further action.
For example:
params: ["on", "smooth", transition, state ? 1 : 0]
async setMoonlightMode(state) {
// Get transition time from config or use default 400ms
const { brightness: transition = 400 } = this.config.transitions || {};
// Log the mode change operation
this.log.debug(
Setting ${state ? 'moon' : 'day'}light mode on device ${this.did}
);
// Get current power state of the light
const [power] = await this.getProperty(['power']);
const isOn = power === 'on';
// Only send power command if the light is currently on
// This prevents the light from turning on when we just want to change the mode
if (isOn) {
await this.sendCmd({
method: 'set_power',
params: [
'on', // power state
'smooth', // effect type
transition, // transition duration in ms
state ? 1 : 0 // 1 for moonlight mode, 0 for daylight mode
],
});
}
// Store the active mode regardless of power state
// This ensures the correct mode is remembered when turning on next time
this.activeMode = state ? MOONLIGHT_MODE : DAYLIGHT_MODE;
// Log the result
this.log.debug(
Mode set to ${state ? 'moonlight' : 'daylight'}, light was ${isOn ? 'on' : 'off'}
);
}
This function will:
Change the mode without turning on the light if it's currently off
Change the mode and keep the light on if it's currently on
Remember the last mode setting for next time the light is turned on
Use proper mode values (1 for moonlight, 0 for daylight) as per Yeelight specification
Provide detailed debug logging
Thanks...
The text was updated successfully, but these errors were encountered: