kellerza / pysma

Async library for SMA Solar's WebConnect interface
MIT License
59 stars 51 forks source link

Remove duplicate sensor keys #52

Closed rklomp closed 3 years ago

rklomp commented 3 years ago

idx is stored as a sting, so default should be string too. Two sensors removed to make test pass again.

kellerza commented 3 years ago

Hi @rklomp - are these creating issues? I doubt this is duplicates, it is just sensors without an additional relay.

I'm pretty sure my Sunnyboy 1.5 used these. What inverter do you use? The keys vary quite a lot between inverter models and I would not want to change these too much

rklomp commented 3 years ago

6380_40451F00 and 6380_40451F00_0 are the same key.

6380_40451F00 will be stored with key="6380_40451F00" and key_idx=0 (as integer) 6380_40451F00_0 will be stored with key="6380_40451F00" and key_idx="0" (as string)

The is statement at line 187 will evaluate False because the comparison would be 0 is "0" https://github.com/kellerza/pysma/blob/a341e81cb4c2ba28660b9bb96457a02c95db30ff/pysma/__init__.py#L187

Storing the default idx as string will fix this and evaluate True because the comparison would be "0" is "0"