Skip to content

Commit f181215

Browse files
authored
feat: add safety counts property and additional connected states (#388)
* feat: add safety counts property and additional connected states * formatting * update tests * more linting
1 parent 1f1a6d6 commit f181215

File tree

4 files changed

+304
-129
lines changed

4 files changed

+304
-129
lines changed

openevsehttp/__main__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,8 @@ def has_limit(self) -> bool | None:
11191119
assert self._status is not None
11201120
if "has_limit" in self._status:
11211121
return self._status["has_limit"]
1122+
if "limit" in self._status:
1123+
return self._status["limit"]
11221124
return None
11231125

11241126
@property
@@ -1286,3 +1288,44 @@ def mqtt_connected(self) -> bool:
12861288
if self._status is not None and "mqtt_connected" in self._status:
12871289
return self._status["mqtt_connected"]
12881290
return False
1291+
1292+
@property
1293+
def emoncms_connected(self) -> bool | None:
1294+
"""Return the status of the emoncms connection."""
1295+
if self._status is not None and "emoncms_connected" in self._status:
1296+
return self._status["emoncms_connected"]
1297+
return None
1298+
1299+
@property
1300+
def ocpp_connected(self) -> bool | None:
1301+
"""Return the status of the ocpp connection."""
1302+
if self._status is not None and "ocpp_connected" in self._status:
1303+
return self._status["ocpp_connected"]
1304+
return None
1305+
1306+
@property
1307+
def uptime(self) -> int | None:
1308+
"""Return the unit uptime."""
1309+
if self._status is not None and "uptime" in self._status:
1310+
return self._status["uptime"]
1311+
return None
1312+
1313+
@property
1314+
def freeram(self) -> int | None:
1315+
"""Return the unit freeram."""
1316+
if self._status is not None and "freeram" in self._status:
1317+
return self._status["freeram"]
1318+
return None
1319+
1320+
# Safety counts
1321+
@property
1322+
def checks_count(self) -> dict | None:
1323+
"""Return the saftey checks counts."""
1324+
attributes = ("gfcicount", "nogndcount", "stuckcount")
1325+
if self._status is not None and set(attributes).issubset(self._status.keys()):
1326+
counts = {}
1327+
counts["gfcicount"] = self._status["gfcicount"]
1328+
counts["nogndcount"] = self._status["nogndcount"]
1329+
counts["stuckcount"] = self._status["stuckcount"]
1330+
return counts
1331+
return None
Lines changed: 105 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,108 @@
11
{
2-
"firmware": "7.1.3",
3-
"protocol": "-",
4-
"espflash": 4194304,
5-
"wifi_serial": "1234567890AB",
6-
"version": "4.1.8",
7-
"diodet": 0,
8-
"gfcit": 0,
9-
"groundt": 0,
10-
"relayt": 0,
11-
"ventt": 0,
12-
"tempt": 0,
13-
"service": 2,
14-
"scale": 220,
15-
"offset": 0,
16-
"max_current_soft": 48,
17-
"min_current_hard": 6,
18-
"max_current_hard": 48,
19-
"mqtt_supported_protocols": [
2+
"mqtt_supported_protocols": [
203
"mqtt",
214
"mqtts"
22-
],
23-
"http_supported_protocols": [
24-
"http",
25-
"https"
26-
],
27-
"ssid": "Datanode-IoT",
28-
"pass": "_DUMMY_PASSWORD",
29-
"www_username": "",
30-
"www_password": "",
31-
"hostname": "openevse-7b2c",
32-
"sntp_hostname": "0.us.pool.ntp.org",
33-
"time_zone": "America/Phoenix|MST7",
34-
"emoncms_server": "https://emoncms.collective.lan/",
35-
"emoncms_node": "openevse",
36-
"emoncms_apikey": "_DUMMY_PASSWORD",
37-
"emoncms_fingerprint": "",
38-
"mqtt_server": "192.168.1.198",
39-
"mqtt_port": 1883,
40-
"mqtt_topic": "openevse",
41-
"mqtt_user": "devices",
42-
"mqtt_pass": "_DUMMY_PASSWORD",
43-
"mqtt_solar": "",
44-
"mqtt_grid_ie": "home-assistant/power/watts",
45-
"mqtt_vrms": "home-assistant/solar/watts",
46-
"mqtt_announce_topic": "openevse/announce/7b2c",
47-
"ohm": "",
48-
"divert_PV_ratio": 1.1,
49-
"divert_attack_smoothing_factor": 0.4,
50-
"divert_decay_smoothing_factor": 0.05,
51-
"divert_min_charge_time": 600,
52-
"tesla_username": "",
53-
"tesla_password": "",
54-
"tesla_vehidx": -1,
55-
"led_brightness": 128,
56-
"flags": 522,
57-
"emoncms_enabled": false,
58-
"mqtt_enabled": true,
59-
"mqtt_reject_unauthorized": true,
60-
"ohm_enabled": false,
61-
"sntp_enabled": true,
62-
"tesla_enabled": false,
63-
"divert_enabled": false,
64-
"pause_uses_disabled": false,
65-
"mqtt_protocol": "mqtt",
66-
"charge_mode": "fast"
67-
}
5+
],
6+
"http_supported_protocols": [
7+
"http"
8+
],
9+
"buildenv": "openevse_wifi_v1",
10+
"version": "v5.1.2",
11+
"wifi_serial": "9C9C1FE57B2C",
12+
"protocol": "-",
13+
"espinfo": "ESP32r1 2 core WiFi BLE BT",
14+
"espflash": 4194304,
15+
"firmware": "7.1.3",
16+
"evse_serial": "",
17+
"diode_check": true,
18+
"gfci_check": true,
19+
"ground_check": true,
20+
"relay_check": true,
21+
"vent_check": true,
22+
"temp_check": true,
23+
"max_current_soft": 48,
24+
"service": 2,
25+
"scale": 220,
26+
"offset": 0,
27+
"min_current_hard": 6,
28+
"max_current_hard": 48,
29+
"ssid": "Datanode-IoT",
30+
"pass": "_DUMMY_PASSWORD",
31+
"ap_ssid": "",
32+
"ap_pass": "",
33+
"lang": "en",
34+
"www_username": "",
35+
"www_password": "",
36+
"www_certificate_id": "",
37+
"hostname": "openevse-7b2c",
38+
"sntp_hostname": "0.us.pool.ntp.org",
39+
"time_zone": "America/Phoenix|MST7",
40+
"limit_default_type": "",
41+
"limit_default_value": 0,
42+
"emoncms_server": "http://emoncms.collective.lan/",
43+
"emoncms_node": "openevse",
44+
"emoncms_apikey": "_DUMMY_PASSWORD",
45+
"emoncms_fingerprint": "",
46+
"mqtt_server": "192.168.1.198",
47+
"mqtt_port": 1883,
48+
"mqtt_topic": "openevse",
49+
"mqtt_user": "devices",
50+
"mqtt_pass": "_DUMMY_PASSWORD",
51+
"mqtt_certificate_id": "",
52+
"mqtt_solar": "",
53+
"mqtt_grid_ie": "home-assistant/power/watts",
54+
"mqtt_vrms": "",
55+
"mqtt_live_pwr": "",
56+
"mqtt_vehicle_soc": "",
57+
"mqtt_vehicle_range": "",
58+
"mqtt_vehicle_eta": "",
59+
"mqtt_announce_topic": "openevse/announce/7b2c",
60+
"ocpp_server": "",
61+
"ocpp_chargeBoxId": "",
62+
"ocpp_authkey": "",
63+
"ocpp_idtag": "DefaultIdTag",
64+
"ohm": "",
65+
"divert_type": 1,
66+
"divert_PV_ratio": 1.1,
67+
"divert_attack_smoothing_time": 20,
68+
"divert_decay_smoothing_time": 600,
69+
"divert_min_charge_time": 600,
70+
"current_shaper_max_pwr": 0,
71+
"current_shaper_smoothing_time": 60,
72+
"current_shaper_min_pause_time": 300,
73+
"current_shaper_data_maxinterval": 120,
74+
"vehicle_data_src": 0,
75+
"tesla_access_token": "",
76+
"tesla_refresh_token": "",
77+
"tesla_created_at": 18446744073709551615,
78+
"tesla_expires_in": 18446744073709551615,
79+
"tesla_vehicle_id": "",
80+
"rfid_storage": "",
81+
"led_brightness": 125,
82+
"scheduler_start_window": 600,
83+
"flags": 102761482,
84+
"flags_changed": 48242178,
85+
"emoncms_enabled": false,
86+
"mqtt_enabled": true,
87+
"mqtt_reject_unauthorized": true,
88+
"mqtt_retained": false,
89+
"ohm_enabled": false,
90+
"sntp_enabled": true,
91+
"tesla_enabled": false,
92+
"divert_enabled": false,
93+
"current_shaper_enabled": false,
94+
"pause_uses_disabled": false,
95+
"mqtt_vehicle_range_miles": false,
96+
"ocpp_enabled": false,
97+
"ocpp_auth_auto": false,
98+
"ocpp_auth_offline": false,
99+
"ocpp_suspend_evse": false,
100+
"ocpp_energize_plug": false,
101+
"rfid_enabled": false,
102+
"factory_write_lock": true,
103+
"is_threephase": false,
104+
"wizard_passed": true,
105+
"default_state": true,
106+
"mqtt_protocol": "mqtt",
107+
"charge_mode": "eco"
108+
}
Lines changed: 79 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,80 @@
11
{
2-
"mode": "STA",
3-
"wifi_client_connected": 1,
4-
"eth_connected": 0,
5-
"net_connected": 1,
6-
"ipaddress": "192.168.21.10",
7-
"emoncms_connected": 0,
8-
"packets_sent": 0,
9-
"packets_success": 0,
10-
"mqtt_connected": 1,
11-
"ohm_hour": "NotConnected",
12-
"free_heap": 223464,
13-
"comm_sent": 345660,
14-
"comm_success": 332432,
15-
"rapi_connected": 1,
16-
"evse_connected": 1,
17-
"amp": 32.2,
18-
"voltage": 240,
19-
"pilot": 48,
20-
"wh": 64582,
21-
"temp": 503,
22-
"temp1": false,
23-
"temp2": 503,
24-
"temp3": false,
25-
"temp4": 560,
26-
"state": 254,
27-
"vehicle": 1,
28-
"colour": 6,
29-
"freeram": 223464,
30-
"divertmode": 0,
31-
"srssi": -61,
32-
"elapsed": 246,
33-
"wattsec": 992549,
34-
"watthour": 64582,
35-
"gfcicount": 1,
36-
"nogndcount": 0,
37-
"stuckcount": 0,
38-
"solar": 0,
39-
"grid_ie": 2891,
40-
"charge_rate": 0,
41-
"divert_update": 11,
42-
"ota_update": 0,
43-
"time": "2021-08-10T23:00:11Z",
44-
"offset": "-0700",
45-
"shaper": 1,
46-
"shaper_live_pwr": 2299,
47-
"shaper_max_pwr": 4000,
48-
"shaper_cur": 21,
49-
"vehicle_soc": 75,
50-
"vehicle_range": 468,
51-
"vehicle_eta": 18000,
52-
"session_energy": 7004,
53-
"has_limit": false,
54-
"total_day": 1234,
55-
"total_week": 12345,
56-
"total_month": 123456,
57-
"total_year": 1234567,
58-
"total_energy": 12345678,
59-
"max_current": 48
60-
}
2+
"mode": "STA",
3+
"wifi_client_connected": 1,
4+
"eth_connected": 0,
5+
"net_connected": 1,
6+
"ipaddress": "192.168.21.19",
7+
"macaddress": "9C:9C:1F:E5:7B:2C",
8+
"emoncms_connected": 0,
9+
"packets_sent": 0,
10+
"packets_success": 0,
11+
"mqtt_connected": 1,
12+
"ocpp_connected": 0,
13+
"rfid_failure": 0,
14+
"ohm_hour": "NotConnected",
15+
"free_heap": 167436,
16+
"comm_sent": 677216,
17+
"comm_success": 677214,
18+
"rapi_connected": 1,
19+
"evse_connected": 1,
20+
"amp": 0,
21+
"voltage": 220,
22+
"power": 0,
23+
"pilot": 48,
24+
"max_current": 48,
25+
"temp": 440,
26+
"temp_max": 588,
27+
"temp1": false,
28+
"temp2": 440,
29+
"temp3": false,
30+
"temp4": 542.5,
31+
"state": 254,
32+
"status": "disabled",
33+
"flags": 512,
34+
"vehicle": 0,
35+
"colour": 5,
36+
"manual_override": 0,
37+
"freeram": 167436,
38+
"divertmode": 1,
39+
"srssi": -59,
40+
"time": "2024-11-14T20:53:35Z",
41+
"local_time": "2024-11-14T13:53:35-0700",
42+
"offset": "-0700",
43+
"uptime": 1208725,
44+
"session_elapsed": 0,
45+
"session_energy": 0,
46+
"total_energy": 20127.22817,
47+
"total_day": 0,
48+
"total_week": 1.567628635,
49+
"total_month": 37.21857071,
50+
"total_year": 2155.219982,
51+
"total_switches": 1159,
52+
"elapsed": 0,
53+
"wattsec": 0,
54+
"watthour": 2.012722817e7,
55+
"gfcicount": 1,
56+
"nogndcount": 0,
57+
"stuckcount": 0,
58+
"solar": 0,
59+
"grid_ie": -2489,
60+
"charge_rate": 15,
61+
"divert_update": 6,
62+
"divert_active": false,
63+
"shaper": 0,
64+
"shaper_live_pwr": 0,
65+
"shaper_cur": 0,
66+
"shaper_updated": false,
67+
"service_level": 2,
68+
"limit": false,
69+
"ota_update": 0,
70+
"config_version": 6,
71+
"claims_version": 36,
72+
"override_version": 4,
73+
"schedule_version": 1,
74+
"schedule_plan_version": 30,
75+
"limit_version": 1,
76+
"vehicle_state_update": 1208725,
77+
"tesla_vehicle_count": false,
78+
"tesla_vehicle_id": false,
79+
"tesla_vehicle_name": false
80+
}

0 commit comments

Comments
 (0)