forked from wills106/homeassistant-solax-modbus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_solax_ev_charger.py
More file actions
1770 lines (1691 loc) · 62 KB
/
Copy pathplugin_solax_ev_charger.py
File metadata and controls
1770 lines (1691 loc) · 62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import logging
from dataclasses import dataclass
from datetime import UTC, datetime, timedelta, timezone
from typing import Any
from homeassistant.components.number import NumberDeviceClass
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import (
PERCENTAGE,
UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfEnergy,
UnitOfFrequency,
UnitOfPower,
UnitOfTemperature,
UnitOfTime,
)
from homeassistant.helpers.entity import ( # type: ignore[attr-defined]
EntityCategory,
)
from custom_components.solax_modbus.const import (
REG_HOLDING,
REG_INPUT,
REGISTER_S16,
REGISTER_U16,
REGISTER_U32,
REGISTER_WORDS,
TIME_OPTIONS_SEPARATE_REGISTERS,
WRITE_MULTI_MODBUS,
BaseModbusButtonEntityDescription,
BaseModbusNumberEntityDescription,
BaseModbusSelectEntityDescription,
BaseModbusSensorEntityDescription,
BaseModbusSwitchEntityDescription,
BaseModbusTimeEntityDescription,
plugin_base,
value_function_enable_disable,
value_function_firmware_decimal_hundredths,
value_function_separate_registers_time,
)
from .pymodbus_compat import DataType, convert_from_registers
_LOGGER = logging.getLogger(__name__)
# Debug helper for EV charger operations
def _debug_charger_setting(hub_name: str, setting_name: str, value: Any, register: int | None = None, mode: str | None = None) -> None:
"""Log debug information about charger setting changes"""
mode_info = f" (current mode: {mode})" if mode else ""
reg_info = f" at register 0x{register:x}" if register else ""
_LOGGER.debug(f"{hub_name}: EV Charger {setting_name} set to {value}{reg_info}{mode_info}")
""" ============================================================================================
bitmasks definitions to characterize inverters, ogranized by group
these bitmasks are used in entitydeclarations to determine to which inverters the entity applies
within a group, the bits in an entitydeclaration will be interpreted as OR
between groups, an AND condition is applied, so all gruoups must match.
An empty group (group without active flags) evaluates to True.
example: GEN3 | GEN4 | X1 | X3 | EPS
means: any inverter of type (GEN3 or GEN4) and (X1 or X3) and (EPS)
An entity can be declared multiple times (with different bitmasks) if the parameters are different for each inverter type
"""
GEN = 0x0001 # base generation for MIC, PV, AC
GEN1 = 0x0001
GEN2 = 0x0002
GEN3 = 0x0004
GEN4 = 0x0008
ALL_GEN_GROUP = GEN1 | GEN2 | GEN3 | GEN4 | GEN
X1 = 0x0100
X3 = 0x0200
ALL_X_GROUP = X1 | X3
POW4 = 0x0080
POW7 = 0x0010
POW11 = 0x0020
POW22 = 0x0040
ALL_POW_GROUP = POW4 | POW7 | POW11 | POW22
# Feature flags — set dynamically in async_determineInverterType based on device registers
OCPP_TYPE = 0x0800 # device reports TypeCharger (0x0023) == 1 (OCPP variant)
ALL_FEATURE_GROUP = OCPP_TYPE
ALLDEFAULT = 0 # should be equivalent to HYBRID | AC | GEN2 | GEN3 | GEN4 | X1 | X3
# ======================= end of bitmask handling code =============================================
SENSOR_TYPES: list[Any] = []
# ====================== find inverter type and details ===========================================
async def async_read_serialnr(hub: Any, address: int) -> str | None:
_LOGGER.debug(f"{hub.name}: Reading serial number from address 0x{address:x}")
res = None
try:
_LOGGER.debug(f"{hub.name}: Attempting to read holding registers at 0x{address:x}, count=7, unit={hub._modbus_addr}")
inverter_data = await hub.async_read_holding_registers(unit=hub._modbus_addr, address=address, count=7)
if not inverter_data.isError():
_LOGGER.debug(f"{hub.name}: Successfully read registers: {inverter_data.registers[0:7]}")
raw = convert_from_registers(inverter_data.registers[0:7], DataType.STRING, "big") # type: ignore[attr-defined] # Dynamic enum aliasing
_LOGGER.debug(f"{hub.name}: Converted raw data: {raw} (type: {type(raw)})")
res = raw.decode("ascii", errors="ignore") if isinstance(raw, (bytes, bytearray)) else str(raw)
hub.seriesnumber = res
_LOGGER.debug(f"{hub.name}: Decoded serial number: {res}")
else:
_LOGGER.debug(f"{hub.name}: Register read returned error: {inverter_data}")
except Exception as ex:
_LOGGER.warning(f"{hub.name}: attempt to read serialnumber failed at 0x{address:x}", exc_info=True)
_LOGGER.debug(f"{hub.name}: Exception type: {type(ex).__name__}, message: {ex}")
if not res:
_LOGGER.warning(f"{hub.name}: reading serial number from address 0x{address:x} failed; other address may succeed")
_LOGGER.info(f"Read {hub.name} 0x{address:x} serial number before potential swap: {res}")
return res
async def async_read_firmware(hub: Any, address: int = 0x25) -> float | None:
"""Read firmware version from input register.
Args:
hub: The modbus hub instance
address: Register address (default 0x25)
Returns:
float: Firmware version (e.g., 7.07) or None on failure
"""
_LOGGER.debug(f"{hub.name}: Reading firmware version from address 0x{address:x}")
res = None
try:
_LOGGER.debug(f"{hub.name}: Attempting to read input registers at 0x{address:x}, count=1, unit={hub._modbus_addr}")
fw_data = await hub.async_read_input_registers(unit=hub._modbus_addr, address=address, count=1)
if not fw_data.isError():
fw_raw = fw_data.registers[0]
res = fw_raw / 100.0 # Decimal hundredths (e.g., 707 → 7.07)
_LOGGER.debug(f"{hub.name}: Successfully read firmware: raw={fw_raw}, version={res:.2f}")
else:
_LOGGER.debug(f"{hub.name}: Register read returned error: {fw_data}")
except Exception as ex:
_LOGGER.warning(f"{hub.name}: attempt to read firmware failed at 0x{address:x}", exc_info=True)
_LOGGER.debug(f"{hub.name}: Exception type: {type(ex).__name__}, message: {ex}")
if not res:
_LOGGER.debug(f"{hub.name}: reading firmware from address 0x{address:x} failed")
return res
# =================================================================================================
@dataclass(kw_only=True, frozen=True)
class SolaXEVChargerModbusButtonEntityDescription(BaseModbusButtonEntityDescription):
allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice
@dataclass(kw_only=True, frozen=True)
class SolaXEVChargerModbusNumberEntityDescription(BaseModbusNumberEntityDescription):
allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice
@dataclass(kw_only=True, frozen=True)
class SolaXEVChargerModbusSelectEntityDescription(BaseModbusSelectEntityDescription):
allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice
@dataclass(kw_only=True, frozen=True)
class SolaXEVChargerModbusSensorEntityDescription(BaseModbusSensorEntityDescription):
allowedtypes: int = ALLDEFAULT # maybe 0x0000 (nothing) is a better default choice
# order16: int = Endian.BIG
order32: str | None = None # optional per-sensor 32-bit word order override
register_data_type: str = REGISTER_U16
register_type: int = REG_HOLDING
@dataclass(kw_only=True, frozen=True)
class SolaXEVChargerModbusTimeEntityDescription(BaseModbusTimeEntityDescription):
allowedtypes: int = ALLDEFAULT
# ====================================== Computed value functions =================================================
def value_function_rtc_evc(initval: Any, descr: Any, datadict: dict[str, Any]) -> datetime | None:
"""Parse EVC RTC block (7 words from 0x61D).
word[0] = timezone offset in MINUTES (device uses minutes; e.g. UTC+3 → 180,
negatives as uint16 two's-complement).
words[1-6] = seconds, minutes, hours, day, month, year (2-digit).
Attaches the stored timezone directly to the stored time — no UTC assumption,
no conversion. Whatever time the device holds is shown as-is with its offset.
e.g. stored: tz=180, time=11:18 -> returns 2026-05-01 11:18:00+03:00
"""
try:
tz_raw, sec, minute, hour, day, month, year = initval
tz_minutes = tz_raw if tz_raw <= 32767 else tz_raw - 65536
tz = timezone(timedelta(minutes=tz_minutes))
return datetime(2000 + year % 100, month, day, hour, minute, sec, tzinfo=tz)
except Exception:
return None
def value_function_sync_rtc_evc(initval: Any, descr: Any, datadict: dict[str, Any]) -> list[tuple[str, int]]:
"""Write timezone (0x61D) then RTC time (0x61E–0x623) in one multi-register write.
The device displays stored_UTC_time + tz_offset as local time, so we write:
- 0x61D: the real UTC offset in minutes (e.g. 180 for UTC+3) so the device
can show correct local time on its own display / app.
- 0x61E–0x623: current UTC time so the stored instant is always correct.
"""
utc_now = datetime.now(UTC)
local_offset = datetime.now().astimezone().utcoffset()
tz_minutes = int(local_offset.total_seconds() / 60) if local_offset is not None else 0
tz_u16 = tz_minutes & 0xFFFF # e.g. UTC+3 → 180; UTC-5 → 65531
return [
(REGISTER_U16, tz_u16), # 0x61D: timezone offset in minutes
(REGISTER_U16, utc_now.second), # 0x61E: seconds (UTC)
(REGISTER_U16, utc_now.minute), # 0x61F: minutes (UTC)
(REGISTER_U16, utc_now.hour), # 0x620: hours (UTC)
(REGISTER_U16, utc_now.day), # 0x621: day (UTC)
(REGISTER_U16, utc_now.month), # 0x622: month (UTC)
(REGISTER_U16, utc_now.year % 100), # 0x623: year (UTC)
]
# ================================= Button Declarations ============================================================
BUTTON_TYPES = [
SolaXEVChargerModbusButtonEntityDescription(
name="Sync RTC",
key="sync_rtc",
register=0x61D,
write_method=WRITE_MULTI_MODBUS,
icon="mdi:home-clock",
value_function=value_function_sync_rtc_evc,
entity_category=EntityCategory.CONFIG,
),
]
# ================================= Number Declarations ============================================================
NUMBER_TYPES = [
###
#
# Data only number types
#
###
###
#
# Normal number types
#
###
SolaXEVChargerModbusNumberEntityDescription(
name="Overload Limit",
key="overload_limit",
register=0x611,
fmt="i",
native_min_value=260,
native_max_value=300,
native_step=1,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=NumberDeviceClass.VOLTAGE,
entity_category=EntityCategory.CONFIG,
),
SolaXEVChargerModbusNumberEntityDescription(
name="Undervoltage Limit",
key="undervoltage_limit",
register=0x612,
fmt="i",
native_min_value=80,
native_max_value=160,
native_step=1,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=NumberDeviceClass.VOLTAGE,
entity_category=EntityCategory.CONFIG,
),
SolaXEVChargerModbusNumberEntityDescription(
name="Main Breaker Limit",
key="main_breaker_limit",
register=0x614,
fmt="i",
native_min_value=11,
native_max_value=300,
native_step=1,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=NumberDeviceClass.CURRENT,
entity_category=EntityCategory.CONFIG,
),
SolaXEVChargerModbusNumberEntityDescription(
name="Datahub Charge Current",
key="datahub_charge_current",
register=0x624,
allowedtypes=GEN1, # GEN1 only - not available on GEN2
fmt="f",
native_min_value=6,
native_max_value=32,
native_step=0.1,
scale=0.01,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=NumberDeviceClass.CURRENT,
),
SolaXEVChargerModbusNumberEntityDescription(
name="Charge Current",
key="charge_current",
register=0x628,
fmt="f",
native_min_value=6,
native_max_value=32,
native_step=0.1,
scale=0.01,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=NumberDeviceClass.CURRENT,
),
SolaXEVChargerModbusNumberEntityDescription(
name="Max Charge Current",
key="max_charge_current",
register=0x668,
fmt="f",
native_min_value=6,
native_max_value=32,
native_step=0.1,
scale=0.01,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=NumberDeviceClass.CURRENT,
),
SolaXEVChargerModbusNumberEntityDescription(
name="Modbus Address",
key="modbus_address",
register=0x640,
fmt="i",
native_min_value=1,
native_max_value=247,
native_step=1,
icon="mdi:identifier",
entity_category=EntityCategory.CONFIG,
),
SolaXEVChargerModbusNumberEntityDescription(
name="Smart Boost Energy",
key="smart_boost_energy",
register=0x63A,
fmt="i",
native_min_value=0,
native_max_value=200,
native_step=1,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=NumberDeviceClass.ENERGY,
entity_category=EntityCategory.CONFIG,
),
SolaXEVChargerModbusNumberEntityDescription(
name="OCPP Charge Current",
key="ocpp_charge_current",
register=0x61B,
allowedtypes=OCPP_TYPE,
fmt="f",
native_min_value=6,
native_max_value=32,
native_step=0.001,
scale=0.001,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=NumberDeviceClass.CURRENT,
),
]
# ================================= Select Declarations ============================================================
SELECT_TYPES = [
###
#
# Data only select types
#
###
###
#
# Normal select types
#
###
SolaXEVChargerModbusSelectEntityDescription(
name="Meter Setting",
key="meter_setting",
register=0x60C,
option_dict={
0: "External CT",
1: "External Meter",
2: "Inverter",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:meter-electric",
),
SolaXEVChargerModbusSelectEntityDescription(
name="Charger Use Mode",
key="charger_use_mode",
register=0x60D,
option_dict={
0: "Stop",
1: "Fast",
2: "ECO",
3: "Green",
},
icon="mdi:dip-switch",
),
SolaXEVChargerModbusSelectEntityDescription(
name="ECO Gear",
key="eco_gear",
register=0x60E,
option_dict={
1: "6A",
2: "10A",
3: "16A",
4: "20A",
5: "25A",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:dip-switch",
),
SolaXEVChargerModbusSelectEntityDescription(
name="Green Gear",
key="green_gear",
register=0x60F,
option_dict={
1: "3A",
2: "6A",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:dip-switch",
),
SolaXEVChargerModbusSelectEntityDescription(
name="Start Charge Mode",
key="start_charge_mode",
register=0x610,
allowedtypes=GEN2,
option_dict={
0: "Plug and Charge",
1: "Swipe Card to Start",
2: "App Start",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:lock",
),
SolaXEVChargerModbusSelectEntityDescription(
name="Start Charge Mode",
key="start_charge_mode",
register=0x610,
allowedtypes=GEN1,
option_dict={
0: "Plug and Charge",
1: "Swipe Card to Start",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:lock",
),
SolaXEVChargerModbusSelectEntityDescription(
name="Boost Mode",
key="boost_mode",
register=0x613,
option_dict={
0: "Normal",
1: "Timer Boost",
2: "Smart Boost",
},
icon="mdi:dip-switch",
),
SolaXEVChargerModbusSelectEntityDescription(
name="Charging Mode",
key="evse_scene",
register=0x61C,
allowedtypes=GEN1,
option_dict={
0: "Private",
1: "OCPP",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:dip-switch",
),
SolaXEVChargerModbusSelectEntityDescription(
name="Charging Mode",
key="evse_scene",
register=0x61C,
allowedtypes=GEN2,
option_dict={
0: "PV Mode",
1: "Standard Mode",
2: "OCPP Mode",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:dip-switch",
),
SolaXEVChargerModbusSelectEntityDescription(
name="Charge Phase",
key="charge_phase",
register=0x625,
option_dict={
0: "Three Phase",
1: "L1 Phase",
2: "L2 Phase",
3: "L3 Phase",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:dip-switch",
allowedtypes=X3,
),
SolaXEVChargerModbusSelectEntityDescription(
name="Charge Phase Alt",
key="charge_phase_alt",
register=0x63B,
option_dict={
0: "Three Phase",
1: "L1 Phase",
2: "L2 Phase",
3: "L3 Phase",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:dip-switch",
allowedtypes=X3,
entity_registry_enabled_default=False,
),
SolaXEVChargerModbusSelectEntityDescription(
name="Control Command",
key="control_command",
register=0x627,
option_dict={
0: "No Command",
1: "Available",
2: "Unavailable",
3: "Stop Charging",
4: "Start Charging",
5: "Reserve",
6: "Cancel the Reservation",
},
icon="mdi:dip-switch",
),
SolaXEVChargerModbusSelectEntityDescription(
name="EVSE Mode",
key="evse_mode",
register=0x669,
allowedtypes=GEN2,
option_dict={
0: "Fast",
1: "ECO",
2: "Green",
},
entity_category=EntityCategory.CONFIG,
icon="mdi:dip-switch",
),
]
# ================================= Time Declarations ==============================================================
TIME_TYPES = [
SolaXEVChargerModbusTimeEntityDescription(
name="Timer Boost Start Time",
key="timer_boost_start_time",
register=0x634,
option_dict=TIME_OPTIONS_SEPARATE_REGISTERS,
wordcount=2,
entity_category=EntityCategory.CONFIG,
icon="mdi:clock-start",
),
SolaXEVChargerModbusTimeEntityDescription(
name="Timer Boost End Time",
key="timer_boost_end_time",
register=0x636,
option_dict=TIME_OPTIONS_SEPARATE_REGISTERS,
wordcount=2,
entity_category=EntityCategory.CONFIG,
icon="mdi:clock-end",
),
SolaXEVChargerModbusTimeEntityDescription(
name="Smart Boost End Time",
key="smart_boost_end_time",
register=0x638,
option_dict=TIME_OPTIONS_SEPARATE_REGISTERS,
wordcount=2,
entity_category=EntityCategory.CONFIG,
icon="mdi:clock-end",
),
]
# ================================= Sensor Declarations ============================================================
SENSOR_TYPES_MAIN: list[SolaXEVChargerModbusSensorEntityDescription] = [
###
#
# Holding — internal backing sensors (poll registers for SELECT/NUMBER readback;
# not registered as HA entities — use the SELECT/NUMBER entities instead)
#
###
SolaXEVChargerModbusSensorEntityDescription(
name="Meter Setting",
key="meter_setting",
register=0x60C,
scale={0: "External CT", 1: "External Meter", 2: "Inverter"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charger Use Mode",
key="charger_use_mode",
register=0x60D,
scale={0: "Stop", 1: "Fast", 2: "ECO", 3: "Green"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="ECO Gear",
key="eco_gear",
register=0x60E,
scale={1: "6A", 2: "10A", 3: "16A", 4: "20A", 5: "25A"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Green Gear",
key="green_gear",
register=0x60F,
scale={1: "3A", 2: "6A"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Start Charge Mode",
key="start_charge_mode",
register=0x610,
scale={0: "Plug and Charge", 1: "Swipe Card to Start", 2: "App Start"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Overload Limit",
key="overload_limit",
register=0x611,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Undervoltage Limit",
key="undervoltage_limit",
register=0x612,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Boost Mode",
key="boost_mode",
register=0x613,
scale={0: "Normal", 1: "Timer Boost", 2: "Smart Boost"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Main Breaker Limit",
key="main_breaker_limit",
register=0x614,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Electronic Lock",
key="electronic_lock",
register=0x615,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="RFID Card Activation",
key="rfid_card_activation",
register=0x616,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charging Mode",
key="evse_scene",
register=0x61C,
allowedtypes=GEN1,
scale={0: "Private", 1: "OCPP"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charging Mode",
key="evse_scene",
register=0x61C,
allowedtypes=GEN2,
scale={0: "PV Mode", 1: "Standard Mode", 2: "OCPP Mode"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="RTC",
key="rtc",
register=0x61D,
register_data_type=REGISTER_WORDS,
wordcount=7,
scale=value_function_rtc_evc,
device_class=SensorDeviceClass.TIMESTAMP,
entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:clock",
),
SolaXEVChargerModbusSensorEntityDescription(
name="Datahub Charge Current",
key="datahub_charge_current",
register=0x624,
allowedtypes=GEN1,
scale=0.01,
rounding=1,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Phase",
key="charge_phase",
register=0x625,
scale={0: "Three Phase", 1: "L1 Phase", 2: "L2 Phase", 3: "L3 Phase"},
allowedtypes=X3,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Phase Alt",
key="charge_phase_alt",
register=0x63B,
scale={0: "Three Phase", 1: "L1 Phase", 2: "L2 Phase", 3: "L3 Phase"},
allowedtypes=X3,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Current",
key="charge_current",
register=0x628,
scale=0.01,
rounding=1,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Control Command",
key="control_command",
register=0x627,
scale={
0: "No Command",
1: "Available",
2: "Unavailable",
3: "Stop Charging",
4: "Start Charging",
5: "Reserve",
6: "Cancel the Reservation",
},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Max Charge Current",
key="max_charge_current",
register=0x668,
scale=0.01,
rounding=1,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="EVSE Mode",
key="evse_mode",
register=0x669,
allowedtypes=GEN2,
scale={0: "Fast", 1: "ECO", 2: "Green"},
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Modbus Address",
key="modbus_address",
register=0x640,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Timer Boost Start Time",
key="timer_boost_start_time",
register=0x634,
register_data_type=REGISTER_WORDS,
wordcount=2,
scale=value_function_separate_registers_time,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Timer Boost End Time",
key="timer_boost_end_time",
register=0x636,
register_data_type=REGISTER_WORDS,
wordcount=2,
scale=value_function_separate_registers_time,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Smart Boost End Time",
key="smart_boost_end_time",
register=0x638,
register_data_type=REGISTER_WORDS,
wordcount=2,
scale=value_function_separate_registers_time,
internal=True,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Smart Boost Energy",
key="smart_boost_energy",
register=0x63A,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
internal=True,
),
###
#
# Input — 0x0100+
# 0x0100-0x0102: ChargePower L1 (A) / L2 (B) / L3 (C) also available at 0x08-0x0A; exposed here with Alt suffix
#
###
# ---- 0x0100–0x0102 Phase powers alt for L1 (A) / L2 (B) / L3 (C), disabled by default ----
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Power L1 Alt",
key="charge_power_l1_alt",
register=0x100,
register_type=REG_INPUT,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Power L2 Alt",
key="charge_power_l2_alt",
register=0x101,
register_type=REG_INPUT,
allowedtypes=X3,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Power L3 Alt",
key="charge_power_l3_alt",
register=0x102,
register_type=REG_INPUT,
allowedtypes=X3,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Max Power Charging",
key="max_power_charging",
register=0x103,
register_type=REG_INPUT,
scale={0: "No", 1: "Yes"},
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:lightning-bolt",
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Mode Active",
key="charge_mode_active",
register=0x104,
register_type=REG_INPUT,
scale={0: "Fast", 1: "ECO", 2: "Green"},
icon="mdi:dip-switch",
),
SolaXEVChargerModbusSensorEntityDescription(
name="Green Mode Start Power",
key="green_mode_start_power",
register=0x105,
register_type=REG_INPUT,
native_unit_of_measurement=UnitOfPower.WATT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:solar-power",
),
SolaXEVChargerModbusSensorEntityDescription(
name="Run Mode Alt",
key="charger_status",
register=0x106,
register_type=REG_INPUT,
scale={
0: "Available",
1: "Preparing",
2: "Charging",
3: "Finishing",
4: "Faulted",
5: "Unavailable",
6: "Reserved",
7: "Suspended EV",
8: "Suspended EVSE",
9: "Update",
10: "Card Activation",
11: "Start Delay",
12: "Charge Paused",
13: "Stopping",
},
entity_registry_enabled_default=False,
icon="mdi:ev-station",
),
###
#
# Input
#
###
# ---- 0x0000–0x0002 Phase voltages L1 (A) / L2 (B) / L3 (C), 0.01V ----
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Voltage",
key="charge_voltage",
register=0x0,
register_type=REG_INPUT,
scale=0.01,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
allowedtypes=X1,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Voltage L1",
key="charge_voltage_l1",
register=0x0,
register_type=REG_INPUT,
allowedtypes=X3,
scale=0.01,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Voltage L2",
key="charge_voltage_l2",
register=0x1,
register_type=REG_INPUT,
allowedtypes=X3,
scale=0.01,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Voltage L3",
key="charge_voltage_l3",
register=0x2,
register_type=REG_INPUT,
allowedtypes=X3,
scale=0.01,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
),
# ---- 0x0003 PE voltage (GEN2 doc: VoltagePE, 0.01V) ----
SolaXEVChargerModbusSensorEntityDescription(
name="Charge PE Voltage",
key="charge_pe_voltage",
register=0x3,
register_type=REG_INPUT,
scale=0.01,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE,
entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC,
),
# ---- 0x0004–0x0006 Phase currents L1 (A) / L2 (B) / L3 (C), 0.01A ----
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Current",
key="charge_current",
register=0x4,
register_type=REG_INPUT,
scale=0.01,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
allowedtypes=X1,
entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Current L1",
key="charge_current_l1",
register=0x4,
register_type=REG_INPUT,
allowedtypes=X3,
scale=0.01,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Current L2",
key="charge_current_l2",
register=0x5,
register_type=REG_INPUT,
allowedtypes=X3,
scale=0.01,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
),
SolaXEVChargerModbusSensorEntityDescription(
name="Charge Current L3",
key="charge_current_l3",
register=0x6,
register_type=REG_INPUT,
allowedtypes=X3,
scale=0.01,
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
device_class=SensorDeviceClass.CURRENT,
),
# ---- 0x0007 PE current (GEN2 doc: CurrentPE, 0.001A) ----
SolaXEVChargerModbusSensorEntityDescription(
name="Charge PE Current",
key="charge_pe_current",
register=0x7,
register_type=REG_INPUT,
native_unit_of_measurement=UnitOfElectricCurrent.MILLIAMPERE,
device_class=SensorDeviceClass.CURRENT,
entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC,
),
# ---- 0x0008–0x000A Phase powers L1 (A) / L2 (B) / L3 (C), 1W ----
SolaXEVChargerModbusSensorEntityDescription(