API integration for Solplanet inverter (AISWEI)

Good afternoon,

I have had everything working fine for about 8 months, but since a few days the template sensors no longer seem to work, they indicate unknown in the developer tools.

When I fill in the template in the template tab, I just see a value.
Seems like template.yaml is no longer being read.

More people suffer from this.

I’ve got this issue to…

If I restart home assistant when the sun is shining, the template sensor is read correctly. But when the dongle gives no output at night, the template sensor is shown as unavailable and does not show up the next day. Then a restart brings it back.
Is there any kind of configuration to restart the template integration ?

Friends, I’m from Brazil.
I have a problem with the integration, I did all the steps listed, but only the data coming from the inverter appears, what was configured in the template does not appear in the HA, and when I try to apply sensors to the energy tab nothing appears, could you help me?

hi, what do you mean wrong sensor names? i copy paste the lines and got an error: Invalid config for ‘sensor’ at sensor_solar.yaml, line 1: required key ‘platform’ not provided . pls help

  • platform: rest
    resource: http://192.168.1.xx:8484/getdevdata.cgi?device=2&sn=SZ001260xxxx
    scan_interval: “00:00:10”
    name: Solplanet PV
    value_template: “OK”
    json_attributes:
    • flg # ???
    • tim # date/time
    • tmp # inverter temperature / 10
    • fac # frequency / 100
    • pac # actual power watt
    • sac # apparent power
    • qac # reactive power
    • eto # total produced / 10
    • etd # total producted daily / 10
    • hto # running time
    • pf # ???
    • wan # ???
    • err # ???
    • vac # voltage / 10
    • iac # current / 10
    • vpv # string voltage
    • ipv # string current
    • str

Hey, you have no dot in your sensor.yaml? Just for question… The yaml starts with minus platform: rest
When you rename your sensor, instead of solplanet PV in my private pv you have to rename the sensors in the template.yaml to. That’s what it means

Hello Kevin, thanks for the quick reply.
Now in the dashboard the Solplanet PV status is “ok” but everything is unavalaible

Here is my code : template_solar.yaml

  • sensor:
    • name: “Solplanet PV Produktion”
      unique_id: solplanet_current_production
      state: “{{ state_attr(‘sensor.solplanet_pv_produktion’, ‘pac’) | float }}”
      unit_of_measurement: “W”
      device_class: energy
      state_class: measurement
      icon: mdi:transmission-tower-export

    • name: “Solplanet PV Tageswert”
      unique_id: solplanet_daily_production
      state: “{{ state_attr(‘sensor.solplanet_pv_tageswert’, ‘etd’) | float / 10 }}”
      unit_of_measurement: “kWh”
      device_class: energy
      state_class: total_increasing

    • name: “Solplanet PV gesamt”
      unique_id: solplanet_total_production
      state: “{{ state_attr(‘sensor.solplanet_pv_gesamt’, ‘eto’) | float / 10 }}”
      unit_of_measurement: “kWh”
      device_class: energy
      state_class: total_increasing

    • name: “Solplanet PV Temperatur”
      unique_id: solplanet_temperature
      state: “{{ state_attr(‘sensor.solplanet_pv_temperatur’, ‘tmp’) | float / 10 }}”
      unit_of_measurement: “°C”
      device_class: temperature
      state_class: measurement

template_solar.yaml :

  • platform: rest
    resource: http://192.168.1.xxx:8484/getdevdata.cgi?device=2&sn=SZ0012602225xxxx
    scan_interval: “00:00:10”
    name: Solplanet PV
    value_template: “OK”
    json_attributes:
    • flg # ???
    • tim # date/time
    • tmp # inverter temperature / 10
    • fac # frequency / 100
    • pac # actual power watt
    • sac # apparent power
    • qac # reactive power
    • eto # total produced / 10
    • etd # total producted daily / 10
    • hto # running time
    • pf # ???
    • wan # ???
    • err # ???
    • vac # voltage / 10
    • iac # current / 10
    • vpv # string voltage
    • ipv # string current
    • str

Any idea what could be the problem? Thanks in advance

That what I mean in my post of names. You named it solplanet PV so your unique IDs have to be renamed to solplanet_pv_ptoduction ins the template.yaml
Then do a restart and everything should work

Thank you ! Works

Can you past you final code here? I get the following error:
Error loading /config/configuration.yaml: mapping values are not allowed here
in “/config/template_solar.yaml”, line 32, column 13

Hi there

II am considering buying a Solplanet hybrid inverter with battery. but has anyone succeeded in being able to control when batteries charge/discharge in HA, as well as being able to set export to 0

my wish is to use HA to control the inverter in relation to sun hours and the electricity price. a bit like their own AI can

Have someone been able to set parameters in the inverter over the API?
I have an hybrid inverter with battery and was hoping to be able to define when the battery should be charged/discharged depending on eletrical prices etc.

looking in to this i found like for all devices 2 api replies, meter, battery inverter,
should these be added each time ?
if so what would be the best approach?

@derkorte if possible could we do a teams session to get me in the good direction?
totally new in the HA config

I will try to give you some instroduktion, but i havent any battery connected so i have no experience to integrate it in HA

Use file editor in your root folder usually named config folder, cause its the folder where your configuration.yaml is stored.

Add These lines to your configuration.yaml and save it:

sensor: !include sensor.yaml
template: !include template.yaml

image

Create a new file in your config folder (If its already there edit it) named:

sensor.yaml

and add following:

  • platform: rest
    resource: http://YOUR.IP.HERE:8484/getdevdata.cgi?device=2&sn=YOUR.SERIAL.NUMBER.OF.WIFI.DONGLE.OR.INVERTER(ethern.only)
    scan_interval: ‘10’
    name: XXXXX
    value_template: “OK”
    json_attributes:
    • flg # ???
    • tim # date/time
    • tmp # inverter temperature / 10
    • fac # frequency / 100
    • pac # actual power watt
    • sac # apparent power
    • qac # reactive power
    • eto # total produced / 10
    • etd # total producted daily / 10
    • hto # running time
    • pf # ???
    • wan # ???
    • err # ???
    • vac # voltage / 10
    • iac # current / 10
    • vpv # string voltage
    • ipv # string current
    • str

click save!

back to config folder.
create new file named:

template.yaml

add following:

sensor:

  • name: “XXXXX_current_production”
    unique_id: XXXXX_current_production
    state: “{{ state_attr(‘XXXXX’, ‘pac’) | float }}”
    unit_of_measurement: “W”
    device_class: energy
    state_class: measurement

    • name: “XXXXX_daily_production”
      unique_id: XXXXX_daily_production
      state: “{{ state_attr(‘XXXXX’, ‘etd’) | float / 10 }}”
      unit_of_measurement: “kWh”
      device_class: energy
      state_class: total_increasing

    • name: “XXXXX_total_production”
      unique_id: XXXXX_total_production
      state: “{{ state_attr(‘XXXXX’, ‘eto’) | float / 10 }}”
      unit_of_measurement: “kWh”
      device_class: energy
      state_class: total_increasing

    • name: “XXXXX_temperature”
      unique_id: XXXXX_temperature
      state: “{{ state_attr(‘XXXXX’, ‘tmp’) | float / 10 }}”
      unit_of_measurement: “°C”
      device_class: temperature
      state_class: measurement

Replace the XXXXX with your name choosed in the sensor.yaml (important!)

then do a restart and you should have new entitys with your choosed name.

My non hybrid Solplanet inverter had Modbus, and I found it way easier and more reliable to use that instead of using the API which could also change. This works great and should be applicable to more inverters that support this.
It’s not even that complicated because of the great ESPHome community and its support for Home Assistant.
I’ve also wrote down how I did this in a blog post
Step-by-Step Guide to Linking Your (SolPlanet) Solar Inverter to Home Assistant Using ModBus Serial any feedback is welcome of course.

2 Likes

Do I have to get 5v to the esp or does it get the power from the inverter?

Yes you will indeed need to get 5v for it, i would recommend a simple power supply.

I got it from the Solplanet usb stick, which gave me 7V -9V so you will need to step this down. But be careful this may actually damage the inverter

So im fine with this solution, but in my mind it’s not easier for beginners. You have to be fit in soldering and yaml codes. Also you need some stuff like an esp. I will give it a try because I have all the stuff at home. Thanks for the tip.

1 Like

True, you don’t really need to solder, I just chose to. I would recommend to use a simple 5V power supply for the esp. But I totally agree that if someone created a plug and play integration that would be easier for most people, although it might come with some others drawbacks.

I just checked the voltage of the Solplanet stick and it’s pretty inconsistent now at 7V so I’m not sure I would recommend executing my earlier reply, I’m going to change that message. (And add a step-down to my current setup :sweat_smile:)

Today I’ve tried a few things but I think there an issue with my translation of gpios for the esp32. Don’t you tried to use the original Wi-Fi dongle? There’s an esp32 build in. If we solder in the rs485 module, it’s the all in one solution.


Info: For all ones who have added the solplanet inverter to wifi or ethern, i recommend to stay with that.

IF YOU HAVENT ANY DONGLE, then the modbus solution may is something for you. Ive tried out everything, but i see no advantage to the Wifi integration.

May you have some advantage if you have any battery connected… but i havent.

heres the modbus file i’ve got from solplanet support, got it about 10 mins after my request, gratz for that…:

1 Like