joscha82 / wattpilot

Python library to connect to a Fronius Wattpilot Wallbox
MIT License
40 stars 10 forks source link

Addon (docker) for Home Assistant #7

Open thecem opened 2 years ago

thecem commented 2 years ago

To install this repo it would be a good solution to create a docker addon. The docker will bring all necessary dependency´s with it and it would be easy to use this as an adaptor between HA and Wattpilot.

Best way would be to integrate the WS interface to HA Fronius Intergration. Who is maintainig it right now?

joscha82 commented 2 years ago

Building a docker container makes only sense for @ahochsteger recent commit to build a Wattpilot2mqtt Bridge. Given that his Pull-Request also adds env support for configuration, running from docker should be no issue. Existing Fronius HA Integration however utilizes Fronius SolarWatt APIs, while the Wattpilot uses the e-go charger API. I don't believe that adding Wattpilot Support to the existing Fronius HA Integration makes sense, however, @mk-maddin just created a first HA Integration for Wattpilot here: https://github.com/mk-maddin/wattpilot-HA

ahochsteger commented 2 years ago

@joscha82, @thecem, yes wrapping the MQTT bridge into a Docker container is already on my TODO list. Maybe you're also interested that I've got a Home Assistant integration using MQTT discovery working locally which in the final testing stages. It's fully based on the configuration file wattpilot.yaml so it can be easily customized to the many properties that are available from Wattpilot.

thecem commented 2 years ago

no cloue how to install Phyton Module to HA, I tried in the shell of HA but finally some error occurred.

thecem commented 2 years ago

Some hints, how to instal the photogne Module to HA ?

ahochsteger commented 2 years ago

@joscha82, @thecem the PR https://github.com/joscha82/wattpilot/pull/9 now has initial docker support included and allows to start the websocket-to-mqtt bridge with Home Assistent auto-discovery as a docker container.

ahochsteger commented 2 years ago

@thecem the first docker image has been built and can be obtained using (note: this is not yet a release):

docker pull ghcr.io/joscha82/wattpilot:main

For more information about running the docker image have a look at: https://github.com/joscha82/wattpilot#docker-support

You may need to adjust the image name from wattpilot:latest to ghcr.io/joscha82/wattpilot:main in the file docker-compose.yml and skip building if you want to test the pre-built image.

@joscha82 the build of the docker image can be seen here: https://github.com/joscha82/wattpilot/runs/6564042519?check_suite_focus=true It would be interesting to see, if a release correctly taggs the docker image with the version number. Maybe it's time to release the first version as 1.0.0 (after feedback to the docker image) since IMO it's now ready and running for weeks on my side with just rare minor issues. The next step would be to generate docker images for multiple architectures, if the current image works as expected.

joscha82 commented 2 years ago

@joscha82 the build of the docker image can be seen here: https://github.com/joscha82/wattpilot/runs/6564042519?check_suite_focus=true It would be interesting to see, if a release correctly taggs the docker image with the version number. Maybe it's time to release the first version as 1.0.0 (after feedback to the docker image) since IMO it's now ready and running for weeks on my side with just rare minor issues. The next step would be to generate docker images for multiple architectures, if the current image works as expected.

Also running now (mqtt bridge) for a few days without issues here. I also added a similar workflow to publish new releases to pypi upon new releases.

Will bump release version to 0.2 soon and create new release and will check if pypi and docker upload are working then.

thecem commented 2 years ago

sry, will be back next week and try to test…

thecem commented 2 years ago

tryed to start the docker with portainer (in ha) with folowing stack config:

version: '2'
services:
  wattpilot:
    image: ghcr.io/joscha82/wattpilot:latest
    restart: always
    network_mode: host
    environment:
      - PGID=0
      - PUID=0
      - HA_ENABLED=true
      - MQTT_ENABLED=true
      - MQTT_HOST=<mqtt_host>
      - WATTPILOT_HOST=<wattpilot_ip>
      - WATTPILOT_PASSWORD=<my_secret_password>
    volumes:
      - /mnt/data/supervisor/homeassistant/wattpilot:/wattpilot

missing is MQTT_USER and MQTT_PASSWORD since my mqtt is secured.

but the container is allways restarting.....

joscha82 commented 2 years ago

can you post the output of "docker-compose logs wattpilot"? Or click on the wattpilot container in portainer and then logs.

You do not need to mount a volume into the container and most likely can remove the volumes: config, as the container does not need to save persistant data.

thecem commented 2 years ago

found the problem, following is working but not connecting to ha since no mptt pw and user

version: '3'
services:
  wattpilot:
    image: ghcr.io/joscha82/wattpilot:main
   command: server
    restart: always
    network_mode: host
    environment:
      - PGID=0
      - PUID=0
      - HA_ENABLED=true
      - MQTT_ENABLED=true
      - MQTT_HOST=<mqtt_host>
      - WATTPILOT_HOST=<wattpilot_ip>
      - WATTPILOT_PASSWORD=<my_secret_password>
    volumes:
      - /mnt/data/supervisor/homeassistant/wattpilot:/wattpilot

logs:

2022-06-05T17:10:05.699809000Z INFO:wattpilot.wattpilotshell:Automatically connecting to Wattpilot ...
2022-06-05T17:10:05.700070000Z INFO:wattpilot:Wattpilot None initilized
2022-06-05T17:10:05.700384000Z INFO:wattpilot:Wattpilot connected
2022-06-05T17:10:35.771114000Z ERROR: Timeout while connecting to Wattpilot!
2022-06-05T17:10:36.266359000Z INFO:wattpilot.wattpilotshell:Automatically connecting to Wattpilot ...
2022-06-05T17:10:36.266553000Z INFO:wattpilot:Wattpilot None initilized
2022-06-05T17:10:36.266851000Z INFO:wattpilot:Wattpilot connected
2022-06-05T17:11:06.322557000Z ERROR: Timeout while connecting to Wattpilot!
2022-06-05T17:11:06.810498000Z INFO:wattpilot.wattpilotshell:Automatically 
thecem commented 2 years ago

finaly i found another problem, i tried to connect to the wrong wp, after changing the ip to the right one:

INFO:wattpilot.wattpilotshell:Automatically connecting to Wattpilot ...
INFO:wattpilot:Wattpilot None initilized
INFO:wattpilot:Wattpilot connected
INFO:wattpilot:Connected to WattPilot Serial 31224711
INFO:wattpilot:Authentication successful
INFO:wattpilot.wattpilotshell:Connecting to MQTT host 192.168.xxx.100 on port 1883 ...
INFO:wattpilot.wattpilotshell:Subscribing to command topics wattpilot/properties/+/set
INFO:wattpilot.wattpilotshell:Registering message callback to publish updates to the following properties to MQTT: ['acs', 'alw', 'ama', 'amp', 'awc', 'awp', 'bac', 'car', 'cbl', 'cch', 'cco', 'cus', 'dwo', 'err', 'eto', 'etop', 'fbuf_akkuSOC', 'fbuf_pAkku', 'fbuf_pGrid', 'fbuf_pPv', 'ffb', 'fna', 'fot', 'frc', 'fst', 'fwv', 'lck', 'lmo', 'loty', 'modelStatus', 'nrg', 'nrg_ptotal', 'ocs', 'pvopt_averagePAkku', 'pvopt_averagePGrid', 'pvopt_averagePOhmpilot', 'pvopt_averagePPv', 'pvopt_deltaA', 'pvopt_deltaP', 'pwm', 'scas', 'sse', 'tds', 'tse', 'ust', 'var', 'wh', 'wsms', 'wst']
INFO:wattpilot.wattpilotshell:Enabling HA discovery for the following properties: ['acs', 'alw', 'ama', 'amp', 'awc', 'awp', 'bac', 'car', 'cbl', 'cch', 'cco', 'cus', 'dwo', 'err', 'eto', 'etop', 'fbuf_akkuSOC', 'fbuf_pAkku', 'fbuf_pGrid', 'fbuf_pPv', 'ffb', 'fna', 'fot', 'frc', 'fst', 'fwv', 'lck', 'lmo', 'loty', 'modelStatus', 'nrg', 'nrg_ptotal', 'ocs', 'pvopt_averagePAkku', 'pvopt_averagePGrid', 'pvopt_averagePOhmpilot', 'pvopt_averagePPv', 'pvopt_deltaA', 'pvopt_deltaP', 'pwm', 'scas', 'sse', 'tds', 'tse', 'ust', 'var', 'wh', 'wsms', 'wst']
INFO:wattpilot.wattpilotshell:Publishing all initial property values to MQTT to populate the entity values ...
INFO:wattpilot.wattpilotshell:Server started.
thecem commented 2 years ago

MQTT: User and Password is missing, how to configure?

1654450395: Client <unknown> disconnected, not authorised.
1654450400: New connection from 172.30.32.1:37368 on port 1883.
error: received null username or password for unpwd check
thecem commented 2 years ago

how to check the mqtt is working in the container...? (via shell to the container...)

ahochsteger commented 2 years ago

@thecem, @joscha82, this PR adds the environment variables MQTT_USERNAME and MQTT_PASSWORD for authenticated MQTT: https://github.com/joscha82/wattpilot/pull/13 Would be great, if you could give it a try.

thecem commented 2 years ago

main?

joscha82 commented 2 years ago

yes. I just merged the PR and new docker image just finished the build in main branch. You should receive the update upon next container-start with @ahochsteger MQTT Auth Support.

thecem commented 2 years ago

tried directly, but seems mqtt is not working. No mqtt packets go out or to the container. Is there a diffrent debug level for mqtt?

thecem commented 2 years ago

after serval trys:

1654460518: New connection from 192.168.7.100:57629 on port 1883.
1654460518: New client connected from 192.168.7.100:57629 as wattpilot2mqtt (p2, c1, k60, u'mqttfoo').

but then:

1654460591: Client wattpilot2mqtt closed its connection.

thecem commented 2 years ago

got it working, since I configured my mqtt to test in the wrong way, after reconfig the deafult wattpilot is discoverd in mqtt. Will test tomorow....

thx

thecem commented 2 years ago

perfect it works realy great! In this moment not a addon but on the best way to become one...

thx a lot!