async initAttributeEntities() {
         // If device is wireless publish signal strength entity
        const deviceHealth = await this.device.getHealth()
        if (deviceHealth && !(deviceHealth.hasOwnProperty('network_connection') && deviceHealth.network_connection === 'ethernet')) {
            this.entity.wireless = {
                component: 'sensor',
                device_class: 'signal_strength',
                unit_of_measurement: 'dBm',
                parent_state_topic: 'info/state',
                attributes: 'wireless',
                value_template: '{{ value_json["wirelessSignal"] | default }}'
            }
        }

        // If device is battery powered publish battery entity
        if (this.device.hasBattery) {
            this.entity.battery = {
                component: 'sensor',
                device_class: 'battery',
                unit_of_measurement: '%',
                state_class: 'measurement',
                parent_state_topic: 'info/state',
                attributes: 'battery',
                value_template: '{{ value_json["batteryLevel"] | default }}'
            }
        }

        // Update motion properties with most recent historical event data
        const lastMotionEvent = (await this.device.getEvents({ limit: 1, kind: 'motion'})).events[0]
        const lastMotionDate = (lastMotionEvent && lastMotionEvent.hasOwnProperty('created_at')) ? new Date(lastMotionEvent.created_at) : false
        this.data.motion.last_ding = lastMotionDate ? Math.floor(lastMotionDate/1000) : 0
        this.data.motion.last_ding_time = lastMotionDate ? utils.getISOTime(lastMotionDate) : ''
        if (lastMotionEvent && lastMotionEvent.hasOwnProperty('cv_properties')) {
            this.data.motion.is_person = (lastMotionEvent.cv_properties.detection_type === 'human') ? true : false
        }

        // Update motion properties with most recent historical event data
        if (this.device.isDoorbot) {
            const lastDingEvent = (await this.device.getEvents({ limit: 1, kind: 'ding'})).events[0]
            const lastDingDate = (lastDingEvent && lastDingEvent.hasOwnProperty('created_at')) ? new Date(lastDingEvent.created_at) : false
            this.data.ding.last_ding = lastDingDate ? Math.floor(lastDingDate/1000) : 0
            this.data.ding.last_ding_time = lastDingDate ? utils.getISOTime(lastDingDate) : ''
        }
    }
// Build standard and optional entities for device
Build standard and optional entities for device
Build standard and optional entities for device
async initAttributeEntities() {
        const deviceHealth = await this.device.getHealth()
        if (deviceHealth && !(deviceHealth.hasOwnProperty('network_connection') && deviceHealth.network_connection === 'ethernet')) {
            this.entity.wireless = {
                component: 'sensor',
                device_class: 'signal_strength',
                unit_of_measurement: 'dBm',
                parent_state_topic: 'info/state',
                attributes: 'wireless',
                value_template: '{{ value_json["wirelessSignal"] | default }}'
            }
        }
        if (this.device.hasBattery) {
            this.entity.battery = {
                component: 'sensor',
                device_class: 'battery',
                unit_of_measurement: '%',
                state_class: 'measurement',
                parent_state_topic: 'info/state',
                attributes: 'battery',
                value_template: '{{ value_json["batteryLevel"] | default }}'
            }
        }
        const lastMotionEvent = (await this.device.getEvents({ limit: 1, kind: 'motion'})).events[0]
        const lastMotionDate = (lastMotionEvent && lastMotionEvent.hasOwnProperty('created_at')) ? new Date(lastMotionEvent.created_at) : false
        this.data.motion.last_ding = lastMotionDate ? Math.floor(lastMotionDate/1000) : 0
        this.data.motion.last_ding_time = lastMotionDate ? utils.getISOTime(lastMotionDate) : ''
        if (lastMotionEvent && lastMotionEvent.hasOwnProperty('cv_properties')) {
            this.data.motion.is_person = (lastMotionEvent.cv_properties.detection_type === 'human') ? true : false
        }
        if (this.device.isDoorbot) {
            const lastDingEvent = (await this.device.getEvents({ limit: 1, kind: 'ding'})).events[0]
            const lastDingDate = (lastDingEvent && lastDingEvent.hasOwnProperty('created_at')) ? new Date(lastDingEvent.created_at) : false
            this.data.ding.last_ding = lastDingDate ? Math.floor(lastDingDate/1000) : 0
            this.data.ding.last_ding_time = lastDingDate ? utils.getISOTime(lastDingDate) : ''
        }
    }
async initAttributeEntities ( ) { const deviceHealth = await this . device . getHealth ( ) if ( deviceHealth && ! ( deviceHealth . hasOwnProperty ( 'network_connection' ) && deviceHealth . network_connection === 'ethernet' ) ) { this . entity . wireless = { component : 'sensor' , device_class : 'signal_strength' , unit_of_measurement : 'dBm' , parent_state_topic : 'info/state' , attributes : 'wireless' , value_template : '{{ value_json["wirelessSignal"] | default }}' } } if ( this . device . hasBattery ) { this . entity . battery = { component : 'sensor' , device_class : 'battery' , unit_of_measurement : '%' , state_class : 'measurement' , parent_state_topic : 'info/state' , attributes : 'battery' , value_template : '{{ value_json["batteryLevel"] | default }}' } } const lastMotionEvent = ( await this . device . getEvents ( { limit : 1 , kind : 'motion' } ) ) . events [ 0 ] const lastMotionDate = ( lastMotionEvent && lastMotionEvent . hasOwnProperty ( 'created_at' ) ) ? new Date ( lastMotionEvent . created_at ) : false this . data . motion . last_ding = lastMotionDate ? Math . floor ( lastMotionDate / 1000 ) : 0 this . data . motion . last_ding_time = lastMotionDate ? utils . getISOTime ( lastMotionDate ) : '' if ( lastMotionEvent && lastMotionEvent . hasOwnProperty ( 'cv_properties' ) ) { this . data . motion . is_person = ( lastMotionEvent . cv_properties . detection_type === 'human' ) ? true : false } if ( this . device . isDoorbot ) { const lastDingEvent = ( await this . device . getEvents ( { limit : 1 , kind : 'ding' } ) ) . events [ 0 ] const lastDingDate = ( lastDingEvent && lastDingEvent . hasOwnProperty ( 'created_at' ) ) ? new Date ( lastDingEvent . created_at ) : false this . data . ding . last_ding = lastDingDate ? Math . floor ( lastDingDate / 1000 ) : 0 this . data . ding . last_ding_time = lastDingDate ? utils . getISOTime ( lastDingDate ) : '' } }
Build standard and optional entities for device
Build standard and optional entities for device
// If device is wireless publish signal strength entity // If device is battery powered publish battery entity // Update motion properties with most recent historical event data // Update motion properties with most recent historical event data