Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions custom_components/ocpp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,33 +464,36 @@ async def handle_set_charge_rate(call):
all_measurands = self.entry.data.get(
CONF_MONITORED_VARIABLES, DEFAULT_MEASURAND
)
key = ckey.meter_values_sampled_data.value
chgr_measurands = await self.get_configuration(key)

accepted_measurands = []
key = ckey.meter_values_sampled_data.value
cfg_ok = [
ConfigurationStatus.accepted,
ConfigurationStatus.reboot_required,
]

for measurand in all_measurands.split(","):
_LOGGER.debug(f"'{self.id}' trying measurand '{measurand}'")
_LOGGER.debug(f"'{self.id}' trying measurand: '{measurand}'")
req = call.ChangeConfiguration(key=key, value=measurand)
resp = await self.call(req)
if resp.status == ConfigurationStatus.accepted:
_LOGGER.debug(f"'{self.id}' adding measurand '{measurand}'")
if resp.status in cfg_ok:
_LOGGER.debug(f"'{self.id}' adding measurand: '{measurand}'")
accepted_measurands.append(measurand)

accepted_measurands = ",".join(accepted_measurands)

if len(accepted_measurands) > 0:
_LOGGER.debug(f"'{self.id}' allowed measurands '{accepted_measurands}'")
_LOGGER.debug(
f"'{self.id}' allowed measurands: '{accepted_measurands}'"
)
await self.configure(
ckey.meter_values_sampled_data.value,
accepted_measurands,
)
else:
_LOGGER.debug(f"'{self.id}' measurands not configurable by OCPP")
resp = await self.get_configuration(
ckey.meter_values_sampled_data.value
)
accepted_measurands = resp
_LOGGER.debug(f"'{self.id}' allowed measurands '{accepted_measurands}'")
_LOGGER.debug(f"'{self.id}' measurands not configurable by integration")
_LOGGER.debug(f"'{self.id}' allowed measurands: '{chgr_measurands}'")

updated_entry = {**self.entry.data}
updated_entry[CONF_MONITORED_VARIABLES] = accepted_measurands
Expand Down