Skip to content

Commit

Permalink
Merge pull request #187 from fboundy/dev
Browse files Browse the repository at this point in the history
Move `set_select` to main module
  • Loading branch information
fboundy authored Mar 28, 2024
2 parents 2796b42 + 2711f82 commit 80cd703
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 7 additions & 0 deletions apps/pv_opt/pv_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2355,5 +2355,12 @@ def write_and_poll_value(self, entity_id, value, tolerance=0.0, verbose=False):

return (changed, written)

def set_select(self, item, state):
if state is not None:
entity_id = self.config[f"id_{item}"]
if self.get_state(entity_id=entity_id) != state:
self.call_service("select/select_option", entity_id=entity_id, option=state)
self.rlog(f"Setting {entity_id} to {state}")


# %%
5 changes: 1 addition & 4 deletions apps/pv_opt/solis.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,7 @@ def _solis_set_mode_switch(self, **kwargs):
self.log(f">>> Modes: {modes}")
self.log(f">>> Inverter Mode: {mode}")

if mode is not None:
if self.host.get_state(entity_id=entity_id) != mode:
self.host.call_service("select/select_option", entity_id=entity_id, option=mode)
self.log(f"Setting {entity_id} to {mode}")
self.host.set_select("inverter_mode", mode)

elif self.type == "SOLIS_CORE_MODBUS" or self.type == "SOLIS_SOLARMAN":
address = INVERTER_DEFS[self.type]["registers"]["storage_control_switch"]
Expand Down

0 comments on commit 80cd703

Please sign in to comment.