I’m following this guide.
I have an app (~/homeassistant/conf/apps/hello.py
):
import appdaemon.plugins.hass.hassapi as hass
class HelloWorld(hass.Hass):
def initialize(self):
self.register_endpoint(self.my_callback, "test_endpoint")
def my_callback(self, data):
self.log(data)
response = {"message": "ok"}
return response, 200
Which is being run:
$ sudo systemctl status [email protected]
● [email protected] - AppDaemon
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-08-31 17:20:23 UTC; 34min ago
Main PID: 7987 (appdaemon)
CGroup: /system.slice/system-appdaemon.slice/[email protected]
└─7987 /usr/bin/python3 /usr/local/bin/appdaemon -c /home/pi/homeassistant/conf
Aug ~-~ INFO AppDaemon: HASS: Connected to Home Assistant 0.77.0
Aug ~-~ INFO AppDaemon: Got initial state from namespace default
Aug ~-~ INFO AppDaemon: Reading config
Aug ~-~ INFO AppDaemon: /home/pi/homeassistant/conf/apps/apps.yaml added or modified
Aug ~-~ INFO AppDaemon: /home/pi/homeassistant/conf/apps/apps.yaml added or modified
Aug ~-~ INFO AppDaemon: App 'hello_world' added
Aug ~-~ INFO AppDaemon: Adding /home/pi/homeassistant/conf/apps to module import path
Aug ~-~ AppDaemon: Loading App Module: /home/pi/homeassistant/conf/apps/hello.py
Aug ~-~ INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
Aug ~-~ INFO AppDaemon: App initialization complete
But I can’t get appdaemon to respond to a request:
$curl -i -X POST -H 'Content-Type: application/json' -d '{test: "yes"}' http://192.168.0.81:5050/api/appdaemon/test_endpont
curl: (7) Failed to connect to 192.168.0.81 port 5050: Connection refused
My appdaemon.yaml
:
appdaemon:
threads: 10
ad_port: 5050
plugins:
HASS:
type: hass
ha_url: http://192.168.0.81:8123
ha_key: 'ha_key'
I’ve tried adding api_key: 'api_key'
to appdaemon.yaml
, along with -H "x-ad-access: 'api_key'"
in the request, didn’t help.
Telnet can’t reach port 5050 either:
$ telnet 192.168.0.81 5050
Trying 192.168.0.81...
telnet: Unable to connect to remote host: Connection refused