import { Device } from './yeelight.device' import { YEELIGHT_COMMAND, YEELIGHT_PROPERTY, YEELIGHT_VALUE } from './yeelight.constant' import { sleep } from '../utils' const info = { location: 'yeelight://192.168.1.218:55443', id: '0x00000000124f9c93', model: 'ceiling10', support: 'get_prop set_default set_power toggle set_bright set_scene cron_add cron_get cron_del start_cf stop_cf set_ct_abx set_name set_adjust adjust_bright adjust_ct bg_set_rgb bg_set_hsv bg_set_ct_abx bg_start_cf bg_stop_cf set_scene_bundle bg_set_default bg_set_power bg_set_bright bg_set_adjust bg_adjust_bright bg_adjust_color bg_adjust_ct bg_toggle dev_toggle', power: true, bright: 100, color_mode: 2, ct: 3300, rgb: '0', hue: 0, sat: 0, host: '192.168.1.218', port: 55443, debug: false, trackedAttributes: [], fw_ver: '49', name: '', 'cache-control': 'max-age=3600', date: '', ext: '', server: 'POSIX UPnP/1.0 YGLC/1' } ;(async () => { const device = new Device({ identify: { name: '测试', address: info.host } }) // @ts-ignore console.log(await device.getProperty()) // @ts-ignore device.debouncedGetProperty().then(console.log) // @ts-ignore await device.setProperty(YEELIGHT_COMMAND.SetPower, YEELIGHT_VALUE[YEELIGHT_PROPERTY.power].POWER_OFF) await sleep(2000) // @ts-ignore await device.setProperty(YEELIGHT_COMMAND.SetPower, YEELIGHT_VALUE[YEELIGHT_PROPERTY.power].POWER_ON) })() // const discovery = new Discovery([info]) // discovery.on(YEELIGHT_EVENT.DISCOVERED, async (info: YeelightDeviceInfo) => { // const device = new Device({ identify: info }) // await device.getProp() // // await device.sendCommand('bg_set_power', ['off', 'smooth', 500]) // // await sleep(500) // // await device.sendCommand('bg_set_power', ['on', 'smooth', 500]) // // console.log(await device.sendCommand('get_prop', YEELIGHT_PROPERTIES)) // // await device.sendCommand('set_power', ['on', 'smooth', 500]) // // await device.sendCommand('set_power', ['off', 'smooth', 500]) // }) // discovery.search()