Collect Inverter data from Solarman API

Just called solarman, directly from the integration menu.

Yes I know, but I don´t know why is does´t working for me, try from integration nenu and try frome manual sensor. The sensors and all entitires appear but I dont get nothing from logger.

im not getting “solarman” in the integration menu … how can this be??

First add it through hacs

That’s great your explanation @Skully !

I just could use the APPID and APPSECRET I received, thanks.

However I cannot access any of my devices.
When I try to get data from any one of my inverters I get these msgs:

{
“code”: “2101040”,
“msg”: “device not found”,
“success”: false,
“requestId”: “f4…”
}

I tried the SN for the Logger and Deye microinverter, from different plants I have already registered on my https://pro.solarmanpv.com/business/maintain/plant monitoring platform.

Please, any help?

1 Like

Hello, where am I doing wrong please?

Welcome to the community! You have been slightly mislead. The code goes under “sensor:”, like:

sensor:
  - platform: command_line  
    command: curl -s -u admin:admin http://192.168.15.150/status.html | grep -E "\webdata_now_p(\s|$)" | cut -d'"' -f 2
    name: solarmanlocal_power_solar
    unit_of_measurement: 'W'
    scan_interval: 10
  - platform: ....

Hi all, anyone who is still using OP’s method and encountering issues:

The json output of the website has been changed.

Cumulative Production (Active) is no longer found in [16] but in [18].

Hello,

No, is not working , I have the same issue but I do not think is from the way we collect data, because if I look at the sensor data I see the correct data

In above picture , 10.68 is the state in HA and on the logger Yield today10.87 kWh

I really do not know what is the problem.

I removed all the other sensors from Energy Dashboard , just to test:

Any thoughts are welcomed :slight_smile:

I hope there will be a implementation to HACS for this one day. This is quiete complicated for a noob like me.

1 Like

Hi Skully,
thanks for sharing your knowledge on the Solarman API.
As far as I understand OAuth 2.0 API architecture, appID and appSecret are means to identify your app at the Solarman API. It’s not a credential in that sense. For security, you pass the user’s credentials and receive a token which from there on identifies your user.
Customer service at solarmanpv has become very hesitant to provide appID and appSecret for new apps meanwhile, because apparently a lot of projects on gitHub misunderstood this fact such that now every user is requesting an own appID from their service desk.

Your app can use the access_token for all further API calls on the other functions as long as the token has not expired. Logically, you can also skip the appId parameter in your example where you call device/v1.0/currentData. The documentation provided by solarmanpv is quite clear in that.

How much further experience have you gained with this API? Have you meanwhile found out how to use the refresh_token? As soon as the access_token has expired, this should be used to obtain a new refresh_token in order to save the need to re-communicate the user’s credentials again.
I tried with grant_type=refresh_token&refresh_token=<resfresh-token> as defined per OAuth spec, but I failed to get it work.

Regards,
stedon81

What do I add in template/or anywhere else to use/show Battery data in the Energy Dashboard?

I thought I went past that step but it appears the data ain’t pulling via mqtt. How do we debug this?

Also, No webdata_now_p parameter data :frowning:

Any idea why?

All, sorry to hear all the issues. Like my previous response, https://github.com/lechk82/solarman-mqtt is working like a charm for a couple of months already:

  • no issues with expiring tokens
  • no issues with timings
    it just works flawlessly!

In short:

  1. Follow the link above
    I’m using the docker-compose method. If you do as well, make sure the config.jason file is located at the correct location. Use the logging to see the output. It should be something similar like:

    oh btw, if the DeviceState = 1, the sun is shining :grinning:, DeviceState = 3: Inverter is offline
  2. The config.jason formatting is not that well documented, please use the following:
{
  "name": "Trannergy",
  "url": "api.solarmanpv.com",
  "appid": "<id>",
  "secret": "<secret>",
  "username": "<username>",
  "passhash": "<hased password>",
  "stationId": <stationid>,
  "inverterId": "<inverterid>",
  "loggerId": "<loggerid>",
  "debug" : false,
  "mqtt":{
    "broker": "<broker ip>",
    "port": 1883,
    "topic": "solarmanpv",
    "username": "<broker username>",
    "password": "<broker password>"
  }
}
  1. Install, if you havent already, a MQTT broker like: MQTT - Home Assistant
  2. Do use something like MQTT-Explorer to see if the messages are coming in like:
  3. Add the following in your configuration.yaml:
mqtt:
  sensor:
    - state_topic: "solarmanpv/station/generationPower"
      name: "solarmanpv_station_generationPower"
      unique_id: "generatedPower"
      unit_of_measurement: "Wh"
      device_class: energy
      state_class: measurement

    - state_topic: "solarmanpv/inverter/deviceState"
      name: "solarmanpv_inverter"
      unique_id: "solarmanpv_inverter"
      json_attributes_topic: "solarmanpv/inverter/attributes"

    - state_topic: "solarmanpv/logger/deviceState"
      name: "solarmanpv_logger"
      unique_id: "solarmanpv_logger"
      json_attributes_topic: "solarmanpv/logger/attributes"

sensor:
  - platform: template
    sensors:
      solarmanpv_inverter_device_state:
        unique_id: "inverter_device_state"
        value_template: >-
          {% set mapper =  {
              '1' : 'Online',
              '2' : 'Failure',
              '3' : 'Offline'} %}
          {% set state =  states.sensor.solarmanpv_inverter.state %}
          {{ mapper[state] if state in mapper else 'Unknown' }}

  - platform: template
    sensors:
      solarmanpv_logger_device_state:
        unique_id: "logger_device_state"
        value_template: >-
          {% set mapper =  {
              '1' : 'Online',
              '2' : 'Failure',
              '3' : 'Offline'} %}
          {% set state =  states.sensor.solarmanpv_logger.state %}
          {{ mapper[state] if state in mapper else 'Unknown' }}
          
template:
  - sensor:
    - name: "Solarman energy daily"
      unique_id: "solarman_energy_daily"
      unit_of_measurement: 'kWh'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'Daily_Production_(Active)') }}"
      device_class: energy
      state_class: total_increasing
      attributes:
        last_reset: '1970-01-01T00:00:00+00:00'

  - sensor:
    - name: solarmanpv_inverter_dc_voltage_pv1
      unique_id: "solarmanpv_inverter_dc_voltage_pv1"
      unit_of_measurement: 'V'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'DC_Voltage_PV1') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_dc_current_pv1
      unique_id: "solarmanpv_inverter_dc_current_pv1"
      unit_of_measurement: 'A'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'DC_Current_PV1') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_dc_voltage_testing
      unique_id: "solarmanpv_inverter_dc_current_testing"
      unit_of_measurement: 'V'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'DC_Voltage_PV1') }}"
      state_class: measurement
      unit_of_measurement: 'A'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'DC_Current_PV1') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_dc_voltage_pv2
      unique_id: " solarmanpv_inverter_dc_voltage_pv2"
      unit_of_measurement: 'V'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'DC_Voltage_PV2') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_dc_current_pv2
      unique_id: "solarmanpv_inverter_dc_current_pv2"
      unit_of_measurement: 'A'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'DC_Current_PV2') }}"
      state_class: measurement
      
  - sensor:
    - name: solarmanpv_inverter_dc_power_pv1
      unique_id: "solarmanpv_inverter_dc_power_pv1"
      unit_of_measurement: 'W'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'DC_Power_PV1') }}"
      state_class: measurement
      
  - sensor:
    - name: solarmanpv_inverter_dc_power_pv2
      unique_id: "solarmanpv_inverter_dc_power_pv2"
      unit_of_measurement: 'W'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'DC_Power_PV2') }}"
      state_class: measurement
      
  - sensor:
    - name: solarmanpv_inverter_total_production
      unique_id: "solarmanpv_inverter_total_production"
      unit_of_measurement: 'kWh'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'Cumulative_Production_(Active)') }}"
      state_class: total_increasing
      
  - sensor:
    - name: solarmanpv_inverter_daily_production
      unique_id: "solarmanpv_inverter_daily_production"
      unit_of_measurement: 'kWh'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'Daily_Production_(Active)') }}"
      state_class: total_increasing

  - sensor:
    - name: solarmanpv_inverter_ac_radiator_temp
      unique_id: "solarmanpv_inverter_ac_radiator_temp"
      unit_of_measurement: '°C'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'Temperature-_Inverter') }}"
      state_class: measurement
      
  - sensor:
    - name: solarmanpv_inverter_ac_voltage_1
      unique_id: "solarmanpv_inverter_ac_voltage_1"
      unit_of_measurement: 'V'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'AC_Voltage_R/U/A') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_ac_current_1
      unique_id: "solarmanpv_inverter_ac_current_1"
      unit_of_measurement: 'A'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'AC_Current_R/U/A') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_ac_voltage_2
      unique_id: "solarmanpv_inverter_ac_volgage_2"
      unit_of_measurement: 'V'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'AC_Voltage_S/V/B') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_ac_current_2
      unique_id: "solarmanpv_inverter_ac_current_2"
      unit_of_measurement: 'A'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'AC_Current_S/V/B') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_ac_voltage_3
      unique_id: "solarmanpv_inverter_ac_voltage_3"
      unit_of_measurement: 'V'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'AC_Voltage_T/W/C') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_ac_current_3
      unique_id: "solarmanpv_inverter_ac_current_3"
      unit_of_measurement: 'A'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'AC_Current_T/W/C') }}"
      state_class: measurement

  - sensor:
    - name: solarmanpv_inverter_ac_output_frequency
      unique_id: "solarmanpv_inverter_ac_output_frequency"
      unit_of_measurement: 'Hz'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'AC_Output_Frequency_R') }}"
      state_class: measurement
  1. Configure the energy dashboard, something like this:

As the energy dashboard refreshes on top of the hour, it could take up to 2 hours to get visuals on your dashboard as only a full hour is being visualised!

Good Luck :grinning:

1 Like

Thank you so much for the guide !

Why this though? Any idea?

Configuration file updated as per your guide.

This is most likely caused by not having the full 1-2 hours of data available to be reflected in the dashboard. After ignoring this for 2 hours, do you still see the errors?

Yea the error msg is same even though the data is there on solarman portal and container log isnt showing anything wrong either.

Please check:

template:
  - sensor:
    - name: "Solarman energy daily"
      unique_id: "solarman_energy_daily"
      unit_of_measurement: 'kWh'
      state: "{{ state_attr('sensor.solarmanpv_inverter', 'Daily_Production_(Active)') }}"
      device_class: energy
      state_class: total_increasing
      attributes:
        last_reset: '1970-01-01T00:00:00+00:00

This is a bit different than the mentioned in the tutorial of Lechk82. Also please check if you are running the latest HA version as there have been a few changes in how to configure MQTT sensors

Copied rom your code above… I was thinking to add battery attributes but I guess that challenge comes later :smiley:

Home Assistant 2022.9.5
Supervisor 2022.09.1
Frontend 20220907.2 - latest

You however added a space in attribute name before (Active) where as it states differently on github documentation.

Uhmm, I know formatting is key. Did you validate the configuration.yaml file? And checked to entity state? (Under development tools)