Skip to content

Commit

Permalink
wallbox_prohibit_usage is display ONLY (no switch any longer)
Browse files Browse the repository at this point in the history
  • Loading branch information
marq24 committed Jan 6, 2024
1 parent 4bc5e16 commit c63291e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 93 deletions.
81 changes: 41 additions & 40 deletions custom_components/senec/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,46 +545,6 @@ class ExtNumberEntityDescription(NumberEntityDescription):
icon="mdi:battery",
icon_off="mdi:battery-off",
),
ExtSwitchEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
array_key="wallbox_prohibit_usage",
array_pos=0,
inverted=True,
key="wallbox_1_prohibit_usage",
name="wallbox_1_prohibit_usage",
icon="mdi:toggle-switch",
),
ExtSwitchEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
array_key="wallbox_prohibit_usage",
array_pos=1,
inverted=True,
key="wallbox_2_prohibit_usage",
name="wallbox_2_prohibit_usage",
icon="mdi:toggle-switch",
),
ExtSwitchEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
array_key="wallbox_prohibit_usage",
array_pos=2,
inverted=True,
key="wallbox_3_prohibit_usage",
name="wallbox_3_prohibit_usage",
icon="mdi:toggle-switch",
),
ExtSwitchEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
array_key="wallbox_prohibit_usage",
array_pos=3,
inverted=True,
key="wallbox_4_prohibit_usage",
name="wallbox_4_prohibit_usage",
icon="mdi:toggle-switch",
),

# SOCKETS PERMANENT ON
ExtSwitchEntityDescription(
Expand Down Expand Up @@ -791,6 +751,47 @@ class ExtNumberEntityDescription(NumberEntityDescription):
icon_off="mdi:toggle-switch-off",
entity_category=EntityCategory.DIAGNOSTIC,
),
ExtBinarySensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
array_key="wallbox_prohibit_usage",
array_pos=0,
key="wallbox_1_prohibit_usage",
name="wallbox_1_prohibit_usage",
icon="mdi:toggle-switch",
icon_off="mdi:toggle-switch-off",
),
ExtBinarySensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
array_key="wallbox_prohibit_usage",
array_pos=1,
key="wallbox_2_prohibit_usage",
name="wallbox_2_prohibit_usage",
icon="mdi:toggle-switch",
icon_off="mdi:toggle-switch-off",
),
ExtBinarySensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
array_key="wallbox_prohibit_usage",
array_pos=2,
key="wallbox_3_prohibit_usage",
name="wallbox_3_prohibit_usage",
icon="mdi:toggle-switch",
icon_off="mdi:toggle-switch-off",
),

ExtBinarySensorEntityDescription(
senec_lala_section=SENEC_SECTION_WALLBOX,
entity_registry_enabled_default=False,
array_key="wallbox_prohibit_usage",
array_pos=3,
key="wallbox_4_prohibit_usage",
name="wallbox_4_prohibit_usage",
icon="mdi:toggle-switch",
icon_off="mdi:toggle-switch-off",
),
ExtBinarySensorEntityDescription(
senec_lala_section=SENEC_SECTION_FAN_SPEED,
entity_registry_enabled_default=False,
Expand Down
36 changes: 19 additions & 17 deletions custom_components/senec/pysenec_ha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,18 +1766,20 @@ async def switch_array_smart_charge_active(self, pos: int, value: int):
def wallbox_prohibit_usage(self) -> [int]:
return self.read_array_data(SENEC_SECTION_WALLBOX, "PROHIBIT_USAGE")

async def switch_array_wallbox_prohibit_usage(self, pos: int, value: bool, sync: bool = True):
mode = None
if value:
mode = APP_API_WEB_MODE_LOCKED
else:
mode = APP_API_WEB_MODE_SSGCM
if IntBridge.app_api._app_last_wallbox_modes[pos] is not None:
mode = IntBridge.app_api._app_last_wallbox_modes[pos]

await self._set_wallbox_mode_post(pos=pos, mode_to_set_in_lc=mode)
if sync and IntBridge.avail():
await IntBridge.app_api.app_set_wallbox_mode(mode_to_set_in_lc=mode, wallbox_num=(pos + 1), sync=False)
# async def switch_array_wallbox_prohibit_usage(self, pos: int, value: bool, sync: bool = True):
# mode = None
# if value:
# mode = APP_API_WEB_MODE_LOCKED
# else:
# mode = APP_API_WEB_MODE_SSGCM
# if IntBridge.app_api._app_last_wallbox_modes_lc[pos] is not None:
# mode = IntBridge.app_api._app_last_wallbox_modes_lc[pos]
# elif IntBridge.app_api._app_raw_wallbox[pos] is not None:
# pass
#
# await self._set_wallbox_mode_post(pos=pos, mode_to_set_in_lc=mode)
# if sync and IntBridge.avail():
# await IntBridge.app_api.app_set_wallbox_mode(mode_to_set_in_lc=mode, wallbox_num=(pos + 1), sync=False)

def read_array_data(self, section_key: str, array_values_key) -> []:
if hasattr(self, '_raw') and section_key in self._raw and array_values_key in self._raw[section_key]:
Expand Down Expand Up @@ -2330,7 +2332,7 @@ def __init__(self, user, pwd, web_session, master_plant_number: int = 0, options
self._app_token = None
self._app_master_plant_id = None
self._app_raw_wallbox = [None, None, None, None]
self._app_last_wallbox_modes = [None, None, None, None]
#self._app_last_wallbox_modes_lc = [None, None, None, None]
self._app_wallbox_num_max = 4

IntBridge.app_api = self
Expand Down Expand Up @@ -2585,10 +2587,10 @@ async def app_set_wallbox_mode(self, mode_to_set_in_lc: str, wallbox_num: int =
if self._app_raw_wallbox[idx] is not None:
cur_mode = self._app_raw_wallbox[idx]["chargingMode"].lower()
# if the NEW mode will be the LOCKED mode we will keep/store the previous active mode
if mode_to_set_in_lc == APP_API_WEB_MODE_LOCKED:
self._app_last_wallbox_modes[idx] = cur_mode
else:
self._app_last_wallbox_modes[idx] = None
#if mode_to_set_in_lc == APP_API_WEB_MODE_LOCKED:
# self._app_last_wallbox_modes_lc[idx] = cur_mode
#else:
# self._app_last_wallbox_modes_lc[idx] = None
else:
cur_mode = "unknown"

Expand Down
24 changes: 12 additions & 12 deletions custom_components/senec/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@
"wallbox_allow_intercharge": {
"name": "Wallbox load from battery"
},
"wallbox_1_prohibit_usage": {
"name": "Wallbox I activated"
},
"wallbox_2_prohibit_usage": {
"name": "Wallbox II activated"
},
"wallbox_3_prohibit_usage": {
"name": "Wallbox III activated"
},
"wallbox_4_prohibit_usage": {
"name": "Wallbox IV activated"
},
"sockets_1_force_on": {
"name": "Socket1 permanent on"
},
Expand Down Expand Up @@ -223,6 +211,18 @@
"wallbox_4_smart_charge_active": {
"name": "Wallbox IV Smart-Charge active"
},
"wallbox_1_prohibit_usage": {
"name": "Wallbox I locked"
},
"wallbox_2_prohibit_usage": {
"name": "Wallbox II locked"
},
"wallbox_3_prohibit_usage": {
"name": "Wallbox III locked"
},
"wallbox_4_prohibit_usage": {
"name": "Wallbox IV locked"
},
"fan_inv_lv": {
"name": "Fan LV-Inverter"
},
Expand Down
24 changes: 12 additions & 12 deletions custom_components/senec/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@
"wallbox_allow_intercharge": {
"name": "Wallbox laden aus Speicher"
},
"wallbox_1_prohibit_usage": {
"name": "Wallbox I aktiv"
},
"wallbox_2_prohibit_usage": {
"name": "Wallbox II aktiv"
},
"wallbox_3_prohibit_usage": {
"name": "Wallbox III aktiv"
},
"wallbox_4_prohibit_usage": {
"name": "Wallbox IV aktiv"
},
"sockets_1_force_on": {
"name": "Kontakt1 permanent ein"
},
Expand Down Expand Up @@ -308,6 +296,18 @@
"wallbox_4_smart_charge_active": {
"name": "Wallbox IV Smart-Charge aktiv"
},
"wallbox_1_prohibit_usage": {
"name": "Wallbox I gesperrt"
},
"wallbox_2_prohibit_usage": {
"name": "Wallbox II gesperrt"
},
"wallbox_3_prohibit_usage": {
"name": "Wallbox III gesperrt"
},
"wallbox_4_prohibit_usage": {
"name": "Wallbox IV gesperrt"
},
"fan_inv_lv": {
"name": "Lüfter LV-Inverter"
},
Expand Down
24 changes: 12 additions & 12 deletions custom_components/senec/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@
"wallbox_allow_intercharge": {
"name": "Wallbox load from battery"
},
"wallbox_1_prohibit_usage": {
"name": "Wallbox I activated"
},
"wallbox_2_prohibit_usage": {
"name": "Wallbox II activated"
},
"wallbox_3_prohibit_usage": {
"name": "Wallbox III activated"
},
"wallbox_4_prohibit_usage": {
"name": "Wallbox IV activated"
},
"sockets_1_force_on": {
"name": "Socket1 permanent on"
},
Expand Down Expand Up @@ -308,6 +296,18 @@
"wallbox_4_smart_charge_active": {
"name": "Wallbox IV Smart-Charge active"
},
"wallbox_1_prohibit_usage": {
"name": "Wallbox I locked"
},
"wallbox_2_prohibit_usage": {
"name": "Wallbox II locked"
},
"wallbox_3_prohibit_usage": {
"name": "Wallbox III locked"
},
"wallbox_4_prohibit_usage": {
"name": "Wallbox IV locked"
},
"fan_inv_lv": {
"name": "Fan LV-Inverter"
},
Expand Down

0 comments on commit c63291e

Please sign in to comment.