I have a APSystems installation which I would like to connect to my Home Assistant installation.
I have searched the forum, but only found people who had a different ECU than mine. I do not start at nothing though, because I’m coming from Domoticz and already foudn and adjusted a script that generates a output like this:
Via a ‘regular’ shell. I run it with python. I previously ran it via Node-RED and someone helped processing the data to prepare it for Domoticz, then sent it to the API.
Which ECU do you have?
How do you get these data?
If you can’t use the ECU custom integration you may be able to use command_line, rest or modbus integrations
I have added the lines, replacing the command with a simple ‘cat output.txt’ for easy debugging.
When checking the config, I recieved the following error:
> Invalid config for [sensor.command_line]: [device_class] is an invalid option for [sensor.command_line]. Check: sensor.command_line->device_class. (See ?, line ?).
> Invalid config for [sensor.command_line]: [device_class] is an invalid option for [sensor.command_line]. Check: sensor.command_line->device_class. (See ?, line ?).
> Invalid config for [sensor.command_line]: [device_class] is an invalid option for [sensor.command_line]. Check: sensor.command_line->device_class. (See ?, line ?).
When commenting out the device_class and restarting, I got no errors but I could not find any devices, integrations or entities.
I’m sorry if I skipped some step or done something wrong, I’m still very new to Home Assistant
You are right for device_class I made a mistake and updated my code.
You should have at least 4 entities and one named sensor.microinverter_1_power. If not, you should have errors in logs
Thank you. I have updated the code, I again recieve a error, but a different one:
Error loading /config/configuration.yaml: while parsing a block mapping
in "/config/configuration.yaml", line 3, column 1
expected <block end>, but found '-'
in "/config/configuration.yaml", line 18, column 1
Note that this is my first and only modification to the configuration.yaml file. I have pasted the code below the stuff that was already there.
Thank you, I think it is working, I have 4 entities now.
Now that this is working, I have 3 questions:
-Is it possible to add some flag so I can use the created devices in the Energy dashboard?
-How can I create a new entity which combines the power of all modules?
-I need to run a Python script in order to get the output. What would be the easiest way to do this? Run the script on another VM and scp the output to HA? Or somehow get python to function within HA?
The energy dashboard uses energy entities (in kWh). I think that you won’t be able to use those entities as it is in Watt.
Go to settings, Devices & Services, Helpers then create a new helper type “group”, “sensor group”. Add a name, all your power entities, and select “Sum” as Type.
This will create a new entity which will be the sum of all your power entities. For example: sensor.power_summation
Then in your config folder, create a file named customize.yaml.
In this file, add:
sensor.power_summation:
state_class: measurement
device_class: power
Then in your configuration.yaml file, add this:
homeassistant:
customize: !include customize.yaml
Then restart Home Assistant.
Then, you will be able to create a new helper type utility_meter that will create an energy sensor in kWh that you will be able to add to the energy dashboard.
I don’t know if this will work but you can try to put the script in your config folder, then run it in a new command_line sensor:
Sorry for my late response, it was quite a lot of work copying and modifying all lines to get all inverters to show up.
I followed your instructions, and I how have a group that summarizes the inverters, I also have a utility meter with the expected results, but I am not able to select it in the Energy Dashboard. Do you have any idea what is going on?
As to how I’m reading the file, I have another VM set up to run the script and scp it to the Home Assistant VM. Python wasn’t available so this was the easiest solution for now.
To be able to add this new entity to the Energy Dashboard, it needs some attributes. You can check these in Developer Tools > States and search for your utility_meter entity. It needs state_class = total_increasing and device_class = energy.
If these are missing, edit your customize.yaml file to add this:
sensor.<your sensor name>:
state_class: total_increasing
device_class: energy
In the customize.yaml I have used the sensor ID of the utility meter. Is this correct?
When I go to the utility meter sensor, it shows the power in W, not kWh. I am also not able to add the sensor to the Energy Dashboard.
I also noticed in your instructions earlier I had to set the device_class to power. Now I need to set it to energy, correct?
Your entity which is the sum of all your power sensor (from the group helper) should be in W and have state_class: measurement and device_class: power.
The sensor from the utility_meter should be in Wh or kWh and have state_class: total_increasing and device_class: energy