mirror of
https://github.com/nikdoof/hapz2m.git
synced 2026-01-30 03:28:18 +00:00
Only process EndDevices during add and more verbose errors
If a Coordinator is present in the device list, AddDevicesFromJSON will fail catastrophically, which shouldn't happen. Therefore, make sure only EndDevices are considered during add. Also updated the tests to check for this. Added a device descriptor for failed adds. This will help with identifying which device failed (and perhaps, why).
This commit is contained in:
15
z2m.go
15
z2m.go
@@ -76,7 +76,8 @@ func initExposeMappings(exposes ...*ExposeMapping) error {
|
||||
func createAccessory(dev *Device) (*accessory.A, []*ExposeMapping, error) {
|
||||
if dev.Disabled ||
|
||||
!dev.Supported ||
|
||||
!dev.InterviewCompleted {
|
||||
!dev.InterviewCompleted ||
|
||||
dev.Type != "EndDevice" {
|
||||
return nil, nil, ErrDeviceSkipped
|
||||
}
|
||||
|
||||
@@ -278,14 +279,14 @@ type Device struct {
|
||||
IEEEAddress string `json:"ieee_address"`
|
||||
InterviewCompleted bool `json:"interview_completed"`
|
||||
Interviewing bool `json:"interviewing"`
|
||||
Manufacturer string `json:"manufacturer"`
|
||||
ModelId string `json:"model_id"`
|
||||
Manufacturer string `json:"manufacturer,omitempty"`
|
||||
ModelId string `json:"model_id,omitempty"`
|
||||
NetworkAddress int `json:"network_address"`
|
||||
PowerSource string `json:"power_source"`
|
||||
SoftwareBuildId string `json:"software_build_id"`
|
||||
DateCode string `json:"date_code"`
|
||||
PowerSource string `json:"power_source,omitempty"`
|
||||
SoftwareBuildId string `json:"software_build_id,omitempty"`
|
||||
DateCode string `json:"date_code,omitempty"`
|
||||
|
||||
Definition *DevDefinition `json:"definition"`
|
||||
Definition *DevDefinition `json:"definition,omitempty"`
|
||||
|
||||
Disabled bool `json:"disabled"`
|
||||
Supported bool `json:"supported"`
|
||||
|
||||
Reference in New Issue
Block a user