mKeRix / room-assistant

Presence tracking and more for automation on the room-level
https://www.room-assistant.io
MIT License
1.27k stars 122 forks source link

Docker impossible get configuration file #961

Closed RobertusIT closed 2 years ago

RobertusIT commented 2 years ago

Describe the bug Impossible to config local.yml

To reproduce room assistant start with default config

Relevant logs Log output that correlates to the bug. You can get debug output with room-assistant -v.

[16:50:33] INFO: Copying room-assistant configuration from /config/room_assistant

[16:50:33] INFO: Starting room-assistant

*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.

*** WARNING *** Please fix your application to use the native API of Avahi!

*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>

*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.

*** WARNING *** Please fix your application to use the native API of Avahi!

*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>

11/8/2021, 4:50:34 PM - info - IntegrationsModule: Loading integrations: home-assistant

11/8/2021, 4:50:35 PM - info - NestFactory: Starting Nest application...

11/8/2021, 4:50:35 PM - info - InstanceLoader: AppModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: ConfigModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: NestEmitterModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: IntegrationsModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: DiscoveryModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: PrometheusModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: EventsModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: TerminusModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: ClusterModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: ScheduleModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: EntitiesModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: HomeAssistantModule dependencies initialized

11/8/2021, 4:50:35 PM - info - InstanceLoader: StatusModule dependencies initialized

11/8/2021, 4:50:35 PM - info - RoutesResolver: EntitiesController {/entities}:

11/8/2021, 4:50:35 PM - info - RouterExplorer: Mapped {/entities, GET} route

11/8/2021, 4:50:35 PM - info - RoutesResolver: StatusController {/status}:

11/8/2021, 4:50:35 PM - info - RouterExplorer: Mapped {/status, GET} route

11/8/2021, 4:50:35 PM - info - RoutesResolver: PrometheusController {/metrics}:

11/8/2021, 4:50:35 PM - info - RouterExplorer: Mapped {/metrics, GET} route

11/8/2021, 4:50:35 PM - info - ConfigService: Loading configuration from /usr/lib/node_modules/room-assistant/dist/config/definitions/default.js, config/local.yml (Current: /room-assistant)

11/8/2021, 4:50:35 PM - error - HomeAssistantService: connect ECONNREFUSED 127.0.0.1:1883

11/8/2021, 4:50:35 PM - error - ClusterService: Failed to start mdns discovery (dns service error: unknown)

11/8/2021, 4:50:35 PM - info - NestApplication: Nest application successfully started

11/8/2021, 4:50:37 PM - info - ClusterService: changeme has been elected as leader

11/8/2021, 4:50:37 PM - info - HomeAssistantService: Refreshing entity states

Relevant configuration Paste the relevant parts of your configuration below.

![image](https://user-images.githubusercontent.com/11599774/140784353-ee37be3b-6a25-4d18-a8f0-8aa0b28bc4bc.png)
global:
  instanceName: SALONE-NUC
  integrations:
    - homeAssistant
    - bluetoothClassic
    - bluetoothLowEnergy
homeAssistant:
  mqttUrl: 'mqtt://192.168.178.56:1883'
  mqttOptions:
    username: mqtt_user
    password: mqtt_user
bluetoothClassic:
#  hciDeviceId: 0
#  interval: 10
#  timeoutCycles: 2.5
#  minRssi:
#    '64:A2:F9:31:XX:XX': -10
#    default: -20
  addresses:
    - '64:A2:F9:31:0B:B9'
#  entityOverrides:
#   '64:A2:F9:31:XX:XX':
#    id: ONE-PLUS6
#    name: oneplus_6
bluetoothLowEnergy:
  allowlist:
    - c7XX80fXXfXX
  tagOverrides:
    c72c80ff2fdc:
      name: Mi Band 6

Expected behavior I can't start room assistant in docker with my yaml

Environment

hellcry37 commented 2 years ago

Check not to have [TABS] in that config, i am 99% that is the issue here, there is no bug.

If you read about YAML you will know it will not handle [TAB]

RobertusIT commented 2 years ago

Check not to have [TABS] in that config, i am 99% that is the issue here, there is no bug.

If you read about YAML you will know it will not handle [TAB]

In first, thanks to reply

Sorry but what do you means about TABS ?

I searched without success, I'm not an expert about docker and portainer, but anyway I didn't find any "tabs" features

hellcry37 commented 2 years ago

edit your yaml file (config) delete all white spaces and put them back but only with space bar, do not use TAB from your keyboard

RobertusIT commented 2 years ago

edit your yaml file (config) delete all white spaces and put them back but only with space bar, do not use TAB from your keyboard

I have tried without success, and when i start room assistant, my config file, come back to default

global:
  instanceName: SALONENUC
  integrations:
    - homeAssistant
    - bluetoothClassic
    - bluetoothLowEnergy
homeAssistant:
  mqttUrl: 'mqtt://192.168.178.56:1883'
  mqttOptions:
    username: mqtt_user
    password: mqtt_user
bluetoothClassic:
  addresses:
    - '64:A2:F9:31:0B:B9'
bluetoothLowEnergy:
  allowlist:
    - c7XX80fXXfXX
  tagOverrides:
    c72c80ff2fdc:
      name: Mi Band 6
hellcry37 commented 2 years ago

check docker mounts, from what i sow not sure are ok https://user-images.githubusercontent.com/11599774/140784353-ee37be3b-6a25-4d18-a8f0-8aa0b28bc4bc.png

RobertusIT commented 2 years ago

check docker mounts, from what i sow not sure are ok https://user-images.githubusercontent.com/11599774/140784353-ee37be3b-6a25-4d18-a8f0-8aa0b28bc4bc.png

in according to https://www.room-assistant.io/guide/configuration.html#configuring-with-docker

image

same story

[22:08:20] ERROR: Something went wrong contacting the API

[22:08:20] INFO: Creating default room-assistant configuration under /config/room_assistant

[22:08:20] INFO: Copying room-assistant configuration from /config/room_assistant

[22:08:20] INFO: Starting room-assistant

*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.

*** WARNING *** Please fix your application to use the native API of Avahi!

*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>

*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.

*** WARNING *** Please fix your application to use the native API of Avahi!

*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>

11/10/2021, 10:08:21 PM - info - IntegrationsModule: Loading integrations: home-assistant

11/10/2021, 10:08:22 PM - info - NestFactory: Starting Nest application...

11/10/2021, 10:08:22 PM - info - InstanceLoader: AppModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: ConfigModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: NestEmitterModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: IntegrationsModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: DiscoveryModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: PrometheusModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: EventsModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: TerminusModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: ClusterModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: ScheduleModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: EntitiesModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: HomeAssistantModule dependencies initialized

11/10/2021, 10:08:22 PM - info - InstanceLoader: StatusModule dependencies initialized

11/10/2021, 10:08:22 PM - info - RoutesResolver: EntitiesController {/entities}:

11/10/2021, 10:08:22 PM - info - RouterExplorer: Mapped {/entities, GET} route

11/10/2021, 10:08:22 PM - info - RoutesResolver: StatusController {/status}:

11/10/2021, 10:08:22 PM - info - RouterExplorer: Mapped {/status, GET} route

11/10/2021, 10:08:22 PM - info - RoutesResolver: PrometheusController {/metrics}:

11/10/2021, 10:08:22 PM - info - RouterExplorer: Mapped {/metrics, GET} route

11/10/2021, 10:08:22 PM - info - ConfigService: Loading configuration from /usr/lib/node_modules/room-assistant/dist/config/definitions/default.js, config/local.yml (Current: /room-assistant)

11/10/2021, 10:08:22 PM - error - HomeAssistantService: connect ECONNREFUSED 127.0.0.1:1883

11/10/2021, 10:08:22 PM - error - ClusterService: Failed to start mdns discovery (dns service error: unknown)

11/10/2021, 10:08:22 PM - info - NestApplication: Nest application successfully started

11/10/2021, 10:08:24 PM - info - ClusterService: changeme has been elected as leader

11/10/2021, 10:08:24 PM - info - HomeAssistantService: Refreshing entity state

And also create a config folder into my /mnt/room-assistant folder ( mount folder )

and overwrite my local.yaml with default yaml....

hellcry37 commented 2 years ago

ok so this: error - HomeAssistantService: connect ECONNREFUSED 127.0.0.1:1883

says your instance of room assistant can't connect to mqtt broker

[22:08:20] INFO: Creating default room-assistant configuration under /config/room_assistant [22:08:20] INFO: Copying room-assistant configuration from /config/room_assistant this say in container path is /config/room_assistant but yours is /room_assistant/config ( this is curious because I have same paths and mine works /room_assistant/config, something fishy here )

to fix mqtt error, check mqtt container logs I think is set not to accept connections from anything except localhost, look in conf

hellcry37 commented 2 years ago

here is a good conf take from it: part of docker-compose file

version: '3.7'
services:
  room-assistant:
    image: mkerix/room-assistant
    container_name: room-assistant
    restart: unless-stopped
    network_mode: host
    cap_add:
      - NET_ADMIN
    environment:
      - 'TZ=Europe/Bucharest'
    volumes:
      - '/var/run/dbus:/var/run/dbus'
      - '/home/my-user/room-assistant/config:/room-assistant/config'

Note network_mode! Translate this for your container config

RobertusIT commented 2 years ago

here is a good conf take from it: part of docker-compose file

version: '3.7'
services:
  room-assistant:
    image: mkerix/room-assistant
    container_name: room-assistant
    restart: unless-stopped
    network_mode: host
    cap_add:
      - NET_ADMIN
    environment:
      - 'TZ=Europe/Bucharest'
    volumes:
      - '/var/run/dbus:/var/run/dbus'
      - '/home/my-user/room-assistant/config:/room-assistant/config'

Note network_mode! Translate this for your container config

image

net is already on

folder are:

image

inside lxc docker:

root@ROOM ~# cd /mnt/
root@ROOM /mnt# ls
 101.conf   103.conf   109.conf   frigate  'local - Copia.yml'   media     room-assistant   template
 102.conf   108.conf   dump       images    lost+found           private   snippets         vzsnap0
root@ROOM /mnt# cd room-assistant/
root@ROOM /mnt/room-assistant# ls
config
root@ROOM /mnt/room-assistant# cd config/
root@ROOM .../room-assistant/config# ls
local.yml
root@ROOM .../room-assistant/config# 
root@ROOM .../room-assistant/config# cat local.yml 
# You don't need to add the MQTT details for Home Assistant with the add-on installation, it will be auto-discovered!
global:
  instanceName: SALONENUC
  integrations:
    - homeAssistant
    - bluetoothClassic
    - bluetoothLowEnergy
homeAssistant:
  mqttUrl: 'mqtt://192.168.178.56:1883'
  mqttOptions:
    username: mqtt_user
    password: mqtt_user
bluetoothClassic:
  addresses:
    - '64:A2:F9:31:0B:B9'
bluetoothLowEnergy:
  allowlist:
    - c7XX80fXXfXX
  tagOverrides:
    c72c80ff2fdc:
      name: Mi Band 6root@ROOM .../room-assistant/config# 
root@ROOM .../room-assistant/config# ls -la
total 4
drwxr-xr-x 2 root root   0 Nov 11 08:33 .
drwxr-xr-x 2 root root   0 Nov 11 08:33 ..
-rwxr-xr-x 1 root root 518 Nov 10 21:24 local.yml
root@ROOM .../room-assistant/config# 

So folder is mounted into lxc docker for room assistant.

Reboot room assistant and:

root@ROOM .../room-assistant/config# cat local.yml 
# You don't need to add the MQTT details for Home Assistant with the add-on installation, it will be auto-discovered!
global:
  instanceName: changeme
  integrations:
    - homeAssistant
root@ROOM .../room-assistant/config# 

So delete my config and replace with default, isn't normal

note. I use another lxc container with frigate, with google coral, and i didn't have any issue. and this lxc container use mqtt to connect itself into my home assistant.

dhallgb commented 2 years ago

I have the same problem - my mapped customised config file is overwritten by the default config file. My container can access the MQTT server, and the Yaml is in the correct format.

The container entrypoint.sh script tests for the existence of /config/room_assistant, and if empty creates a default local.yml in that directory and then copies the entire directory to /room_assistant/config inside the container, thereby overwriting my supplied local.yml in the mapped host directory.

Is this the expected behaviour? How do we supply a modified config file?

arsaboo commented 2 years ago

Here's a working Docker run command:

sudo docker run -d --name=roomassistant --net=host --restart=always -v /etc/localtime:/etc/localtime:ro -v /var/run/dbus:/var/run/dbus -v /home/pi/room-assistant/config:/room-assistant/config --cap-add=NET\_ADMIN mkerix/room-assistant:beta

I have had no problems with this. The config file is located at ~/room-assistant/config/local.yml

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. In an effort to provide a better overview of current issues we automatically clean some of the old ones. Many of them may already be resolved in newer versions of room-assistant. This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.