Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyuentuen committed Jun 11, 2024
2 parents 1aa2b48 + 338cd91 commit fce3eec
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
3 changes: 2 additions & 1 deletion custom_components/alfen_wallbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
if not device:
return False

device.initilize = True
await device.async_update()
device.get_number_of_socket()
device.get_licenses()
Expand All @@ -60,7 +61,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
hass.data[DOMAIN][config_entry.entry_id] = device

await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)

device.initilize = False
return True


Expand Down
19 changes: 16 additions & 3 deletions custom_components/alfen_wallbox/alfen.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(self,
self.latest_tag = None
self.transaction_offset = 0
self.transaction_counter = 0
self.initilize = False

# set next update time as current time
self.next_update = datetime.datetime.now()
Expand Down Expand Up @@ -171,9 +172,11 @@ async def async_update(self):
try:
self.updating = True
await self._get_all_properties_value()
if self.transaction_counter == 0:

if self.transaction_counter == 0 and not self.initilize:
await self._get_transaction()
self.transaction_counter += 1
if not self.initilize:
self.transaction_counter += 1

finally:
self.updating = False
Expand Down Expand Up @@ -339,8 +342,14 @@ async def _get_transaction(self):
#_LOGGER.debug(response)
# split this text into lines with \n
lines = str(response).splitlines()

# if the lines are empty, break the loop
if not lines or not response:
transactionLoop = False
break

for line in lines:
if line is None or response is None:
if line is None:
transactionLoop = False
break

Expand Down Expand Up @@ -415,6 +424,10 @@ async def _get_transaction(self):

elif 'dto' in line:
continue
elif '0_Empty' in line:
# break if the transaction is empty
transactionLoop = False
break
else:
_LOGGER.debug(f"Unknown line: {line}")
continue
Expand Down
15 changes: 15 additions & 0 deletions custom_components/alfen_wallbox/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,21 @@ class AlfenNumberDescription(NumberEntityDescription, AlfenNumberDescriptionMixi
api_param="3262_4",
round_digits=2
),
AlfenNumberDescription(
key="price_price_other",
name="Price other",
state=None,
icon="mdi:currency-eur",
assumed_state=False,
device_class=None,
native_min_value=-5,
native_max_value=5,
native_step=0.01,
custom_mode=NumberMode.BOX,
unit_of_measurement=CURRENCY_EURO,
api_param="3262_6",
round_digits=2
),
AlfenNumberDescription(
key="ev_disconnection_timeout",
name="Car Disconnection Timeout (s)",
Expand Down
7 changes: 7 additions & 0 deletions custom_components/alfen_wallbox/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class AlfenTextDescription(TextEntityDescription, AlfenTextDescriptionMixin):
mode=TextMode.PASSWORD,
api_param="2116_1"
),
AlfenTextDescription(
key="price_other_description",
name="Price other description",
icon="mdi:tag-text-outline",
mode=TextMode.TEXT,
api_param="3262_7"
),
)


Expand Down

0 comments on commit fce3eec

Please sign in to comment.