Skip to content

Commit a3276fb

Browse files
authored
Merge pull request #315 from claudegel/fix-3.0
Fix for 3.0
2 parents e90eff8 + 007c48c commit a3276fb

File tree

5 files changed

+73
-27
lines changed

5 files changed

+73
-27
lines changed

custom_components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"neviweb130": {
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"local_location": "/custom_components/neviweb130/__init__.py",
55
"remote_location": "https://github.com/claudegel/sinope-130/tree/master/custom_components/__init__.py",
66
"visit_repo": "https://github.com/claudegel/sinope-130",

custom_components/neviweb130/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ def __init__(self, hass, config):
115115
network = config.get(CONF_NETWORK)
116116
network2 = config.get(CONF_NETWORK2)
117117
network3 = config.get(CONF_NETWORK3)
118+
ignore_miwi = config.get(CONF_IGNORE_MIWI)
118119
self.neviweb130_client = Neviweb130Client(
119-
hass, username, password, network, network2, network3
120+
hass, username, password, network, network2, network3, ignore_miwi
120121
)
121122

122123

@@ -141,6 +142,7 @@ def __init__(
141142
network,
142143
network2,
143144
network3,
145+
ignore_miwi,
144146
timeout=REQUESTS_TIMEOUT,
145147
):
146148
"""Initialize the client object."""
@@ -150,6 +152,7 @@ def __init__(
150152
self._network_name = network
151153
self._network_name2 = network2
152154
self._network_name3 = network3
155+
self._ignore_miwi = ignore_miwi
153156
self._gateway_id = None
154157
self._gateway_id2 = None
155158
self._gateway_id3 = None
@@ -453,7 +456,7 @@ def __get_gateway_data(self):
453456
device[ATTR_SIGNATURE] = data[ATTR_SIGNATURE]
454457
_LOGGER.debug("Received signature data: %s", data)
455458
if data[ATTR_SIGNATURE]["protocol"] == "miwi":
456-
if not IGNORE_MIWI:
459+
if not self._ignore_miwi:
457460
_LOGGER.debug(
458461
"The Neviweb location selected for parameter "
459462
+ "«network» contain unsupported device with protocol"
@@ -471,7 +474,7 @@ def __get_gateway_data(self):
471474
device[ATTR_SIGNATURE] = data2[ATTR_SIGNATURE]
472475
_LOGGER.debug("Received signature data: %s", data2)
473476
if data2[ATTR_SIGNATURE]["protocol"] == "miwi":
474-
if not IGNORE_MIWI:
477+
if not self._ignore_miwi:
475478
_LOGGER.debug(
476479
"The Neviweb location selected for parameter "
477480
+ "«network2» contain unsupported device with protocol"
@@ -489,7 +492,7 @@ def __get_gateway_data(self):
489492
device[ATTR_SIGNATURE] = data3[ATTR_SIGNATURE]
490493
_LOGGER.debug("Received signature data: %s", data3)
491494
if data3[ATTR_SIGNATURE]["protocol"] == "miwi":
492-
if not IGNORE_MIWI:
495+
if not self._ignore_miwi:
493496
_LOGGER.debug(
494497
"The Neviweb location selected for parameter "
495498
+ "«network3» contain unsupported device with protocol"

custom_components/neviweb130/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"dependencies": [],
88
"requirements": [],
99
"iot_class": "cloud_polling",
10-
"version": "3.0.0",
10+
"version": "3.0.1",
1111
"homeassistant": "2024.12.1"
1212
}

custom_components/neviweb130/schema.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,30 @@
3737

3838
"""Default parameters values."""
3939

40-
VERSION = "3.0.0"
40+
VERSION = "3.0.1"
4141
SCAN_INTERVAL = timedelta(seconds=540)
4242
HOMEKIT_MODE = False
4343
STAT_INTERVAL = 1800
4444
IGNORE_MIWI = False
4545
NOTIFY = "both"
46-
PERIOD_VALUE = {"15 sec", "5 min", "10 min", "15 min", "20 min", "25 min", "30 min"}
46+
PERIOD_VALUE = {
47+
"15 sec",
48+
"5 min",
49+
"10 min",
50+
"15 min",
51+
"20 min",
52+
"25 min",
53+
"30 min",
54+
}
4755
MIN_TIME = {120, 180, 240, 300, 600}
4856
WIFI_CYCLE = {600, 900, 1200, 1500}
4957
TANK_VALUE = {"40 gal", "50 gal", "60 gal", "80 gal"}
50-
CONTROLLED_VALUE = {"Hot water heater", "Pool pump", "Eletric vehicle charger", "Other"}
58+
CONTROLLED_VALUE = {
59+
"Hot water heater",
60+
"Pool pump",
61+
"Eletric vehicle charger",
62+
"Other",
63+
}
5164
FLOW_MODEL = {"FS4220", "FS4221", "No flow meter"}
5265
FLOW_DURATION = {
5366
"15 min",

custom_components/neviweb130/valve.py

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ def set_valve_alert_service(service):
324324
value = {}
325325
for switch in entities:
326326
if switch.entity_id == entity_id:
327-
value = {"id": switch.unique_id, "batt": service.data[ATTR_BATT_ALERT]}
327+
value = {
328+
"id": switch.unique_id,
329+
"batt": service.data[ATTR_BATT_ALERT],
330+
}
328331
switch.set_valve_alert(value)
329332
switch.schedule_update_ha_state(True)
330333
break
@@ -335,7 +338,10 @@ def set_valve_temp_alert_service(service):
335338
value = {}
336339
for switch in entities:
337340
if switch.entity_id == entity_id:
338-
value = {"id": switch.unique_id, "temp": service.data[ATTR_TEMP_ALERT]}
341+
value = {
342+
"id": switch.unique_id,
343+
"temp": service.data[ATTR_TEMP_ALERT],
344+
}
339345
switch.set_valve_temp_alert(value)
340346
switch.schedule_update_ha_state(True)
341347
break
@@ -403,7 +409,10 @@ def set_activation_service(service):
403409
value = {}
404410
for switch in entities:
405411
if switch.entity_id == entity_id:
406-
value = {"id": switch.unique_id, "active": service.data[ATTR_ACTIVE]}
412+
value = {
413+
"id": switch.unique_id,
414+
"active": service.data[ATTR_ACTIVE],
415+
}
407416
switch.set_activation(value)
408417
switch.schedule_update_ha_state(True)
409418
break
@@ -820,7 +829,7 @@ def do_stat(self, start):
820829
and self._energy_stat_time != 0
821830
):
822831
device_hourly_stats = self._client.get_device_hourly_stats(self._id)
823-
# _LOGGER.warning("%s device_hourly_stats = %s", self._name, device_hourly_stats)
832+
# _LOGGER.warning("%s device_hourly_stats = %s", self._name, device_hourly_stats)
824833
if device_hourly_stats is not None and len(device_hourly_stats) > 1:
825834
self._hour_energy_kwh_count = (
826835
device_hourly_stats[1]["counter"] / 1000
@@ -831,7 +840,7 @@ def do_stat(self, start):
831840
self._hour_kwh = 0
832841
_LOGGER.warning("Got None for device_hourly_stats")
833842
device_daily_stats = self._client.get_device_daily_stats(self._id)
834-
# _LOGGER.warning("%s device_daily_stats = %s", self._name, device_daily_stats)
843+
# _LOGGER.warning("%s device_daily_stats = %s", self._name, device_daily_stats)
835844
if device_daily_stats is not None and len(device_daily_stats) > 1:
836845
self._today_energy_kwh_count = (
837846
device_daily_stats[0]["counter"] / 1000
@@ -842,7 +851,7 @@ def do_stat(self, start):
842851
self._today_kwh = 0
843852
_LOGGER.warning("Got None for device_daily_stats")
844853
device_monthly_stats = self._client.get_device_monthly_stats(self._id)
845-
# _LOGGER.warning("%s device_monthly_stats = %s", self._name, device_monthly_stats)
854+
# _LOGGER.warning("%s device_monthly_stats = %s", self._name, device_monthly_stats)
846855
if device_monthly_stats is not None and len(device_monthly_stats) > 1:
847856
self._month_energy_kwh_count = (
848857
device_monthly_stats[0]["counter"] / 1000
@@ -881,15 +890,18 @@ def log_error(self, error_data):
881890
elif error_data == "MAINTENANCE":
882891
_LOGGER.warning("Access blocked for maintenance...Retry later.")
883892
self.notify_ha(
884-
"Warning: Neviweb access temporary blocked for maintenance...Retry later."
893+
"Warning: Neviweb access temporary blocked for maintenance..."
894+
+ "Retry later."
885895
)
886896
self._client.reconnect()
887897
elif error_data == "ACCSESSEXC":
888898
_LOGGER.warning(
889-
"Maximun session number reached...Close other connections and try again."
899+
"Maximun session number reached...Close other connections "
900+
+ "and try again."
890901
)
891902
self.notify_ha(
892-
"Warning: Maximun Neviweb session number reached...Close other connections and try again."
903+
"Warning: Maximun Neviweb session number reached...Close "
904+
+ "other connections and try again."
893905
)
894906
self._client.reconnect()
895907
elif error_data == "DVCATTRNSPTD":
@@ -901,13 +913,16 @@ def log_error(self, error_data):
901913
)
902914
elif error_data == "DVCACTNSPTD":
903915
_LOGGER.warning(
904-
"Device action not supported for %s...(SKU: %s) Report to maintainer.",
916+
"Device action not supported for %s...(SKU: %s) Report to "
917+
+ "maintainer.",
905918
self._name,
906919
self._sku,
907920
)
908921
elif error_data == "DVCCOMMTO":
909922
_LOGGER.warning(
910-
"Device Communication Timeout for %s... The device did not respond to the server within the prescribed delay. (SKU: %s)",
923+
"Device Communication Timeout for %s... The device did not "
924+
+ "respond to the server within the prescribed delay. "
925+
+ "(SKU: %s)",
911926
self._name,
912927
self._sku,
913928
)
@@ -920,7 +935,8 @@ def log_error(self, error_data):
920935
)
921936
elif error_data == "DVCBUSY":
922937
_LOGGER.warning(
923-
"Device busy can't reach (neviweb update ?), retry later %s: %s...(SKU: %s)",
938+
"Device busy can't reach (neviweb update ?), retry later %s: %s..."
939+
+ "(SKU: %s)",
924940
self._name,
925941
error_data,
926942
self._sku,
@@ -934,16 +950,21 @@ def log_error(self, error_data):
934950
self._sku,
935951
)
936952
_LOGGER.warning(
937-
"This device %s is de-activated and won't be updated for 20 minutes.",
953+
"This device %s is de-activated and won't be updated for "
954+
+ "20 minutes.",
938955
self._name,
939956
)
940957
_LOGGER.warning(
941-
"You can re-activate device %s with service.neviweb130_set_activation or wait 20 minutes for update to restart or just restart HA.",
958+
"You can re-activate device %s with "
959+
+ "service.neviweb130_set_activation or wait 20 minutes "
960+
+ "for update to restart or just restart HA.",
942961
self._name,
943962
)
944963
if NOTIFY == "notification" or NOTIFY == "both":
945964
self.notify_ha(
946-
"Warning: Received message from Neviweb, device disconnected... Check your log... Neviweb update will be halted for 20 minutes for "
965+
"Warning: Received message from Neviweb, device "
966+
+ "disconnected... Check your log... Neviweb update will "
967+
+ "be halted for 20 minutes for "
947968
+ self._name
948969
+ ", Sku: "
949970
+ self._sku
@@ -1094,7 +1115,10 @@ def update(self):
10941115
self._battery_alert = device_data[ATTR_BATT_ALERT]
10951116
if ATTR_WATER_LEAK_STATUS in device_data:
10961117
self._water_leak_status = device_data[ATTR_WATER_LEAK_STATUS]
1097-
if self._water_leak_status == "flowMeter":
1118+
if (
1119+
self._water_leak_status == "flowMeter"
1120+
and device_data[ATTR_FLOW_METER_CONFIG]["offset"] != 0
1121+
):
10981122
self.notify_ha(
10991123
"Warning: Neviweb Device error detected: "
11001124
+ device_data[ATTR_WATER_LEAK_STATUS]
@@ -1399,7 +1423,10 @@ def update(self):
13991423
]
14001424
self._flowmeter_model = model_to_HA(self._flowmeter_multiplier)
14011425
self._water_leak_status = device_data[ATTR_WATER_LEAK_STATUS]
1402-
if self._water_leak_status == "flowMeter":
1426+
if (
1427+
self._water_leak_status == "flowMeter"
1428+
and device_data[ATTR_FLOW_METER_CONFIG]["offset"] != 0
1429+
):
14031430
self.notify_ha(
14041431
"Warning: Neviweb Device error detected: "
14051432
+ device_data[ATTR_WATER_LEAK_STATUS]
@@ -1657,7 +1684,10 @@ def update(self):
16571684
]
16581685
self._flowmeter_model = model_to_HA(self._flowmeter_multiplier)
16591686
self._water_leak_status = device_data[ATTR_WATER_LEAK_STATUS]
1660-
if self._water_leak_status == "flowMeter":
1687+
if (
1688+
self._water_leak_status == "flowMeter"
1689+
and device_data[ATTR_FLOW_METER_CONFIG]["offset"] != 0
1690+
):
16611691
self.notify_ha(
16621692
"Warning: Neviweb Device error detected: "
16631693
+ device_data[ATTR_WATER_LEAK_STATUS]

0 commit comments

Comments
 (0)