eet-energy / solmate-sdk

All you need to integrate your EET SolMate into your home automation system
MIT License
19 stars 2 forks source link

solmate mit home assistent and mqtt - wunsch #2

Open josy1024 opened 1 year ago

josy1024 commented 1 year ago

ich bekomm aktuell nicht die api-dokumentation sauber zum laufen. (DOKUMENT: EET SolMate API Documentation) der pyton code ist einfach nicht aus dem pdf rauszukopieren mit all den tabstops (GIT REPO?)

  File "/usr/lib/python3.10/site-packages/appdaemon/app_management.py", line 165, in initialize_app
    await utils.run_in_executor(self, init)
  File "/usr/lib/python3.10/site-packages/appdaemon/utils.py", line 337, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/appdaemon/apps/eet.py", line 47, in initialize
    self.client.quickstart()
  File "/usr/lib/python3.10/site-packages/solmate_sdk/apiclient.py", line 123, in quickstart
    self.connect()
  File "/usr/lib/python3.10/site-packages/solmate_sdk/apiclient.py", line 54, in connect
    asyncio.get_event_loop().run_until_complete(self._connect())
  File "/usr/lib/python3.10/asyncio/events.py", line 656, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'

source: https://github.com/eet-energy/solmate-sdk/blob/master/solmate_sdk/apiclient.py

You are trying to run asyncio.get_event_loop() in some thread other than the main thread - however, asyncio only generates an event loop for the main thread.

Instead use new_event_loop:

asyncio.new_event_loop().run_until_complete(main())

ENVIRONMENT: appdeamon config packages:

init_commands: []
python_packages:
  - gurux-dlms
  - beautifulsoup4
  - paho-mqtt
  - lxml
  - pyserial
  - cryptography
  - pycryptodomex
  - solmate-sdk
system_packages:
  - libxslt-dev
  - python3-idle
  - python3
  - python3-dev
  - alpine-sdk
  - autoconf
  - automake
  - libtool
  - gcc
  - g++
  - make
  - libffi-dev
  - py3-pycryptodome
  - libcrypto1.1
  - libssl1.1
log_level: info

refs: https://solmate-sdk.readthedocs.io/en/latest/#sol2mqtt https://appdaemon.readthedocs.io/en/latest/HASS_TUTORIAL.html

mmattel commented 11 months ago

Hey @josy1024 vielleicht magst du mal auf meine Implementierung schauen. Läuft bei mir seit Monaten ohne Unterbrechung/Fehler 😄

BetaTobi commented 11 months ago

Hi @mmattel Ich hab mir deine Implementierung auch angeschaut. Allerdings bekomm ich das python-script nicht laufen. Kannst du beschreiben (oder gibt es irgendwo eine Doku), wie man das Script ins Home Assistant System integriert?

mmattel commented 11 months ago

@BetaTobi im Repo ist ein Readme und dort steht alles drinnen. Deine Info dass du das Script nicht zu laufen bekommst ist sehr dünn weil keine weiteren Angaben. Hast du alle benötigten Python Module installiert? Hast du ein .env config File mit Deinen Werten? Läuft das Script auf der Kommandozeile? Siehst Du im MQTT Explorer deinen Solmate, etc? Kannst Du mir Deine Fragen nicht hier sondern in meiner Repo stellen, das wäre Hilfreich auch für andere, thx...

mmattel commented 11 months ago

Info zur Vervollständigung, der comment von @BetaTobi wurde hier fortgeführt und gelöst ✔️

josy1024 commented 11 months ago

großartig! Danke! Muss ich vielleicht nochmal umbauen.

ICH habe mittlerweile mqtt mit subscribes erweitert um über node-red - > mqtt - > solmate. Py - > solmate API auch minimum battery und minimum Power levels zu setzen. Nachdem ich auch aktuelle Verbrauchswerte vom Smartmeter auslesen kann ergibt sich damit eine optimiertere Energie Eigenverbrauchsnutzung.

Die Solmate API connect braucht bei mir auch fast stündliche reboots! (das müsste eet vielleicht mal nachbessern)

mmattel commented 11 months ago

das müsste eet vielleicht mal nachbessern

Willkommen im Club 😅