Skip to content

Defining custom sensors

Thijs W. edited this page Jul 21, 2024 · 4 revisions

This integration ships with already a lot of sensors by default. Some of the less popular sensors are disabled by default, but can be enabled by going to the settings page of the relevant device, clicking on +XX entities not shown, clicking in the relevant sensor and then clicking Enable in the settings window.

The sensors made available by this integration were chosen because of their relevance and because of technical feasibility (limiting the number of requests sent to the inverter on each update).

If the sensor you want is not listed, but you found a relevant register in the "Huawei Solar Modbus Definitions" PDF file, you can choose to add the sensor yourself by editing the sensor.py file from this integration.

Warning

This is an advanced subject which comes with NO SUPPORT whatsoever.

You should only proceed if you have sufficient knowledge and understanding of Python code.

Any bug report or feature request will be closed without any answer.

You will need to reapply the changes to sensor.py after each update.

Steps for creating your own custom sensors

  1. Check register_names.py and/or registers.py to see if the register you want to read is supported by the underlying huawei-solar library. Is the register you want missing? Then please submit a PR against the library (cfr. example commit with new register definitions)

  2. Go to sensor.py and add an extra HuaweiSolarSensorEntityDescription to the correct list: INVERTER_SENSOR_DESCRIPTIONS for inverter-related registers, BATTERIES_SENSOR_DESCRIPTIONS for battery-related registers, etc.

  3. Add a translation for your new sensor to strings.json, and translations/en.json (or for the language that you are using).

  4. Restart your HA to apply your code changes.

You can look at the following PR to get a sense of which changes are needed: PR #768 .

Support

Please resolve any questions you have or problems you encounter yourself. NO SUPPORT WHATSOEVER IS PROVIDED BY THE MAINTAINER OF THIS LIBRARY.

I do invite you to edit this page to add extra information you found to be missing, or to submit a PR against the user-defined-extra-sensors branch if it becomes outdated.