Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: add mqtt vars to dockerStart.sh #1454

Merged
merged 1 commit into from
Jun 27, 2022

Conversation

xaviml
Copy link
Contributor

@xaviml xaviml commented Jan 9, 2022

Adds MQTT plugin with the environment variables for the namespace, host, user, and password to the dockerStart.sh file.

Note that this adds the plugin only if the variables are present, so this PR does not break the current functionality.

I have tested this with my own HA and MQTT server.

After running:

docker run --rm \
-e DASH_URL=http://127.0.0.1:5050 \
-e HA_URL="http://xxx.xxx.x.xxx:8123" \
-e TOKEN="MY_HA_TOKEN" \
-e MQTT_NAMESPACE=mqtt \
-e MQTT_CLIENT_HOST=xxx.xxx.x.xxx \
-e MQTT_CLIENT_USER=xxxx \
-e MQTT_CLIENT_PASSWORD=xxxx \
appdaemon

I got:

Click to expand!
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
OK: 921 MiB in 69 packages
2022-01-09 19:36:26.371830 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-01-09 19:36:26.372074 INFO AppDaemon: Python version is 3.9.9
2022-01-09 19:36:26.372328 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml
2022-01-09 19:36:26.372491 INFO AppDaemon: Added log: AppDaemon
2022-01-09 19:36:26.372643 INFO AppDaemon: Added log: Error
2022-01-09 19:36:26.372778 INFO AppDaemon: Added log: Access
2022-01-09 19:36:26.372954 INFO AppDaemon: Added log: Diag
2022-01-09 19:36:26.400148 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-01-09 19:36:26.466757 INFO HASS: HASS Plugin Initializing
2022-01-09 19:36:26.466956 INFO HASS: HASS Plugin initialization complete
2022-01-09 19:36:26.467282 INFO AppDaemon: Loading Plugin MQTT using class MqttPlugin from module mqttplugin
2022-01-09 19:36:26.474109 INFO MQTT: MQTT Plugin Initializing
2022-01-09 19:36:26.474387 INFO MQTT: Using 'mqtt-client/status' as Will Topic
2022-01-09 19:36:26.474602 INFO MQTT: Using 'mqtt-client/status' as Birth Topic
2022-01-09 19:36:26.474841 INFO MQTT: Using appdaemon_mqtt_client as Client ID
2022-01-09 19:36:26.475589 INFO AppDaemon: Initializing HTTP
2022-01-09 19:36:26.476134 INFO AppDaemon: Using 'ws' for event stream
2022-01-09 19:36:26.481802 INFO AppDaemon: Starting API
2022-01-09 19:36:26.486466 INFO AppDaemon: Starting Admin Interface
2022-01-09 19:36:26.487084 INFO AppDaemon: Starting Dashboards
2022-01-09 19:36:26.509931 INFO HASS: Connected to Home Assistant 2021.12.8
2022-01-09 19:36:26.525877 INFO AppDaemon: App 'hello_world' added
2022-01-09 19:36:26.527123 INFO AppDaemon: Found 1 total apps
2022-01-09 19:36:26.527908 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2022-01-09 19:36:26.528887 INFO AppDaemon: Running on port 5050
2022-01-09 19:36:26.543176 INFO MQTT: Connected to Broker at URL xxx.xxx.x.xxx:1883
2022-01-09 19:36:26.551861 INFO AppDaemon: Got initial state from namespace mqtt
2022-01-09 19:36:26.552509 INFO MQTT: MQTT Plugin initialization complete
2022-01-09 19:36:26.625510 INFO HASS: Evaluating startup conditions
2022-01-09 19:36:26.634525 INFO HASS: Startup condition met: hass state=RUNNING
2022-01-09 19:36:26.634957 INFO HASS: All startup conditions met
2022-01-09 19:36:26.668390 INFO AppDaemon: Got initial state from namespace default
2022-01-09 19:36:28.537358 INFO AppDaemon: Scheduler running in realtime
2022-01-09 19:36:28.540996 INFO AppDaemon: Adding /conf/apps to module import path
2022-01-09 19:36:28.544024 INFO AppDaemon: Loading App Module: /conf/apps/hello.py
2022-01-09 19:36:28.551214 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2022-01-09 19:36:28.664238 INFO hello_world: Hello from AppDaemon
2022-01-09 19:36:28.665862 INFO hello_world: You are now ready to run Apps!
2022-01-09 19:36:28.667970 INFO AppDaemon: App initialization complete

And, after running:

docker run --rm \
-e DASH_URL=http://127.0.0.1:5050 \
-e HA_URL="http://xxx.xxx.x.xxx:8123" \
-e TOKEN="MY_HA_TOKEN" \
appdaemon

I got:

Click to expand!
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
OK: 921 MiB in 69 packages
2022-01-09 19:38:13.766029 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-01-09 19:38:13.766228 INFO AppDaemon: Python version is 3.9.9
2022-01-09 19:38:13.766447 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml
2022-01-09 19:38:13.766660 INFO AppDaemon: Added log: AppDaemon
2022-01-09 19:38:13.766902 INFO AppDaemon: Added log: Error
2022-01-09 19:38:13.767133 INFO AppDaemon: Added log: Access
2022-01-09 19:38:13.767381 INFO AppDaemon: Added log: Diag
2022-01-09 19:38:13.790416 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-01-09 19:38:13.850965 INFO HASS: HASS Plugin Initializing
2022-01-09 19:38:13.851202 INFO HASS: HASS Plugin initialization complete
2022-01-09 19:38:13.851898 INFO AppDaemon: Initializing HTTP
2022-01-09 19:38:13.852914 INFO AppDaemon: Using 'ws' for event stream
2022-01-09 19:38:13.857246 INFO AppDaemon: Starting API
2022-01-09 19:38:13.861411 INFO AppDaemon: Starting Admin Interface
2022-01-09 19:38:13.862021 INFO AppDaemon: Starting Dashboards
2022-01-09 19:38:13.888255 INFO HASS: Connected to Home Assistant 2021.12.8
2022-01-09 19:38:13.901867 INFO AppDaemon: App 'hello_world' added
2022-01-09 19:38:13.902805 INFO AppDaemon: Found 1 total apps
2022-01-09 19:38:13.903383 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2022-01-09 19:38:13.904529 INFO AppDaemon: Running on port 5050
2022-01-09 19:38:13.969136 INFO HASS: Evaluating startup conditions
2022-01-09 19:38:13.978630 INFO HASS: Startup condition met: hass state=RUNNING
2022-01-09 19:38:13.979093 INFO HASS: All startup conditions met
2022-01-09 19:38:14.048523 INFO AppDaemon: Got initial state from namespace default
2022-01-09 19:38:15.913248 INFO AppDaemon: Scheduler running in realtime
2022-01-09 19:38:15.918536 INFO AppDaemon: Adding /conf/apps to module import path
2022-01-09 19:38:15.921264 INFO AppDaemon: Loading App Module: /conf/apps/hello.py
2022-01-09 19:38:15.927191 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2022-01-09 19:38:16.046826 INFO hello_world: Hello from AppDaemon
2022-01-09 19:38:16.048532 INFO hello_world: You are now ready to run Apps!
2022-01-09 19:38:16.050565 INFO AppDaemon: App initialization complete

Note that appdaemon is the image name I gave after building the Dockerfile, and real values have been masked.

@Odianosen25 Odianosen25 merged commit af30c1a into AppDaemon:dev Jun 27, 2022
@xaviml xaviml deleted the docker/add-mqtt-plugin branch June 27, 2022 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants