diff --git a/apps/predbat/inverter.py b/apps/predbat/inverter.py index 302d379a..8e5c4ef4 100644 --- a/apps/predbat/inverter.py +++ b/apps/predbat/inverter.py @@ -1732,8 +1732,7 @@ def adjust_force_export(self, force_export, new_start_time=None, new_end_time=No self.log("Warn: Inverter {} unable write export end time as neither REST or discharge_end_time are set".format(self.id)) if ((new_end != old_end) or (new_start != old_start)) and self.inv_time_button_press: - entity_id = self.base.get_arg("charge_discharge_update_button", indirect=False, index=self.id) - self.press_and_poll_button(entity_id) + self.press_and_poll_button() # REST version of writing slot if self.rest_data and new_start and new_end and ((new_start != old_start) or (new_end != old_end)): @@ -2093,8 +2092,7 @@ def adjust_charge_window(self, charge_start_time, charge_end_time, minutes_now): # For Solis inverters we also have to press the update_charge_discharge button to send the times to the inverter if self.inv_time_button_press: - entity_id = self.base.get_arg("charge_discharge_update_button", indirect=False, index=self.id) - self.press_and_poll_button(entity_id) + self.press_and_poll_button() if self.base.set_inverter_notify: self.base.call_notify("Predbat: Inverter {} Charge window change to: {} - {} at {}".format(self.id, new_start, new_end, self.base.time_now_str())) @@ -2125,6 +2123,10 @@ def press_and_poll_button(self, entity_id): """ Call a button press service (Solis) and wait for the data to update """ + entity_id = self.base.get_arg("charge_discharge_update_button", indirect=False, index=self.id) + if not entity_id: + return False + for retry in range(8): self.base.call_service_wrapper("button/press", entity_id=entity_id) time.sleep(self.inv_write_and_poll_sleep)