1- import { describe , expect , test } from "vitest" ;
1+ import { describe , expect , test , vi } from "vitest" ;
22import { Zcl } from "zigbee-herdsman" ;
33import { findByDevice , generateExternalDefinitionSource } from "../src" ;
44import * as fz from "../src/converters/fromZigbee" ;
@@ -203,9 +203,11 @@ export default {
203203 test ( "input(genOnOff, lightingColorCtrl)" , async ( ) => {
204204 const attributes = {
205205 lightingColorCtrl : {
206- colorCapabilities : 254 ,
207- colorTempPhysicalMin : 100 ,
208- colorTempPhysicalMax : 500 ,
206+ attributes : {
207+ colorCapabilities : 254 ,
208+ colorTempPhysicalMin : 100 ,
209+ colorTempPhysicalMax : 500 ,
210+ } ,
209211 } ,
210212 } ;
211213
@@ -271,9 +273,11 @@ export default {
271273 test ( "light with color and color temperature" , async ( ) => {
272274 const attributes = {
273275 lightingColorCtrl : {
274- colorCapabilities : 254 ,
275- colorTempPhysicalMin : 100 ,
276- colorTempPhysicalMax : 500 ,
276+ attributes : {
277+ colorCapabilities : 254 ,
278+ colorTempPhysicalMin : 100 ,
279+ colorTempPhysicalMax : 500 ,
280+ } ,
277281 } ,
278282 } ;
279283
@@ -339,9 +343,11 @@ export default {
339343 test ( "Philips light with color and color temperature" , async ( ) => {
340344 const attributes = {
341345 lightingColorCtrl : {
342- colorCapabilities : 254 ,
343- colorTempPhysicalMin : 100 ,
344- colorTempPhysicalMax : 500 ,
346+ attributes : {
347+ colorCapabilities : 254 ,
348+ colorTempPhysicalMin : 100 ,
349+ colorTempPhysicalMax : 500 ,
350+ } ,
345351 } ,
346352 } ;
347353
@@ -413,16 +419,20 @@ export default {
413419 test ( "Electricity meter" , async ( ) => {
414420 const attributes = {
415421 haElectricalMeasurement : {
416- acPowerDivisor : 1000 ,
417- acPowerMultiplier : 1 ,
418- acCurrentDivisor : 1000 ,
419- acCurrentMultiplier : 1 ,
420- acVoltageDivisor : 1000 ,
421- acVoltageMultiplier : 1 ,
422+ attributes : {
423+ acPowerDivisor : 1000 ,
424+ acPowerMultiplier : 1 ,
425+ acCurrentDivisor : 1000 ,
426+ acCurrentMultiplier : 1 ,
427+ acVoltageDivisor : 1000 ,
428+ acVoltageMultiplier : 1 ,
429+ } ,
422430 } ,
423431 seMetering : {
424- divisor : 1000 ,
425- multiplier : 1 ,
432+ attributes : {
433+ divisor : 1000 ,
434+ multiplier : 1 ,
435+ } ,
426436 } ,
427437 } ;
428438
@@ -490,13 +500,15 @@ export default {
490500 test ( "Electricity DC meter" , async ( ) => {
491501 const attributes = {
492502 haElectricalMeasurement : {
493- measurementType : 1 << 6 ,
494- dcPowerDivisor : 10000 ,
495- dcPowerMultiplier : 1 ,
496- dcCurrentDivisor : 1000 ,
497- dcCurrentMultiplier : 1 ,
498- dcVoltageDivisor : 100 ,
499- dcVoltageMultiplier : 1 ,
503+ attributes : {
504+ measurementType : 1 << 6 ,
505+ dcPowerDivisor : 10000 ,
506+ dcPowerMultiplier : 1 ,
507+ dcCurrentDivisor : 1000 ,
508+ dcCurrentMultiplier : 1 ,
509+ dcVoltageDivisor : 100 ,
510+ dcVoltageMultiplier : 1 ,
511+ } ,
500512 } ,
501513 } ;
502514
@@ -548,24 +560,34 @@ export default {
548560 test ( "input(genBinaryInput), output(genBinaryOutput, genAnalogOutput)" , async ( ) => {
549561 const attr10 = {
550562 genBinaryInput : {
551- description : "my_binary_name" ,
563+ attributes : {
564+ description : "my_binary_name" ,
565+ } ,
552566 } ,
553567 genAnalogOutput : {
554- description : "my_output_name" ,
555- applicationType : 0 ,
556- engineeringUnits : 62 ,
557- minPresentValue : 0.0 ,
558- maxPresentValue : 30.0 ,
559- resolution : 0.1 ,
560- presentValue : 15.0 ,
568+ attributes : {
569+ description : "my_output_name" ,
570+ applicationType : 0 ,
571+ engineeringUnits : 62 ,
572+ minPresentValue : 0.0 ,
573+ maxPresentValue : 30.0 ,
574+ resolution : 0.1 ,
575+ presentValue : 15.0 ,
576+ } ,
561577 } ,
562578 } ;
563579
564580 await assertGeneratedDefinition ( {
565581 device : mockDevice ( {
566582 modelID : "temp" ,
567583 endpoints : [
568- { ID : 10 , inputClusters : [ "genBinaryInput" , "genBinaryOutput" , "genAnalogOutput" ] , outputClusters : [ ] , attributes : attr10 } ,
584+ {
585+ ID : 10 ,
586+ inputClusters : [ "genBinaryInput" , "genBinaryOutput" , "genAnalogOutput" ] ,
587+ outputClusters : [ ] ,
588+ attributes : attr10 ,
589+ read : vi . fn ( async ( ) => Promise . reject ( new Error ( "use-fallback" ) ) ) ,
590+ } ,
569591 ] ,
570592 } ) ,
571593 meta : undefined ,
@@ -599,13 +621,15 @@ export default {
599621 test ( "input(genAnalogInput), x2 endpoints" , async ( ) => {
600622 const attr10 = {
601623 genAnalogInput : {
602- description : "my_custom_name" ,
603- applicationType : 0 ,
604- engineeringUnits : 62 ,
605- minPresentValue : 0.0 ,
606- maxPresentValue : 30.0 ,
607- resolution : 0.1 ,
608- presentValue : 15.0 ,
624+ attributes : {
625+ description : "my_custom_name" ,
626+ applicationType : 0 ,
627+ engineeringUnits : 62 ,
628+ minPresentValue : 0.0 ,
629+ maxPresentValue : 30.0 ,
630+ resolution : 0.1 ,
631+ presentValue : 15.0 ,
632+ } ,
609633 } ,
610634 } ;
611635
@@ -614,7 +638,12 @@ export default {
614638 modelID : "temp" ,
615639 endpoints : [
616640 { ID : 10 , inputClusters : [ "genAnalogInput" ] , outputClusters : [ ] , attributes : attr10 } ,
617- { ID : 11 , inputClusters : [ "genAnalogInput" ] , outputClusters : [ ] } ,
641+ {
642+ ID : 11 ,
643+ inputClusters : [ "genAnalogInput" ] ,
644+ outputClusters : [ ] ,
645+ read : vi . fn ( async ( ) => Promise . reject ( new Error ( "use-fallback" ) ) ) ,
646+ } ,
618647 ] ,
619648 } ) ,
620649 meta : { multiEndpoint : true } ,
0 commit comments