Skip to content

Commit aabe151

Browse files
authored
Update developer_guide.md
1 parent 503196f commit aabe151

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

docs/developer_guide.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ This section describes some internal mechanisms of this integration. It is mainl
55
Following sections will appear some day:
66
## Attributes for entities
77

8-
Entities are declared in the plugin_xxx.py files.
8+
Entities are declared in the `plugin_xxx.py` files.
99
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.
1111

1212
### Common attributes for all entities
1313

@@ -77,43 +77,43 @@ To be documented:
7777
To be documented:
7878

7979
* _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`
8181
* _sensor_key_: str = None # The associated sensor key
8282
* _initvalue_: int = None # initial default value for WRITE_DATA_LOCAL entities
8383

8484

8585
## 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.
8989
Documentation to be completed ...
9090

9191
## Scan groups for differentiated polling
9292
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 ...
9494

9595

9696

9797
## Autorepeat mechanism for buttons
9898

9999
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.
101101
The meaning of the parameters of a button autorepeat value_function is:
102102

103-
* initval: either BUTTONREPEAT_FIRST, BUTTONREPEAT_LOOP, BUTTONREPEAT_POST
104-
* BUTTONREPEAT_FIRST indicates it is the first call, usually a manual button press
105-
* BUTTONREPEAT_LOOP indicates subsequent autorepeated calls
106-
* BUTTONREPEAT_POST is called after the loop is finished
103+
* initval: either `BUTTONREPEAT_FIRST`, `BUTTONREPEAT_LOOP`, `BUTTONREPEAT_POST`
104+
* `BUTTONREPEAT_FIRST` indicates it is the first call, usually a manual button press
105+
* `BUTTONREPEAT_LOOP` indicates subsequent autorepeated calls
106+
* `BUTTONREPEAT_POST` is called after the loop is finished
107107
* descr: the entity description object of the button
108108
* datadict: the dictionary with all the known entity values
109109

110110
In its current form, the function should return a dictionary containing following items:
111111
* 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.
112112
* 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.
114114

115115
In the future, the return value may be extended to allow other types of writes (to different addresses).
116116
The system will automatically compute the length of the write_multiple payload to be executed.
117117

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.
119119
____

0 commit comments

Comments
 (0)