Closed BeFygo closed 2 weeks ago
I don't know if this helps but I just tried:
Home Assistant
# modified version of: https://www.home-assistant.io/installation/linux#install-home-assistant-container
# /test being my temp config directory
docker run -d -p 8123:8123 --name homeassistant -e TZ="Europe/Paris" -v $(pwd)/test:/config ghcr.io/home-assistant/home-assistant:stable
EMHASS
# copied config_emhass.yaml and secrets_emhass.yaml (from secrets_emhass(copy).yaml) into /test2
docker run -it -p 5000:5000 --network=host --name emhass-container -v $(pwd)/test2/config_emhass.yaml:/app/config_emhass.yaml -v $(pwd)/test2/secrets_emhass.yaml:/app/secrets_emhass.yaml davidusb/emhass-docker-standalone:latest
These docker runs are just minimal, your volume mounts may be different.
It is my understanding that the EMHASS container would need to have --network=host
in order to access localhost
. (Which I believe your already doing in your Docker compose)
Its my understanding that, by default, Docker runs its networking in bridge mode. A alternative method would be to obtain the Home Assistant bridged ip address and pass that into the EMHASS container. (In theory bypassing the need for network=host)
An example:
# grab the ip address of the running homeassistant
docker exec -it homeassistant ip addr
In my case it was 172.17.0.3
with eth0@if23
network interface, then pass this ip address into the EMHASS secrets.
secrets_emhass.yaml
# Use this file to store secrets like usernames and passwords.
# Learn more at https://home-assistant.io/docs/configuration/secrets/
hass_url: http://172.17.0.3:8123/
long_lived_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI2Y2FkYWQwMTM4MWY0ODM4YTVhYmU3ZGQ1YmUxMzE0YyIsImlhdCI6MTcxODI4MDMzMywiZXhwIjoyMDMzNjQwMzMzfQ.EvfjVXS7KX15KrfATvzlIm06e-U0mXjDdSF0lm7V5_0
time_zone: Europe/Paris
lat: 45.83
lon: 6.86
alt: 4807.8
solcast_api_key: yoursecretsolcastapikey
solcast_rooftop_id: yourrooftopid
solar_forecast_kwp: 5
Note: you may need a foward slash /
at the end of your address: http://localhost:8123
to http://localhost:8123/
Other than maybe obtaining another Long-lived access tokens
token, and testing a new, I am not quite sure whats going on.
Thank you for the help.
I tried your suggestions and in the end it was just the foward slash /
at the end of the address :D
Describe the bug I'm unable to get data from home assistant with the Optimization request.
To Reproduce Home assistant docker en EMHASS docker setup with docker compose both in Network Host mode.
Expected behavior That EMHASS would request data from Home Assistant
Screenshots![image](https://github.com/davidusb-geek/emhass/assets/72655961/0704b637-b778-40df-b479-36057f8d57ed)
Home Assistant installation type
Your hardware
EMHASS installation type
Additional context Secret_emhass.yaml: hass_url: http://localhost:8123 long_lived_token: correct time_zone: Europe/Brussels lat: * lon: alt: 24.4
Docker compose: version: "3.8" services:
homeassistant2: image: ghcr.io/home-assistant/home-assistant:stable container_name: homeAssistant environment:
TZ=Europe/Brussels
volumes:
privileged: true network_mode: host
restart: unless-stopped
emhass: image: davidusb/emhass-docker-standalone:latest container_name: emhass environment:
LOCAL_COSTFUN="profit" volumes:
network_mode: host restart: unless-stopped