Fritz: make unit 1-based (BC) (#29741)

This commit is contained in:
andig 2026-05-08 09:20:51 +02:00 • committed by GitHub
parent 7303a5b476
commit 2b16c415bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 9 additions and 3 deletions

View file

@ -88,10 +88,10 @@ func (c *Connection) resolveUnitUID(unit int) (string, error) {
if d.AIN != c.AIN { if d.AIN != c.AIN {
continue continue
} }
if len(d.UnitUids) < unit+1 { if len(d.UnitUids) < unit {
return "", fmt.Errorf("invalid unit %d, got %v", unit, d.UnitUids) return "", fmt.Errorf("invalid unit %d, got %v", unit, d.UnitUids)
} }
return d.UnitUids[unit], nil return d.UnitUids[unit-1], nil
} }
return "", fmt.Errorf("ain not found: %s", c.AIN) return "", fmt.Errorf("ain not found: %s", c.AIN)

View file

@ -18,7 +18,10 @@ func init() {
// NewFritzDECTFromConfig creates a fritzdect meter from generic config // NewFritzDECTFromConfig creates a fritzdect meter from generic config
func NewFritzDECTFromConfig(other map[string]any) (api.Meter, error) { func NewFritzDECTFromConfig(other map[string]any) (api.Meter, error) {
var cc fritz.Settings cc := fritz.Settings{
Unit: 1,
}
if err := util.DecodeOther(other, &cc); err != nil { if err := util.DecodeOther(other, &cc); err != nil {
return nil, err return nil, err
} }

View file

@ -39,6 +39,7 @@ params:
- name: unit - name: unit
advanced: true advanced: true
type: int type: int
default: 1
description: description:
de: Einheit de: Einheit
en: Unit en: Unit

View file

@ -40,6 +40,7 @@ params:
- name: unit - name: unit
advanced: true advanced: true
type: int type: int
default: 1
description: description:
de: Einheit de: Einheit
en: Unit en: Unit

View file

@ -18,6 +18,7 @@ params:
- name: unit - name: unit
advanced: true advanced: true
type: int type: int
default: 1
description: description:
de: Einheit de: Einheit
en: Unit en: Unit