Files
integrations/test/yeelight/test.yeelight.mapper.node.ts

41 lines
1.2 KiB
TypeScript

import { expect, tap } from '@git.zone/tstest/tapbundle';
import { YeelightMapper } from '../../ts/integrations/yeelight/index.js';
const snapshot = {
connected: true,
bulbs: [
{
id: '0x0000000002eb9f61',
host: '192.168.1.25',
port: 55443,
name: 'Kitchen Bulb',
model: 'color',
support: ['get_prop', 'set_power', 'set_bright', 'set_rgb', 'set_ct_abx'],
available: true,
properties: {
power: 'on',
bright: '80',
ct: '3700',
rgb: '16711680',
hue: '0',
sat: '100',
color_mode: '1',
flowing: '0',
nl_br: '0',
},
},
],
events: [],
};
tap.test('maps Yeelight bulbs to canonical devices and light/sensor entities', async () => {
const devices = YeelightMapper.toDevices(snapshot);
const entities = YeelightMapper.toEntities(snapshot);
expect(devices[0].id).toEqual('yeelight.bulb.0x0000000002eb9f61');
expect(devices[0].features.some((featureArg) => featureArg.id === 'color_temperature')).toBeTrue();
expect(entities[0].id).toEqual('light.kitchen_bulb');
expect(entities.some((entityArg) => entityArg.id === 'sensor.kitchen_bulb_color_temperature')).toBeTrue();
});
export default tap.start();