FaserF / ha-deutschebahn

Unofficial HA DB Integration, due to removal as of Home Assistant 2022.11
Apache License 2.0
40 stars 7 forks source link

Update sensor.py #28

Closed M-See closed 6 months ago

M-See commented 6 months ago

small refactorization of attribute setting

I´m not a 100% convinced of this solution, but it´s more flexible like this. Especially for attributes that can then be read in to Lovelace-cards like Connection_card. Maybe it´s worth finding a better name, but now i changed the attributes name "Next on" to "Next 1" etc.

It´s up to you to decide on this change.

Alternatively, one could have manually inserted the following to make the "arrival" attribute available quickly:

connections["next_arrival"] = self.connections[1]["arrival"]

But with the proposed solution is automatically set for all connections directly.

Related Issues

FaserF commented 6 months ago

Thanks, this definitly is a better way than before!