feat: add Z-Wave network scan via MQTT gateway
Import a Z-Wave JS UI (zwavejs2mqtt) network over the MQTT gateway API, mirroring the existing Zigbee pipeline: - New Z-Wave Import modal + sidebar entry (broker, prefix, gateway name) - coordinator/router/end-device typing with mesh tree from node neighbors - import to Pending section or straight to canvas - Pending Devices gains a Z-Wave source filter - shared mqtt_common helpers extracted from the zigbee service ha-relevant: yes
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { isZwaveType, buildZwaveProperties } from '../zwaveProperties'
|
||||
|
||||
describe('isZwaveType', () => {
|
||||
it('returns true for zwave types', () => {
|
||||
expect(isZwaveType('zwave_coordinator')).toBe(true)
|
||||
expect(isZwaveType('zwave_router')).toBe(true)
|
||||
expect(isZwaveType('zwave_enddevice')).toBe(true)
|
||||
})
|
||||
|
||||
it('returns false for non-zwave types', () => {
|
||||
expect(isZwaveType('zigbee_router')).toBe(false)
|
||||
expect(isZwaveType('server')).toBe(false)
|
||||
expect(isZwaveType(undefined)).toBe(false)
|
||||
expect(isZwaveType(null)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildZwaveProperties', () => {
|
||||
it('builds Z-Wave ID / Vendor / Model rows, all hidden', () => {
|
||||
const props = buildZwaveProperties({ ieee_address: 'zwave-0xh-2', vendor: 'Aeotec', model: 'ZW100' })
|
||||
expect(props).toEqual([
|
||||
{ key: 'Z-Wave ID', value: 'zwave-0xh-2', icon: null, visible: false },
|
||||
{ key: 'Vendor', value: 'Aeotec', icon: null, visible: false },
|
||||
{ key: 'Model', value: 'ZW100', icon: null, visible: false },
|
||||
])
|
||||
})
|
||||
|
||||
it('omits empty fields', () => {
|
||||
const props = buildZwaveProperties({ ieee_address: 'zwave-0xh-2', vendor: null, model: undefined })
|
||||
expect(props.map((p) => p.key)).toEqual(['Z-Wave ID'])
|
||||
})
|
||||
|
||||
it('never adds an LQI row', () => {
|
||||
const props = buildZwaveProperties({ ieee_address: 'x', vendor: 'v', model: 'm' })
|
||||
expect(props.some((p) => p.key === 'LQI')).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user