Skip to content

Commit fc96223

Browse files
authored
v2.13.2 bugfix
1 parent 22815b1 commit fc96223

File tree

4 files changed

+15
-22
lines changed

4 files changed

+15
-22
lines changed

custom_components/apsystems_ecu_reader/binary_sensor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""binary_sensor.py"""
22

33
import logging
4-
from homeassistant.util import dt as dt_util
54

65
from homeassistant.components.binary_sensor import BinarySensorEntity
76
from homeassistant.helpers.entity import EntityCategory
@@ -64,8 +63,7 @@ def extra_state_attributes(self):
6463
"""Return the state attributes of the sensor."""
6564
return {
6665
"timezone": self._ecu.ecu.timezone,
67-
"Last data update": self._ecu.ecu.last_update,
68-
"Last UI update": dt_util.now().isoformat(),
66+
"last_data_update": self._ecu.ecu.last_update,
6967
}
7068

7169
@property

custom_components/apsystems_ecu_reader/ecu_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def __init__(self, ipaddr, raw_ecu=None, raw_inverter=None, timeout=5):
3838
self.timeout = timeout
3939
# how big of a buffer to read at a time from the socket
4040
self.recv_size = DEFAULT_RECV_SIZE
41+
# buffer used to store the latest socket read
42+
self.read_buffer = b""
4143

4244
self.ecu_cmd = "APS1100160001END\n"
4345
self.inverter_query_prefix = "APS1100280002"
@@ -321,7 +323,7 @@ def process_inverter_data(self, show_graphs, data=None):
321323

322324
while cnt1 < inverter_qty:
323325
inv = {}
324-
if aps_str(data, 15, 2) == "01": # 01 = Not replaced inverter
326+
if aps_str(data, 15, 2) == "01": # 01 = Not replaced inverter
325327
inverter_uid = aps_uid(data, cnt2)
326328
inv["uid"] = inverter_uid
327329
inv["online"] = bool(aps_int_from_bytes(data, cnt2 + 6, 1))

custom_components/apsystems_ecu_reader/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"issue_tracker": "https://github.com/haedwin/homeassistant-apsystems_ecu_reader/issues",
1111
"loggers": ["custom_components.apsystems_ecu_reader"],
1212
"requirements": [],
13-
"version": "2.13.1"
13+
"version": "2.13.2"
1414
}

custom_components/apsystems_ecu_reader/sensor.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""sensor.py"""
22

33
import logging
4-
from datetime import datetime
54

65
from homeassistant.components.sensor import SensorEntity
76
from homeassistant.components.binary_sensor import BinarySensorEntity
@@ -27,7 +26,6 @@
2726

2827

2928
from homeassistant.core import callback
30-
from homeassistant.util import dt as dt_util
3129

3230
from .const import (
3331
DOMAIN,
@@ -403,9 +401,8 @@ def is_on(self):
403401
def extra_state_attributes(self):
404402
"""Return the extra state attributes."""
405403
return {
406-
"Timezone": self._ecu.ecu.timezone,
407-
"Last data update": self._ecu.ecu.last_update,
408-
"Last UI update": dt_util.now().isoformat(),
404+
"timezone": self._ecu.ecu.timezone,
405+
"last_data_update": self._ecu.ecu.last_update,
409406
}
410407

411408
@callback
@@ -501,12 +498,10 @@ def native_unit_of_measurement(self):
501498

502499
@property
503500
def extra_state_attributes(self):
504-
attrs = {
505-
"Timezone": self._ecu.ecu.timezone,
506-
"Last data update": self._ecu.ecu.last_update,
507-
"Last UI update": dt_util.now().isoformat(),
501+
return {
502+
"timezone": self._ecu.ecu.timezone,
503+
"last_data_update": self._ecu.ecu.last_update,
508504
}
509-
return attrs
510505

511506
@property
512507
def state_class(self):
@@ -605,9 +600,8 @@ def native_unit_of_measurement(self):
605600
@property
606601
def extra_state_attributes(self):
607602
return {
608-
"Timezone": self._ecu.ecu.timezone,
609-
"Last data update": self._ecu.ecu.last_update,
610-
"Last UI update": dt_util.now().isoformat(),
603+
"timezone": self._ecu.ecu.timezone,
604+
"last_data_update": self._ecu.ecu.last_update,
611605
}
612606

613607
@property
@@ -687,10 +681,9 @@ def icon(self):
687681
def extra_state_attributes(self):
688682
"""Return the state attributes of the entity."""
689683
return {
690-
"IP-Address": self._ecu.ipaddr,
691-
"Timezone": self._ecu.ecu.timezone,
692-
"Last data update": self._ecu.ecu.last_update,
693-
"Last UI update": dt_util.now().isoformat(),
684+
"ip_address": self._ecu.ipaddr,
685+
"timezone": self._ecu.ecu.timezone,
686+
"last_data_update": self._ecu.ecu.last_update,
694687
}
695688

696689
@property

0 commit comments

Comments
 (0)