solis2MQTT register help with Unit of Measurement

Hi there,

I’m using solis2MQTT to send data from my solar inverter to HA, using MQTT.

I have some errors, which I think will be simple to resolve once I know the answer to the question below.

Here is the error

Logger: homeassistant.util.logging
Source: util/logging.py:156 
First occurred: 27 January 2023 at 14:10:38 (3 occurrences) 
Last logged: 27 January 2023 at 14:10:38

Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'name': 'Battery Status', 'state_topic': 'solis2mqtt/battery_status', 'unique_id': 'solis2mqtt/battery_status', 'device_class': None, 'state_class': 'measurement', 'unit_of_measurement': None, 'device': {'name': 'solis2mqtt', 'model': 'solis2mqtt', 'manufacturer': 'Ginlong Technologies', 'identifiers': 'solis2mqtt', 'sw_version': 'solis2mqtt 0.7'}, 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 331, in async_discover config: DiscoveryInfoType = discovery_schema(discovery_payload) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 232, in __call__ return self._exec((Schema(val) for val in self.validators), v) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 355, in _exec raise e if self.msg is None else AllInvalid(self.msg, path=path) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 351, in _exec v = func(v) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable return schema(data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: string value is None for dictionary value @ data['unit_of_measurement']
Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'name': 'Storage Mode', 'state_topic': 'solis2mqtt/storage_mode', 'unique_id': 'solis2mqtt/storage_mode', 'device_class': None, 'state_class': None, 'unit_of_measurement': None, 'device': {'name': 'solis2mqtt', 'model': 'solis2mqtt', 'manufacturer': 'Ginlong Technologies', 'identifiers': 'solis2mqtt', 'sw_version': 'solis2mqtt 0.7'}, 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 331, in async_discover config: DiscoveryInfoType = discovery_schema(discovery_payload) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 232, in __call__ return self._exec((Schema(val) for val in self.validators), v) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 355, in _exec raise e if self.msg is None else AllInvalid(self.msg, path=path) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 351, in _exec v = func(v) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable return schema(data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: string value is None for dictionary value @ data['unit_of_measurement']
Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'name': 'Inverter Status', 'state_topic': 'solis2mqtt/inverter_status', 'unique_id': 'solis2mqtt/inverter_status', 'device_class': None, 'state_class': None, 'unit_of_measurement': None, 'device': {'name': 'solis2mqtt', 'model': 'solis2mqtt', 'manufacturer': 'Ginlong Technologies', 'identifiers': 'solis2mqtt', 'sw_version': 'solis2mqtt 0.7'}, 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 331, in async_discover config: DiscoveryInfoType = discovery_schema(discovery_payload) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 232, in __call__ return self._exec((Schema(val) for val in self.validators), v) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 355, in _exec raise e if self.msg is None else AllInvalid(self.msg, path=path) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 351, in _exec v = func(v) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable return schema(data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: string value is None for dictionary value @ data['unit_of_measurement']

It would appear to me that ‘Battery Status’, ‘Storage Mode’ and ‘Inverter Status’ are missing a ‘unit_of_measurement’ value, or that ‘None’ is being incorrectly sent.

The values for these registers are:

Battery Status: 1 / 0

# Batt status - 33135  0 = Charge / 1 = Discharge
- name: battery_status
  description: Battery Status
  unit:
  active: true
  modbus:
    register: 33135
    read_type: register
    number_of_decimals: 0
    function_code: 4
    signed: false
  homeassistant:
    device: number
    min: 0
    max: 1
    step: 1

Storage Mode: 33 / 35

# Battery storage mode, 33=self use, 35=timed charge
- name: storage_mode
  description: Storage Mode
  unit:
  active: true
  modbus:
    register: 43110
    read_type: register
    number_of_decimals: 0
    function_code: 3
    signed: false
  homeassistant:
    device: number
    min: 33
    max: 35
    step: 1

Inverter Status is an odd one because it doesn’t look like I’m even sending that register… Does MQTT retain old messages but still report errors against them?

Is there an appropriate unit I can assign to these registers which are essential just numbers to overcome the errors?

Any help much appreciated!

Thanks