mavenius / renogy-bt-esphome

ESPHome implementation to pull data from BT-enabled Renogy devices
5 stars 2 forks source link

Update HandleBatteryData to use dynamic Ids #2

Closed mavenius closed 3 months ago

mavenius commented 3 months ago

Currently, HandleBatteryData has a hard-coded switch statement to update entities for battery Ids 48, 49, and 50. See if we can make this dynamic.

id("some_string") is not supported by esphome, and id(someid${batteryNumber}_value) doesn't compile either. Maybe this can be done with a preprocessor? Or there could be a way to use sensors[i] to loop through all available sensors and find the correct one by string id or name.

https://community.home-assistant.io/t/get-lambda-id-component-name-from-variable/560943/6