Skip to content

Commit dd3df0e

Browse files
author
Jan C
committed
some work on developer guide doc page
1 parent 0ee0351 commit dd3df0e

1 file changed

Lines changed: 67 additions & 4 deletions

File tree

docs/developer_guide.md

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,94 @@ Following sections will appear some day:
77

88
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.
1011

1112
### Common attributes for all entities
1213

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+
1320
To be completed
1421

1522
### Attributes for sensor entities:
1623

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_
1840

1941
### Attributes for number entities:
2042

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
2257

2358
### Attributes for select entities:
2459

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
2666

2767
### Attributes for button entities:
2868

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+
3090

3191

3292
## Autorepeat mechanism for buttons
3393

3494
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.
3595
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.
3696
The meaning of the parameters of a button value function is:
97+
3798
* initval: either BUTTONREPEAT_FIRST, BUTTONREPEAT_LOOP, BUTTONREPEAT_POST
3899
* BUTTONREPEAT_FIRST indicates it is the first call, usually a manual button press
39100
* BUTTONREPEAT_LOOP indicates subsequent autorepeated calls
@@ -45,7 +106,9 @@ In its current form, the function should return a dictionary containing followin
45106
* 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.
46107
* register (optional): if not specified, the register address for the autorepeat button will be used
47108
* 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+
48110
In the future, the return value may be extended to allow other types of writes (to different addresses).
49111
The system will automatically compute the length of the write_multiple payload to be executed.
50112

51113
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.
114+
____

0 commit comments

Comments
 (0)