Modbus sensor
Adding a modbus sensor is pretty easy. Follow developer guide in this section, copy eg sdm120.json to be your template (https://raw.githubusercontent.com/boneIO-eu/app_black/dev/boneio/sensor/modbus/sdm120.json)
Configuration variables:
- model - model to show in Home Assistant.
- registers_base - array of registers. You can read multiple registers at once, it's more CPU friendly.
- base - start index to read
- length - how many registers to read
- registers - array how to interpret data received from modbus device
- name: Name of sensor
- address - address to read
- unit_of_measurement - unit of measurement
- state_class - either measurement, total, total_increasing. Read more https://developers.home-assistant.io/docs/core/entity/sensor/
- device_class - device class to display in HA - https://developers.home-assistant.io/docs/core/entity/sensor/
- return_type: which function to use to parse data - check out modbus sensor source code.
- value_type: define this or return_type. Possible value types are listed below.
VALUE_TYPES = {
"U_WORD": {"f": "decode_16bit_uint", "byteorder": Endian.Big},
"S_WORD": {"f": "decode_16bit_int", "byteorder": Endian.Big},
"U_DWORD": {"f": "decode_32bit_uint", "byteorder": Endian.Big},
"S_DWORD": {"f": "decode_32bit_int", "byteorder": Endian.Big},
"U_DWORD_R": {"f": "decode_32bit_uint", "byteorder": Endian.Little},
"S_DWORD_R": {"f": "decode_32bit_int", "byteorder": Endian.Little},
"U_QWORD": {"f": "decode_64bit_uint", "byteorder": Endian.Big},
"S_QWORD": {"f": "decode_64bit_int", "byteorder": Endian.Big},
"U_QWORD_R": {"f": "decode_64bit_uint", "byteorder": Endian.Little},
"FP32": {"f": "decode_32bit_float", "byteorder": Endian.Big},
"FP32_R": {"f": "decode_32bit_float", "byteorder": Endian.Little},
}