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
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,9 @@ This section describes some internal mechanisms of this integration. It is mainl
5
5
Following sections will appear some day:
6
6
## Attributes for entities
7
7
8
-
Entities are declared in the plugin_xxx.py files.
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
+
The entity types are also briefly documented in the `const.py` file.
11
11
12
12
### Common attributes for all entities
13
13
@@ -77,43 +77,43 @@ To be documented:
77
77
To be documented:
78
78
79
79
*_register_bit_: int = None
80
-
*_write_method_: int = WRITE_SINGLE_MODBUS # WRITE_SINGLE_MOBUS or WRITE_MULTI_MODBUS or WRITE_DATA_LOCAL
80
+
*_write_method_: int = `WRITE_SINGLE_MODBUS` # `WRITE_SINGLE_MOBUS` or `WRITE_MULTI_MODBUS` or `WRITE_DATA_LOCAL`
81
81
*_sensor_key_: str = None # The associated sensor key
82
82
*_initvalue_: int = None # initial default value for WRITE_DATA_LOCAL entities
83
83
84
84
85
85
## Local Data Entities
86
-
The integration can create entities that have no corresponding modbus register. These entities can be used as parameter for automations or as parameter of an autorepeat loop. These local data entities have the attribute **write_method=WRITE_LOCAL_DATA**.
87
-
Their initial value is determined by attribute **initval**.
88
-
Local variables are made persistent across reboots as they are stored in the config/SolaX_data.json file periodically after a change of data.
86
+
The integration can create entities that have no corresponding modbus register. These entities can be used as parameter for automations or as parameter of an autorepeat loop. These local data entities have the attribute `write_method=WRITE_LOCAL_DATA`.
87
+
Their initial value is determined by attribute `initval`.
88
+
Local variables are made persistent across reboots as they are stored in the `config/SolaX_data.json` file periodically after a change of data.
89
89
Documentation to be completed ...
90
90
91
91
## Scan groups for differentiated polling
92
92
Some inverter plugins use different scan groups (to differentiate between slowly changing sensor entities and entities that are updated frequently?)
93
-
To be documented
93
+
To be documented ...
94
94
95
95
96
96
97
97
## Autorepeat mechanism for buttons
98
98
99
99
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.
100
-
If a button has the attribute **autorepeat**, the button declaration must also have a value_function attribute. The specified value function will be called for each autorepeat loop interation.
100
+
If a button has the attribute **autorepeat**, the button declaration must also have a `value_function` attribute. The specified value function will be called for each autorepeat loop interation.
101
101
The meaning of the parameters of a button autorepeat value_function is:
102
102
103
-
* initval: either BUTTONREPEAT_FIRST, BUTTONREPEAT_LOOP, BUTTONREPEAT_POST
104
-
* BUTTONREPEAT_FIRST indicates it is the first call, usually a manual button press
*`BUTTONREPEAT_POST` is called after the loop is finished
107
107
* descr: the entity description object of the button
108
108
* datadict: the dictionary with all the known entity values
109
109
110
110
In its current form, the function should return a dictionary containing following items:
111
111
* 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.
112
112
* register (optional): if not specified, the register address for the autorepeat button will be used
113
-
* 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.
113
+
* 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.
114
114
115
115
In the future, the return value may be extended to allow other types of writes (to different addresses).
116
116
The system will automatically compute the length of the write_multiple payload to be executed.
117
117
118
-
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.
118
+
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. Storing data in the `datadict` dictionary may work in future versions, please use a name that cannot conflict with other entities.
0 commit comments