diff --git a/bridge.go b/bridge.go index fd54d85..31cc589 100644 --- a/bridge.go +++ b/bridge.go @@ -393,7 +393,7 @@ func (br *Bridge) AddDevicesFromJSON(devJson []byte) error { acc, exp, err := createAccessory(&dev) if err != nil { - if err == ErrDeviceSkipped { + if err == ErrDeviceSkipped || err == ErrUnknownDeviceType { continue } return err diff --git a/z2m.go b/z2m.go index 7aeaa86..b16f24c 100644 --- a/z2m.go +++ b/z2m.go @@ -23,8 +23,9 @@ var IgnoreProperties = map[string]bool{ } var ( - ErrDeviceSkipped = fmt.Errorf("device is skipped") - ErrMalfomedDevice = fmt.Errorf("device is malformed") + ErrDeviceSkipped = fmt.Errorf("device is skipped") + ErrMalfomedDevice = fmt.Errorf("device is malformed") + ErrUnknownDeviceType = fmt.Errorf("device type is unknown") ErrNotNumericCharacteristic = fmt.Errorf("characteristic is non-numeric") ) @@ -119,6 +120,11 @@ func createAccessory(dev *Device) (*accessory.A, []*ExposeMapping, error) { allExposes = append(allExposes, exposes...) } + // if no Exposes entry was processed, return error + if len(allExposes) == 0 { + return nil, nil, ErrUnknownDeviceType + } + // copy value ranges for _, e := range allExposes { if e.ExposesEntry.Type != "numeric" { @@ -316,6 +322,7 @@ func (m *ExposeMapping) ToExposedValue(v any) (any, error) { expVal = m.ExposesEntry.ValueOn } } + return expVal, err }