import type Bulb from '.' ; import Schedule , { createScheduleRule , ScheduleRule } from '../shared/schedule' ; import type { ScheduleRuleInputTime } from '../shared/schedule' ; import type { LightState } from './lighting' ; import type { SendOptions } from '../client' ; export type BulbScheduleRule = Omit < ScheduleRule , 'emin' > & { s_light : LightState ; sact : 2 ; emin : - 1 ; etime_opt : - 1 ; } ; export interface BulbScheduleRuleInput { lightState : LightState ; /**
     * Date or number of minutes
     */ start : ScheduleRuleInputTime ; /**
     * [0,6] = weekend, [1,2,3,4,5] = weekdays
     */ daysOfWeek ? : number [ ] ; defaultValue name : string ; defaultValue enable : boolean ; } export default class BulbSchedule extends Schedule { constructor ( readonly device , readonly apiModuleName , readonly childId ? ) { super ( device , apiModuleName , childId ) ; } returns throws ResponseError async addRule ( rule , sendOptions ? ) { const { lightState , start , daysOfWeek , name = '' , enable = true } = rule ; const scheduleRule = { s_light : lightState , name , enable : enable ? 1 : 0 , sact : 2 , emin : - 1 , etime_opt : - 1 , ... createScheduleRule ( { start , daysOfWeek } ) , } ; return super . addRule ( scheduleRule , sendOptions ) ; } returns throws ResponseError async editRule ( rule , sendOptions ? ) { const { id , lightState , start , daysOfWeek , name = '' , enable = true , } = rule ; const scheduleRule = { id , s_light : lightState , name , enable : enable ? 1 : 0 , sact : 2 , emin : - 1 , etime_opt : - 1 , ... createScheduleRule ( { start , daysOfWeek } ) , } ; return super . editRule ( scheduleRule , sendOptions ) ; } }