Git Product home page Git Product logo

jaspere84 / pyfusionsolardatarelay Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 2.0 674 KB

Interface to relay PV inverter data from FusionSolar public kiosk mode to InfluxDB/VictoriaMetrics, PVOutput.org, MQTT and Home Assistant

License: MIT License

Dockerfile 0.83% Python 99.17%
bridge docker fusion-solar fusionsolar grafana homeassistant huawei influxdb inverter kenter meetdata mosquitto mosquitto-mqtt mqtt pvoutput relay victoriametrics xibo

pyfusionsolardatarelay's People

Contributors

jaspere84 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

pyfusionsolardatarelay's Issues

pvoutputsystemid not being read correctly

Running PyFusionSolarDataRelay 1.0.4 on a docker container on a Synology NAS.

I've set the environment variable pvoutputsystemid to what is listed at pvoutput.org. However when I start the container it says in the log:

INFO - System ID: 12345

I have also noticed that when it tries to upload to pvoutput.org

requests.exceptions.InvalidHeader: Header part (12345) from {'X-Pvoutput-SystemId': 12345} must be of type str or bytes, not <class 'int'>

I did try to set the variable pvoutputsystemid to "XXX" but it is still read as 12345.

Any ideas?

pvfusionminutecron : variable does not accept 0,30

Hello,

I've got an issue with the variable pvfusionminutecron. If i set 0,30 in my docker-compose.yml, i get this traceback

2023-07-19 10:54:37,839 - root - INFO - PyFusionSolarDataRelay 1.0.5 started pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - DEBUG - Conf class instantiated pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - DEBUG - Setting default conf values pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - INFO - Processing environment variables to running config pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - DEBUG - Pulled 'pvdebug=True' from the environment pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - DEBUG - Pulled 'pvfusionsolar=True' from the environment pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - DEBUG - Pulled 'pvfusionsolarurl=https://region03eu5.fusionsolar.huawei.com:443/rest/pvms/web/kiosk/v1/station-kiosk-file?kk=' from the environment pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - DEBUG - Pulled 'pvfusionsolarkkid=1O0eLg93hkB8qp2rL5MQPqJc25jPljtK' from the environment pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - DEBUG - Pulled 'pvsysname=inverter01' from the environment pyfusionsolardatarelay | 2023-07-19 10:54:37,840 - root - DEBUG - Pulled 'pvfusionminutecron=0, 30' from the environment pyfusionsolardatarelay | Traceback (most recent call last): pyfusionsolardatarelay | File "/code/pv.py", line 19, in <module> pyfusionsolardatarelay | conf = PvConf(logger) pyfusionsolardatarelay | File "/code/pvconf.py", line 8, in __init__ pyfusionsolardatarelay | self.apply_environment_settings() pyfusionsolardatarelay | File "/code/pvconf.py", line 159, in apply_environment_settings pyfusionsolardatarelay | self.fusionminutecron = int(self.getenv("pvfusionminutecron")) pyfusionsolardatarelay | ValueError: invalid literal for int() with base 10: '0, 30'

My docker-compose has the following parameter set:

  • pvfusionminutecron=0,30

Connect via MQTT to existing Home Assistant Docker instance

I have problems using this project with an existing Home Assistant instance and the MQTT Broker addon from HA. I just need the connection to FusionSolar-Kiosk and MQTT-Entities in HA.
I don't need another MQTT server and the InfluxDB stuff.
Unfortunately MQTT Explorer doesn't show up topic "energy/pyfusionsolar"
I modified the composer file to my need and created an user for the MQTT broker, but I'm not sure which port (1883/9001) and host (HA host, 0.0.0.0, localhost) to use to connect to the HAs' MQTT broker:

version: '3'

services:
  pyfusionsolar:
    container_name: pyfusionsolardatarelay
    image: jsprnl/pyfusionsolardatarelay:latest
    restart: unless-stopped

    environment:
      - pvdebug=True

      - pvfusionsolar=True
      - pvfusionsolarkkid=<KIOSK_TOKEN>
      - pvfusionminutecron=5

      - pvmqtt=True
      - pvmqtthost=??????????
      - pvmqttport=??????????
      - pvmqttauth=True
      - pvmqttuser=XXXXXXXXXX
      - pvmqttpasswd=XXXXXXXXXX

    volumes:
      - /etc/localtime:/etc/localtime:ro

Portainer-Log:

2022-10-10 14:17:08,135 - root - DEBUG - Conf class instantiated
2022-10-10 14:17:08,135 - root - DEBUG - Setting default conf values
2022-10-10 14:17:08,135 - root - INFO - Processing environment variables to running config
2022-10-10 14:17:08,136 - root - DEBUG - Pulled 'pvdebug=True' from the environment
2022-10-10 14:17:08,137 - root - DEBUG - Pulled 'pvfusionsolar=True' from the environment
2022-10-10 14:17:08,137 - root - DEBUG - Pulled 'pvfusionsolarkkid=XXXXXXXXXX' from the environment
2022-10-10 14:17:08,137 - root - DEBUG - Pulled 'pvfusionminutecron=5' from the environment
2022-10-10 14:17:08,137 - root - DEBUG - Pulled 'pvmqtt=True' from the environment
2022-10-10 14:17:08,137 - root - DEBUG - Pulled 'pvmqtthost=XXXXXXXXXX' from the environment
2022-10-10 14:17:08,137 - root - DEBUG - Pulled 'pvmqttport=??????????' from the environment
2022-10-10 14:17:08,138 - root - DEBUG - Pulled 'pvmqttauth=True' from the environment
2022-10-10 14:17:08,139 - root - DEBUG - Enabled verbose logging
2022-10-10 14:17:08,139 - root - INFO - Current settings:
2022-10-10 14:17:08,139 - root - INFO - _Generic:
2022-10-10 14:17:08,139 - root - INFO - debug:   True
2022-10-10 14:17:08,140 - root - INFO - _FusionSolar:
2022-10-10 14:17:08,140 - root - INFO - enabled: True
2022-10-10 14:17:08,140 - root - INFO - fusionsolarurl: https://region01eu5.fusionsolar.huawei.com/rest/pvms/web/kiosk/v1/station-kiosk-file?kk=
2022-10-10 14:17:08,140 - root - INFO - fusionsolarkkid: XXXXXXXXXX
2022-10-10 14:17:08,141 - root - INFO - sysname: inverter01
2022-10-10 14:17:08,141 - root - INFO - fusionhourcron: *
2022-10-10 14:17:08,141 - root - INFO - fusionminutecron: 5
2022-10-10 14:17:08,141 - root - INFO - _Influxdb:
2022-10-10 14:17:08,141 - root - INFO - influx: False
2022-10-10 14:17:08,141 - root - INFO - influx2: True
2022-10-10 14:17:08,142 - root - INFO - host: localhost
2022-10-10 14:17:08,142 - root - INFO - port: 8086
2022-10-10 14:17:08,142 - root - INFO - _Influxdb_v1:
2022-10-10 14:17:08,142 - root - INFO - database: fusionsolar
2022-10-10 14:17:08,142 - root - INFO - user: fusionsolar
2022-10-10 14:17:08,142 - root - INFO - password: **secret**
2022-10-10 14:17:08,142 - root - INFO - _Influxdb_v2:
2022-10-10 14:17:08,142 - root - INFO - protocol: https
2022-10-10 14:17:08,143 - root - INFO - organization: acme
2022-10-10 14:17:08,143 - root - INFO - bucket: fusionsolar
2022-10-10 14:17:08,143 - root - INFO - token: XXXXXXX
2022-10-10 14:17:08,143 - root - INFO - _PVOutput.org:
2022-10-10 14:17:08,143 - root - INFO - Enabled: False
2022-10-10 14:17:08,143 - root - INFO - System ID: 12345
2022-10-10 14:17:08,144 - root - INFO - API Key: yourapikey
2022-10-10 14:17:08,144 - root - INFO - API Url: https://pvoutput.org/service/r2/addstatus.jsp
2022-10-10 14:17:08,144 - root - INFO - API BatchUrl: https://pvoutput.org/service/r2/addbatchstatus.jsp
2022-10-10 14:17:08,144 - root - INFO - _MQTT
2022-10-10 14:17:08,144 - root - INFO - Enabled: True
2022-10-10 14:17:08,144 - root - INFO - Host: ??????????
2022-10-10 14:17:08,144 - root - INFO - Port: ??????????
2022-10-10 14:17:08,144 - root - INFO - Auth: True
2022-10-10 14:17:08,145 - root - INFO - User: XXXXXXXXXX
2022-10-10 14:17:08,145 - root - INFO - Passwd: XXXXXXXXXX
2022-10-10 14:17:08,145 - root - INFO - Topic: energy/pyfusionsolar
2022-10-10 14:17:08,145 - root - INFO - _GridRelay
2022-10-10 14:17:08,145 - root - INFO - Enabled: False
2022-10-10 14:17:08,145 - root - INFO - System name: transformer01
2022-10-10 14:17:08,145 - root - INFO - Interval: 43200
2022-10-10 14:17:08,145 - root - INFO - PVOutput span: 2
2022-10-10 14:17:08,146 - root - INFO - Kenter URL: https://webapi.meetdata.nl
2022-10-10 14:17:08,146 - root - INFO - Kenter EAN: XXX
2022-10-10 14:17:08,146 - root - INFO - Kenter MeterId: XXX
2022-10-10 14:17:08,146 - root - INFO - Kenter User: user
2022-10-10 14:17:08,146 - root - INFO - Kenter Passwd: passwd
2022-10-10 14:17:08,146 - root - INFO - Days back: 3
2022-10-10 14:17:08,147 - root - DEBUG - PvRelay class instantiated
2022-10-10 14:17:08,147 - root - DEBUG - PvFusionSolar class instantiated
2022-10-10 14:17:08,147 - root - DEBUG - PvOutputOrg class instantiated
2022-10-10 14:17:08,147 - root - DEBUG - PvMqtt class instantiated
2022-10-10 14:17:08,147 - root - DEBUG - PvInflux class instantiated
2022-10-10 14:17:08,147 - root - INFO - Starting PvRelay on separate thread
2022-10-10 14:17:08,148 - root - DEBUG - PvRelay waiting 5sec to initialize docker-compose containers
2022-10-10 14:17:13,315 - apscheduler.scheduler - INFO - Adding job tentatively -- it will be properly scheduled when the scheduler starts
/usr/local/lib/python3.10/site-packages/apscheduler/util.py:436: PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  return tzinfo.localize(dt)
2022-10-10 14:17:13,320 - apscheduler.scheduler - INFO - Added job "PvRelay.process_fusionsolar_request" to job store "default"
2022-10-10 14:17:13,321 - apscheduler.scheduler - INFO - Scheduler started
2022-10-10 14:17:13,321 - apscheduler.scheduler - DEBUG - Looking for jobs to run
2022-10-10 14:17:13,321 - apscheduler.scheduler - DEBUG - Next wakeup is due at 2022-10-10 15:05:00+02:00 (in 2866.678750 seconds)```

change in fusionsolarurl

Hi, with the last system update, the fusionsolarurl (for the kiosk mode) changed to
https://uni002eu5.fusionsolar.huawei.com/rest/pvms/web/kiosk/v1/station-kiosk-file?kk

Unable to start due to thread error

Hi, I just cloned the repo, customized docker-compose.yaml and tried a docker-compose up, but this fails with this error:

pyfusionsolardatarelay | Traceback (most recent call last):
pyfusionsolardatarelay |   File "/code/pv.py", line 33, in <module>
pyfusionsolardatarelay |     fs_thread.start()
pyfusionsolardatarelay |   File "/usr/local/lib/python3.10/threading.py", line 935, in start
pyfusionsolardatarelay |     _start_new_thread(self._bootstrap, ())
pyfusionsolardatarelay | RuntimeError: can't start new thread

From the Python threads I found this could be related to too many threads running, but I think there is only one in my case...

I also tried on a Raspberry Pi (which would be my preferred way to keep the container running), but it didn't start with this error:

pyfusionsolardatarelay | standard_init_linux.go:219: exec user process caused: exec format error

Is there a way to have either one to start?
I removed all containers except the pvfusionsolar one, since I only want to publish to pvoutput.org
I changed the folloving variables:

  • pvsysname
  • pvfusionsolarkkid
  • pvfusionsolarurl (added, since it was changed recently to https://uni004eu5.fusionsolar.huawei.com/pvmswebsite/nologin/assets/build/cloud.html#/kiosk?kk= for me)
  • pvinflux=False
  • pvpvoutputsystemid
  • pvpvoutputapikey
  • pvmqtt=False

Thanks in any case!

Docker errors

Docker gives me this error message every time the script runs. I've only configured it for pvoutput and can't really understand what the issue is.

2023-11-05 14:30:00 2023-11-05 13:30:00,001 - root - INFO - Requesting data from FusionSolar Kiosk API...
2023-11-05 14:30:00 2023-11-05 13:30:00,001 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): region04eu5.fusionsolar.huawei.com:443
2023-11-05 14:30:00 2023-11-05 13:30:00,990 - urllib3.connectionpool - DEBUG - https://region04eu5.fusionsolar.huawei.com:443 "GET /pvmswebsite/nologin/assets/build/index.html HTTP/1.1" 200 None
2023-11-05 14:30:01 2023-11-05 13:30:01,001 - root - ERROR - Uncaught exception in FusionSolar data processing loop.
2023-11-05 14:30:01 Traceback (most recent call last):
2023-11-05 14:30:01 File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json
2023-11-05 14:30:01 return complexjson.loads(self.text, **kwargs)
2023-11-05 14:30:01 File "/usr/local/lib/python3.10/json/init.py", line 346, in loads
2023-11-05 14:30:01 return _default_decoder.decode(s)
2023-11-05 14:30:01 File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
2023-11-05 14:30:01 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
2023-11-05 14:30:01 File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
2023-11-05 14:30:01 raise JSONDecodeError("Expecting value", s, err.value) from None
2023-11-05 14:30:01 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2023-11-05 14:30:01
2023-11-05 14:30:01 During handling of the above exception, another exception occurred:
2023-11-05 14:30:01
2023-11-05 14:30:01 Traceback (most recent call last):
2023-11-05 14:30:01 File "/code/pvfusionsolar.py", line 29, in fetch_fusionsolar_status
2023-11-05 14:30:01 response_json = response.json()
2023-11-05 14:30:01 File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json
2023-11-05 14:30:01 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
2023-11-05 14:30:01 requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2023-11-05 14:30:01
2023-11-05 14:30:01 During handling of the above exception, another exception occurred:
2023-11-05 14:30:01
2023-11-05 14:30:01 Traceback (most recent call last):
2023-11-05 14:30:01 File "/code/pvrelay.py", line 34, in process_fusionsolar_request
2023-11-05 14:30:01 fusionsolar_json_data = self.pvfusionsolar.fetch_fusionsolar_status()
2023-11-05 14:30:01 File "/code/pvfusionsolar.py", line 31, in fetch_fusionsolar_status
2023-11-05 14:30:01 raise Exception(
2023-11-05 14:30:01 Exception: Error while parsing JSON response from Kiosk API: 'Expecting value: line 1 column 1 (char 0)'
2023-11-05 14:30:01 2023-11-05 13:30:01,002 - root - DEBUG - Waiting for next FusionSolar interval...
2023-11-05 14:30:01 2023-11-05 13:30:01,002 - apscheduler.executors.default - INFO - Job "PvRelay.process_fusionsolar_request (trigger: cron[hour='*', minute='0,30'], next run at: 2023-11-05 14:00:00 UTC)" executed successfully

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.