Skip to content

Commit 314d88f

Browse files
authored
Merge branch 'main' into dependabot/pip/dot-github/workflows/pyupgrade-3.15.1
2 parents bfbf886 + 3ac7db6 commit 314d88f

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

custom_components/ocpp/api.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,23 @@ async def handle_set_charge_rate(call):
478478

479479
accepted_measurands = ",".join(accepted_measurands)
480480

481-
_LOGGER.debug(f"'{self.id}' allowed measurands '{accepted_measurands}'")
481+
if len(accepted_measurands) > 0:
482+
_LOGGER.debug(f"'{self.id}' allowed measurands '{accepted_measurands}'")
483+
await self.configure(
484+
ckey.meter_values_sampled_data.value,
485+
accepted_measurands,
486+
)
487+
else:
488+
_LOGGER.debug(f"'{self.id}' measurands not configurable by OCPP")
489+
resp = await self.get_configuration(
490+
ckey.meter_values_sampled_data.value
491+
)
492+
accepted_measurands = resp
493+
_LOGGER.debug(f"'{self.id}' allowed measurands '{accepted_measurands}'")
482494

483-
await self.configure(
484-
ckey.meter_values_sampled_data.value,
485-
accepted_measurands,
486-
)
495+
updated_entry = {**self.entry.data}
496+
updated_entry[CONF_MONITORED_VARIABLES] = accepted_measurands
497+
self.hass.config_entries.async_update_entry(self.entry, data=updated_entry)
487498

488499
await self.configure(
489500
ckey.meter_value_sample_interval.value,

0 commit comments

Comments
 (0)