import * as Sentry from "@sentry/node" ; import { CommandClasses } from "@zwave-js/core" ; import { formatId } from "@zwave-js/shared" ; import { isObject } from "alcalzone-shared/typeguards" ; import axios from "axios" ; import { AssociationGroupInfoCC , ConfigurationCC } from "../commandclass" ; import type { ZWaveNode } from "../node/Node" ; const missingDeviceConfigCache = new Set < string > ( ) ; export async function reportMissingDeviceConfig ( node ) { const configFingerprint = `${ formatId ( node . manufacturerId ) }:${ formatId ( node . productType ) }:${ formatId ( node . productId ) }:${ node . firmwareVersion }` ; if ( missingDeviceConfigCache . has ( configFingerprint ) ) return ; try { const { data } = await axios . get ( `https://devices.zwave-js.io/public_api/getdeviceinfo/${ configFingerprint . replace ( /:/g , "/" ) }` ) ; if ( isObject ( data ) && typeof data . deviceFound === "boolean" && data . deviceFound ) { missingDeviceConfigCache . add ( configFingerprint ) ; return ; } } catch ( e ) { return ; } const message = `Missing device config: ${ configFingerprint }` ; const deviceInfo = { supportsConfigCCV3 : node . getCCVersion ( CommandClasses . Configuration ) >= 3 , supportsAGI : node . supportsCC ( CommandClasses [ "Association Group Information" ] ) , supportsZWavePlus : node . supportsCC ( CommandClasses [ "Z-Wave Plus Info" ] ) } ; try { if ( deviceInfo . supportsConfigCCV3 ) { const instance = node . createCCInstanceUnsafe ( ConfigurationCC ) ! ; deviceInfo . parameters = instance . getQueriedParamInfos ( ) ; } if ( deviceInfo . supportsAGI ) { const instance = node . createCCInstanceUnsafe ( AssociationGroupInfoCC ) ! ; const associationGroupCount = instance [ "getAssociationGroupCountCached" ] ( ) ; const names = [ ] ; for ( let group = 1 ; group <= associationGroupCount ; group ++ ) { names . push ( instance . getGroupNameCached ( group ) ?? "" ) ; } deviceInfo . associationGroups = names ; } if ( deviceInfo . supportsZWavePlus ) { deviceInfo . zWavePlusVersion = node . zwavePlusVersion ; } } catch { } Sentry . captureMessage ( message , ( scope ) => { scope . clearBreadcrumbs ( ) ; scope . setFingerprint ( [ configFingerprint ] ) ; scope . setExtras ( deviceInfo ) ; return scope ; } ) ; missingDeviceConfigCache . add ( configFingerprint ) ; }