You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developer_guide.md
+67-4Lines changed: 67 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,33 +7,94 @@ Following sections will appear some day:
7
7
8
8
Entities are declared in the plugin_xxx.py files.
9
9
Each type of entity may support different attributes.
10
+
The entity types are also briefly documented in the const.py file.
10
11
11
12
### Common attributes for all entities
12
13
14
+
Most of the attributes are optional or have a meaningfull default value
15
+
16
+
*_allowedtypes_: int = 0 # overload with ALLDEFAULT from plugin
17
+
*_register_
18
+
*_blacklist_: # None or list of serial number prefixes like ["XRE",] for which the entity will not appear
19
+
13
20
To be completed
14
21
15
22
### Attributes for sensor entities:
16
23
17
-
To be completed
24
+
To be documented:
25
+
26
+
*_scale_
27
+
*_read_scale_exceptions_
28
+
*_read_scale_
29
+
*_rounding_
30
+
*_register_type_: REGISTER_HOLDING, REGISTER_INPUT or REG_DATA
31
+
*_unit_: int = None # optional for WRITE_DATA_LOCAL e.g REGISTER_U16, REGISTER_S32 ...
32
+
*_internal_
33
+
*_newblock_: the system automatically builds blocks of registers that will be polled together, a newblock attribute indicates that a newblock should start at this address. Do not use too many newblock statements as the polling cycle may contain too many operations.
34
+
*_value_function_
35
+
*_sleepmode_: either SLEEPMODE_LAST (default), SLEEPMODE_ZERO or SLEEPMODE_NONE
36
+
*_ignore_readerror_
37
+
*_value_series_
38
+
*_min_value_
39
+
*_max_value_
18
40
19
41
### Attributes for number entities:
20
42
21
-
To be completed
43
+
To be documented:
44
+
45
+
*_read_scale_exceptions_: list = None
46
+
*_read_scale_: float = 1
47
+
*_fmt_: str = None
48
+
*_scale_: float = 1
49
+
*_state_: str = None
50
+
*_max_exception_s: list = None # None or list with structue [ ('U50EC' , 40,) ]
51
+
*_min_exceptions_minus_: list = None # same structure as max_exceptions, values are applied with a minus
52
+
*_write_method_: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL
53
+
*_initvalue_: int = None # initial default value for WRITE_DATA_LOCAL entities
54
+
*_unit_: int = None # optional for WRITE_DATA_LOCAL e.g REGISTER_U16, REGISTER_S32 ...
55
+
*_prevent_update_: bool = (
56
+
False # if set to True, value will not be re-read/updated with each polling cycle; only when read value changes
22
57
23
58
### Attributes for select entities:
24
59
25
-
To be completed
60
+
To be documented:
61
+
62
+
*_option_dict_: dict = None
63
+
*_reverse_option_dict_: dict = None # autocomputed - do not specify
64
+
*_write_method_: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL
65
+
*_initvalue_: int = None # initial default value for WRITE_DATA_LOCAL entities
26
66
27
67
### Attributes for button entities:
28
68
29
-
To be completed
69
+
To be documented:
70
+
71
+
*_command_
72
+
*_write_method_
73
+
*_autorepeat_ : see separate documentation on autorepeat buttons
74
+
75
+
### Attributs for switch entities:
76
+
77
+
To be documented:
78
+
79
+
*_register_bit_: int = None
80
+
*_write_method_: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL
81
+
*_sensor_key_: str = None # The associated sensor key
82
+
*_initvalue_: int = None # initial default value for WRITE_DATA_LOCAL entities
83
+
84
+
85
+
86
+
## Scan groups for differentiated polling
87
+
Some inverter plugins use different scan groups (to differentiate between slowly changing sensor entities and entities that are updated frequently?)
88
+
To be documented
89
+
30
90
31
91
32
92
## Autorepeat mechanism for buttons
33
93
34
94
A button can have the attribute autorepeat, an attribute that specifies the entity_key of the entity that holds the duration over which the button press will be repeated automatically.
35
95
If a button has the autorepeat attribute autorepeat, the button declaration must also have a value_function attribute. The specified value function will be called for each autorepeat loop interation.
36
96
The meaning of the parameters of a button value function is:
97
+
37
98
* initval: either BUTTONREPEAT_FIRST, BUTTONREPEAT_LOOP, BUTTONREPEAT_POST
38
99
* BUTTONREPEAT_FIRST indicates it is the first call, usually a manual button press
@@ -45,7 +106,9 @@ In its current form, the function should return a dictionary containing followin
45
106
* action: the modbus type of write to be executed: currently only MODBUS_WRITE_MULTI is suppored, but the other writes can be easily added later.
46
107
* register (optional): if not specified, the register address for the autorepeat button will be used
47
108
* data: a list of tuples [ (entity_key, value,), ....] that represents the payload of a write_multiple command that starts at the modbus register addres. Instead of the entity_key_name, a register type can also be specified like REGISTER_U16. The payload should not contain the button's entity itself, just the data that needs to be added in the write_multiple scenario.
109
+
48
110
In the future, the return value may be extended to allow other types of writes (to different addresses).
49
111
The system will automatically compute the length of the write_multiple payload to be executed.
50
112
51
113
The autorepeat value_function is called once for every polling loop, so it is up to the value function to reduce the number of interactions if desired. Currently, the value_function cannot pass data to the next polling cycle's value_function's call. This could be enhanced as using global variables is not considered a best practice (may fail in case of multiple inverters/hubs). Storing this data in the descr._hub object may be better, but it is still not very transparent.
0 commit comments