Code Monkey home page Code Monkey logo

solarman-mqtt's Introduction

solarman-mqtt

Script to retrieve current Solar PV data from the Solarman API, and send Power (W) and Energy (kWh) metrics to a MQTT broker, for further use in home automation. Several PV vendors use the Solarman Smart platform for statistics. One example is the Trannergy PV converter.

usage: run.py [-h] [-d] [-s] [-i INTERVAL] [-f FILE] [--validate] [--create-passhash CREATE_PASSHASH] [-v]

Collect data from Trannergy / Solarman API

optional arguments:
  -h, --help            show this help message and exit
  -d, --daemon          run as a service
  -s, --single          single run and exit
  -i INTERVAL, --interval INTERVAL
                        run interval in seconds (default 300 sec.)
  -f FILE, --file FILE  config file (default ./config.json)
  --validate            validate config file and exit
  --create-passhash CREATE_PASSHASH
                        create passhash from provided passwordand exit

Usage

You can run this script as a Docker container or in Python 3. Either way, a configuration file is required. Use the sample config.sample.json file in this repository for reference. Also, a Solarman API appid+secret is required, which can be requested via [email protected].

How to get all required input for the config file

Create a new config file by copying the sample config file and filling in the required information.

The first part covers your SolarmanPV account:

{
  "name": "Trannergy",
  "url": "globalapi.solarmanpv.com",
  "appid": "",
  "secret": "",
  "username": "",
  "passhash": "",
  [..]
}
  • name: is free text to identify the platform.
  • url: is the base URL of the API.
  • appid: is the appid for the API (See Usage).
  • secret: is the secret for the API (See Usage).
  • username: is the username for the API (emailadres).
  • passhash: is a sha256 hash of your password. This can be generated via --create-passhash.

The second part covers the PV inverter and logger ID's. These can be retrieved via the Solarman API.

{
  [..]
  "stationId": 123,
  "inverterId": 456,
  "loggerId": 789
  [..]
}
  • stationId: is the ID of the station. This is the value of stationList[0].id.
curl --location --request POST 'https://globalapi.solarmanpv.com/station/v1.0/list?language=en' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: bearer TOKEN' \
  --data-raw '{"size":20,"page":1}'
  • inverterId: is the SN of the inverter. This is the value of deviceListItems[0].deviceSn.
  • For Bosswerk MI300 and MI600 use "MICRO_INVERTER" instead of "INVERTER".
curl --location --request POST 'https://globalapi.solarmanpv.com/station/v1.0/device?language=en' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: bearer TOKEN' \
  --data-raw '{"size":10,"page":1,"stationId":1234567,"deviceType":"INVERTER"}'
  • loggerId: is the SN of the logger. This is the value of deviceListItems[0].deviceSn.
curl --location --request POST 'https://globalapi.solarmanpv.com/station/v1.0/device?language=en' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: bearer TOKEN' \
  --data-raw '{"size":10,"page":1,"stationId":1234567,"deviceType":"COLLECTOR"}'
  • meterId (optional): If you have a DTSD422 meter as part of your PV system, you can add the meter serialnumber to the config file.
{
  [..]
  "meterId": 123
  [..]
}

A bearer TOKEN to use in the requests above can be retrieved by adding your APPID, APPSECRET, USERNAME, PASSHASH in this request:

curl --location --request POST 'https://globalapi.solarmanpv.com/account/v1.0/token?appId=APPID&language=en' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "appSecret": "APPSECRET",
  "email": "USERNAME",
  "password": "PASSHASH"
}'

Note: If there is an error with AUTH_INVALID_USERNAME_OR_PASSWORD as code it might be that your password is too long or contains special characters. Try something shorter and A-Z, a-z and 0-9 only.

The final section covers the MQTT broker, to where the metrics will be published.

{
  [..]
  "broker": "mqtt.example.com",
  "port": 1883,
  "topic": "solarman",
  "username": "",
  "password": ""
}

MQTT topics

The following topics are published to the MQTT broker. Topics and fields may differ between PV system types. The example output below use solarmanpv as the topic, configured in the config file.

Station (Plant)

Information about the plant, current power and last update time.

solarmanpv/station/batteryPower
solarmanpv/station/batterySoc
solarmanpv/station/chargePower
solarmanpv/station/dischargePower
solarmanpv/station/generationPower
solarmanpv/station/gridPower
solarmanpv/station/irradiateIntensity
solarmanpv/station/lastUpdateTime
solarmanpv/station/purchasePower
solarmanpv/station/usePower
solarmanpv/station/wirePower

Inverter

Inverter information.

solarmanpv/inverter/deviceId
solarmanpv/inverter/deviceSn
solarmanpv/inverter/deviceState
solarmanpv/inverter/deviceType
solarmanpv/inverter/attributes

The attributes field contains all inverter datalist entries as a JSON object. An expample set of attributes is shown below:

SN: XXXXXXXXXX
Device_Type: 4
Production_Compliance_Type: 0
Rated_Power: 300.00
Year: 48
Month: 0
Day: 0
Hour: 0
Minute: 0
Seconds: 0
Communication_Protocol_Version: V0.2.0.1
Control_Board_Firmware_Version: V0.1.1.2
Communication_Board_Firmware_Version: V0.2.0.7
DC_Voltage_PV1: 0.00
DC_Voltage_PV2: 0.00
DC_Voltage_PV3: 0.00
DC_Voltage_PV4: 0.00
DC_Current_PV1: 0.00
DC_Current_PV2: 0.00
DC_Current_PV3: 0.00
DC_Current_PV4: 0.00
DC_Power_PV1: 0.00
DC_Power_PV2: 0.00
DC_Power_PV3: 0.00
DC_Power_PV4: 0.00
AC_Voltage_1: 0.00
AC_Current_1: 0.00
Total_AC_Output_Power(Active): 0
AC_Output_Frequency_1: 0.00
Total_Production(Active): 2.50
Total_Production_1: 2.50
Total_Production_2: 0.00
Total_Production_3: 0.00
Total_Production_4: 0.00
Daily_Production(Active): 0.70
Daily_Production_1: 0.70
Daily_Production_2: 0.00
Daily_Production_3: 0.00
Daily_Production_4: 0.00
AC_Radiator_Temp: -10.00
Micro_Inverter_Port_1: XXXXXXXXXX-1
Micro_Inverter_Port_2: XXXXXXXXXX-2
Micro_Inverter_Port_3: XXXXXXXXXX-3
Micro_Inverter_Port_4: XXXXXXXXXX-4
Number_Of_MPPT_Paths: 1
Number_Of_Phases: 1
Running_Status: 4
Overfrequency_And_Load_Reduction_Starting_Point: 50.20
Islanding Protection Enabled: Enable
Overfrequency_And_Load_Reduction_Percentage: 44
GFDI Enabled: Disable
Grid-connected Standard: 0
Grid Voltage_Upper_Limit: 275.00
Grid Voltage_Lower_Limit: 180.00
Grid Frequency_Upper_Limit: 52.00
Grid Frequency_Lower_Limit: 47.50
Start-up Self-checking Time: 60

Logger (Collector)

solarmanpv/logger/deviceId
solarmanpv/logger/deviceSn
solarmanpv/logger/deviceState
solarmanpv/logger/deviceType
solarmanpv/logger/attributes

The attributes field contains all inverter datalist entries as a JSON object. Some devices may send an empty object for this field. An example set of attributes is shown below:

Embedded_Device_SN: XXXXXXXXXX
Module_Version_No: MW3_15_5406_1.35
Extended_System_Version: V1.1.00.07
Total_running_time: 1
Offset_time: 1634486607
Data_Uploading_Period: 5
Data_Acquisition_Period: 60
Max._No._of_Connected_Devices: 1
Signal_Strength: 100
Heart_Rate: 120
IV_Curve_Supported: 1
Batch_Command_Supported: 1
Support_Reporting_Upgrading_Progress: 0
AT+UPGRADE_Command_Supported: 255
Method_Of_Protocol_Upgrade: 255

Running multiple inverter stations

If you have multiple inverter stations, you can add them to the config file as a list. Make sure to publish to separate MQTT topics per inverter instance, and configure the Home Assistant MQTT sensors accordingly.

[
  {
    "name": "Trannergy-1",
    "stationId": 987,
    "inverterId": 654,
    "loggerId": 321,
    "mqtt": {
      "topic": "inverter1"
    }
  },
  {
    "name": "Trannergy-2",
    "stationId": 123,
    "inverterId": 456,
    "loggerId": 789,
    "mqtt": {
      "topic": "inverter2"
    }
  }
]

Minimized example config; see config.sample.json for all fields.

Home Assistant

mqtt:
  sensor:
    - name: "solarmanpv_station_generationPower"
      state_topic: "solarmanpv/station/generationPower"
      unique_id: "generatedPower"
      unit_of_measurement: "Wh"
      device_class: energy
      state_class: measurement

Repeat for every station topic needed.

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

    - name: "solarmanpv_logger"
      unique_id: "solarmanpv_logger"
      state_topic: "solarmanpv/logger/deviceState"
      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' }}

Templates

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: measurement
        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

Screenshot

Screenshot Screenshot

Running

The easiest way to run is via a container. Current version is available at https://github.com/mpepping/solarman-mqtt/pkgs/container/solarman-mqtt

Using Docker

Docker example to run this script every 5 minutes and providing a config file:

cd /opt
git clone https://github.com/mpepping/solarman-mqtt
cd solarman-mqtt
mv config.sample.json config.json # setup your config
sudo docker run --name solarman-mqtt -d --restart unless-stopped -v /opt/solarman-mqtt:/opt/app-root/src ghcr.io/mpepping/solarman-mqtt:latest

Using docker-compose

This docker-compose.yml example can be used with docker-compose or podman-compose

version: '3'

services:
  solarman-mqtt:
    image: ghcr.io/mpepping/solarman-mqtt:latest
    container_name: "solarman-mqtt"
    environment:
    - TZ=Europe/Berlin
    volumes:
      - /opt/solarman-mqtt/config.json:/opt/app-root/src/config.json # or mount your complete config directory
    restart: unless-stopped

Using Python

Run pip install -r requirements.txt and start python3 run.py.

solarman-mqtt's People

Contributors

austinmroczek avatar dependabot[bot] avatar hakamsaffour avatar lechk82 avatar morrisjobke avatar mpepping avatar namelessjedi avatar wingsofcourage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solarman-mqtt's Issues

ERROR:root:Error on start: 'dataList'

hello,
I run de latest version of solarman-mqtt in docker. Once a day de docker stop running and in de logging I see the next error:

ERROR:root:Error on start: 'dataList'

There is no extra information in de logging. Is this a known error or is this new to you?

Is there a solution for this problem?

Richard

Error

ERROR:root:Error on start: can only concatenate str (not "NoneType") to str
INFO:root:Starting daemonized with a 300 seconds run interval

New to this, do not understand

Hello, I have API and SECRET from solarman, but even that I read the readme file dozen of times, I can not understand how to integrate it in HA. Can someone help me with ? I will buy a big beer to the one that can help me to integrate and make it work.
my email : [email protected]

Thank you.

Feature: Setting Inverter Limit

It is now possible to set inverter limit by percentage via UI. It would be great if this would be added to this add on as it would help to implement zero feed .

Send data of two inverters in one config

Hi,
I have 2 micro-inverters which report in solarman.
For both I made a config.json which are working, but is it possible, to integrate both inverters into one config.json.
Something like the following?

{
 {
  "name": "TrannergyOne",
  "url": "api.solarmanpv.com",
  "appid": "app",
  "secret": "sec",
  "username": "[email protected]",
  "passhash": "345",
  "stationId": 111,
  "inverterId": 333,
  "loggerId": 555,
  "debug" : false,
  "mqtt":{
    "broker": "1.1.1.1",
    "port": 1883,
    "topic": "solarmanpv",
    "username": "",
    "password": ""
  }
 },
 {
  "name": "TrannergyTwo",
  "url": "api.solarmanpv.com",
  "appid": "app",
  "secret": "sec",
  "username": "[email protected]",
  "passhash": "345",
  "stationId": 222,
  "inverterId": 444,
  "loggerId": 666,
  "debug" : false,
  "mqtt":{
    "broker": "1.1.1.1",
    "port": 1883,
    "topic": "solarmanpv",
    "username": "",
    "password": ""
 }
} 

Is there a way to let such an example working?
Or how should I run the two configs?

Thank you

what is passhash

Hello.
Trying to deploy this project but, What does passhash means? The hash calculation of the password used in Solarman platform?

MQTT Out of memory usage Issue

I just upgraded to the new version after having my solarman inverters offline, however Im having some issues pushing the values to the MQTT broker.

Checking the logs on HA mqtt mosquito logs, i see this errors
2023-05-18 10:07:50: New client connected from 192.168.x.x:49135 as solarmanpv-mqtt-655 (p2, c1, k60, u'username').
2023-05-18 10:07:50: Client solarmanpv-mqtt-655 disconnected due to out of memory.

HA is updated to latest version, so is mosquito mqtt server (ver 6.2.1), running on a Pi4 4GB. Checking the memory usage of the Pi it shows just 1-1.3GB RAM usage.

I have several other mqtt client that connects correctly to the server so its just solarman-mqtt that is having the issue

Enabled the debug logs on the solarman-mqtt docker, and this is what i see

INFO:root:2023-05-18 18:18:51 - Inverter DeviceState: 1 -> Publishing to MQTT ...

Any idea what could be wrong?

Unable to fetch token: 'access_token'

Since yesterday I get following error (with latest version):
Nothing changed :-(
Is it still working for you?

root@raspberrypi:/home/pi/solarman-mqtt# python3 run.py -s
ERROR:root:Unable to fetch token: 'access_token'

ERROR:root:Error on start: [Errno 2] No such file or directory: 'config.json'

Hello
Thank you very much for the great project.
Finally I can integrate the Deye inverter into my smart home. I had first created that with Docker that ran until my Raspi had not found its image anymore. Now I tried to start it via Python3. From "hand" this is also possible but if I want to start the daemon automatically I get this message.
ERROR:root:Error on start: [Errno 2] No such file or directory: 'config.json'.
Can they help me with the problem.

Greetings André

AppID is to long

I receive today my app id from solarman and it is to long for the config.json if I validate the config.
The app id has 16 numbers.

StationID is greater than the maximum of 9999999

Hello,

I try to run solarman-mqtt on my raspberry pi4.

After getting al IDs and config the file I got the following Message:

p**@pi1:/opt/solarman-mqtt $ python3 run.py --validate
60120335 is greater than the maximum of 9999999

The 60120335 should be my StationID. Where is my mistake/whats wrong?

Thanks for help

Script reconnect fails after unstable DNS resolution

Hi,

I upgraded yesterday to v0.6.2 (docker container). I don't think the issue is related to that upgrade but to an unstable ISP internet connection I had during the night. My monitoring shows me that I had a lot of paket loss on my ISP uplink during the night, that probably caused the DNS resolution to fail at "02:45:40". It looks like the script couldn't really recover from that because after the "07:58:54" message I see no further tries to fetch data until I finally restarted the docker container shortly before "15:30:48"
The only modification I did to the code was to change the default query interval from 300 to 270 seconds. (Btw. it would be nice to have an environment variable which you could set in your docker-compose file to pass that parameter to the script inside the docker container)

See the following logs (I condensed all the identical repeating messages by using ...):

INFO:root:Starting daemonized with a 270 seconds run interval
INFO:root:2022-10-10 14:20:44 - Inverter DeviceState: 1 -> Publishing to MQTT ...
...
INFO:root:2022-10-10 18:53:20 - Inverter DeviceState: 1 -> Publishing to MQTT ...
INFO:root:2022-10-10 18:57:52 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
...
INFO:root:2022-10-11 02:45:40 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
ERROR:root:Unable to fetch token: [Errno -3] Temporary failure in name resolution
INFO:root:Starting daemonized with a 270 seconds run interval
INFO:root:2022-10-11 02:50:35 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
...
INFO:root:2022-10-11 04:30:38 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
ERROR:root:Unable to fetch token: [Errno -3] Temporary failure in name resolution
INFO:root:Starting daemonized with a 270 seconds run interval
ERROR:root:Unable to fetch token: [Errno 104] Connection reset by peer
INFO:root:Starting daemonized with a 270 seconds run interval
INFO:root:2022-10-11 04:36:58 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
...
INFO:root:2022-10-11 07:38:12 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
ERROR:root:Unable to fetch token: [Errno 104] Connection reset by peer
INFO:root:Starting daemonized with a 270 seconds run interval
INFO:root:2022-10-11 07:44:53 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
INFO:root:2022-10-11 07:49:25 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
INFO:root:2022-10-11 07:53:57 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
INFO:root:2022-10-11 07:58:54 - Inverter DeviceState: 3-> Only status MQTT publish (probably offline due to nighttime shutdown)
ERROR:root:Unable to fetch token: Remote end closed connection without response
INFO:root:Starting daemonized with a 270 seconds run interval
INFO:root:Starting daemonized with a 270 seconds run interval
INFO:root:2022-10-11 15:30:48 - Inverter DeviceState: 1 -> Publishing to MQTT ...

Installation on an raspi pi4: ModuleNotFoundError: No module named 'jsonschema' , Smarthome fhem

Hi,
I installed and configured the Solarman-Mqtt on an raspi and always got the error message below:
/opt/solarman-mqtt $ python3 run.py -s -d -h # this is for testing only single start
Traceback (most recent call last):
File "run.py", line 5, in
import solarman
File "/opt/solarman-mqtt/solarman/init.py", line 12, in
from .helpers import ConfigCheck, HashPassword
File "/opt/solarman-mqtt/solarman/helpers.py", line 7, in
from jsonschema import validate
ModuleNotFoundError: No module named 'jsonschema'

the raspi has installed as standard python 2.7. and 3.7.

Then I changed in requirements.txt the option to jsonschema==2.6.0
and started again with standard python2:
python run.py -s -d -h
Traceback (most recent call last):
File "run.py", line 5, in
import solarman
File "/opt/solarman-mqtt/solarman/init.py", line 11, in
from .api import SolarmanApi, ConstructData
File "/opt/solarman-mqtt/solarman/api.py", line 45
url = f"//account/v1.0/token?appId={appid}&language=en"

Here it seems that the f option in line 45 makes the problem because py2 isn´t able to handle this.

What should I do? Do you have an idea?

Option to 'retain' data

Is it possible to retain data in MQTT. HA now thinks i'm still pulling 20W from the Sun when it's dark, this was the last state reported before the device went offline and got pulled to HA.

ERROR:root:Error on start: 'dataList'

Since this morning, I'm getting the following recorded in my portioner log:

INFO:root:Starting daemonized with a 300 seconds run interval
ERROR:root:Error on start: 'dataList'

Not sure what changed as until last night everything worked perfectly fine. Running ghcr.io/mpepping/solarman-mqtt:latest

Anny suggestions?

Many thanks in advance!

More than one inverter possible?

I tried to add an additional inverter, but that produced only an error message. In the end I created an additional docker container to gather the information from the second inverter. So did anyone manage to add an additional one?

Access Token not available

The day before yesterday I noticed my sun screen's weren't closing with lot's of sun. Today I noticed it again and the following logging is presented:

INFO:root:Starting daemonized with a 60 seconds run interval
ERROR:root:Unable to fetch token: 'access_token'

Nothing has changed, and I can still logon to the home.solarmanpv.com url. What can this be? Everything seems to be in order. Or could it be something has changed with the in API / key provided by Solarman?

screenshot

image

how did you create that beautiful picture? can you share the dashboard?

Compile to ARM

Trying install in my raspberry and im getting errors, mayba cause the compilation is for X86_64 not ARM.

KeyError:'dataList'

Hi

This might be a stupid question but when i try and run the python script I get KeyError:'dataList'

Would you be able to assist with this?

Regards

Suggestion: Process Sleep time

Was wondering maybe it would be a good idea to have in the config a way to set up work times for the script/requests, so whenever its night time it doesnt hammer solarman webservers with hits when we know our inverters are offline.

That would reduce the number of daily requests by at least 30% (and reduce the chances that maybe someday they see this as hammering their API and remove us access to it)

Latest tag on RaspberryPi 4 gives error

Error in my log shows: standard_init_linux.go:228: exec user process caused: exec format error

compose file i'm using:

solarman-mqtt-test:
image: ghcr.io/mpepping/solarman-mqtt:latest
container_name: "solarman-mqtt-test"
environment:
- TZ=${TZ}
mem_limit: 512m
volumes:
- ${DOCKERCONFDIR}/solarman-mqtt-test:/opt/app-root/src
restart: unless-stopped

Any thoughts

Interval setting for docker

Hey,

is there a way to pass the interval parameter when running the script in a container? I tried putting it in docker run command, however it's not parsed correctly resulting in container not being started.

Regards

Entities with a UNIQUE_ID are needed to add a area

With entities without a unique_id it is not possible to add these to a area. I have added unique_id's for all devices. So you can copy/paste it:

  - platform: mqtt
    name: "solarmanpv_station_generationPower"
    state_topic: "solarmanpv/station/generationPower"
    unique_id: "generatedPower"
    unit_of_measurement: "Wh"
    device_class: energy
    state_class: measurement

  - platform: mqtt
    name: "solarmanpv_inverter"
    unique_id: "solarmanpv_inverter"
    state_topic: "solarmanpv/inverter/deviceState"
    json_attributes_topic: "solarmanpv/inverter/attributes"
    
  - platform: mqtt
    name: "solarmanpv_logger"
    unique_id: "solarmanpv_logger"
    state_topic: "solarmanpv/logger/deviceState"
    json_attributes_topic: "solarmanpv/logger/attributes"

  - 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: measurement
        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

`

docker-compose run.py is not found

Hello,
I followed the instruction and installed the docker container using docker-compose

on the docker logs, I am getting the following error, and the container keeps restarting

python: can't open file '/opt/app-root/src/run.py': [Errno 2] No such file or directory

any advise?

New API endpoint

I got this in the mail today:

We are delighted to inform you that SOLARMAN platform will upgrade data centers from 2023-04-16 09:00 to 2023-04-16 18:00 (UTC+8) , as part of our continued efforts to offer you a premium product.

Please note that your account and data will not be accessible via the interface until the upgrade is completed.

Once upgrade is completed, if you are using the "International Data Center", we kindly remind that you use the new OPENAPI domain globalapi.solarmanpv.com to access the platform, replacing the previous domain api.solarmanpv.com. Your APPID and APPSECRET will remain the same, but you will need to obtain a new token to access the platform.

Suggestion: HA add-on

Has anyone made this into a Hass OS add-on ? https://developers.home-assistant.io/docs/add-ons/. Seems like you're 90% of the way there since you have a working container.

I'm willing to figure it out and submit a PR. Just wanted to ask first in case someone had already done it. I'm not seeing it, but may be using the wrong search terms.

HA configuration.yaml example is using deprecated features

Starting yesterday I have been trying to integrate my solar panels into HA. I'm struggling a bit with getting everything working.

I had to create another template sensor:

template:

  - sensor:
      - name: SoFar_Solar_Power_Generation
        unit_of_measurement: 'Wh'
        state: >
          {{ (states("sensor.solarmanpv_station_generationPower") | float) | round(2) }}
        device_class: energy
        state_class: measurement
        attributes:
          last_reset: '1970-01-01T00:00:00+00:00'

To get it to be able to use in the energy tab.

Together with this I had to comment the entity_id's because these are deprecated. Don't exactly know what they do.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.