Hi,
I have a problem when using the Zoneminder component in Homeassistant. It won't let me login, gives me error "Connection error logging into ZoneMinder. I have tried both ip-address and domainname as host but cannot get it to work.
Then I thought that I can use the API with curl commands instead and see if that would work. I get the error below. I am using zmeventnotification and that works like a charm.
johnny@UBUNTU:~$ curl -XPOST -c cookies.txt -d "user=username&pass=password&stateful=1" https://mydomain.com:443/zm/api/host/login.json
{"success":false,"data":{"name":"Login denied for user "username"","message":"Login denied for user "username"","url":"\/zm\/api\/host\/login.json","exception":{"class":"UnauthorizedException","code":401,"message":"Login denied for user \"username\""}}}
I think there might be the same problem for both Homeassistant component and Zoneminder API.
Any ideas?
Problem with Zoneminder component in Homeassistant
-
- Posts: 14
- Joined: Tue Oct 15, 2019 11:22 am
Re: Problem with Zoneminder component in Homeassistant
Login denied basically means that the password was wrong, or the user is disabled or not found.
-
- Posts: 14
- Joined: Tue Oct 15, 2019 11:22 am
Re: Problem with Zoneminder component in Homeassistant
I see, changed my password to a new password without any special characters and then I can login.
When using the command: "curl http://server/zm/api/monitors.json -b cookies.txt" I get error message below.
{"success":false,"data":{"name":"Not Authenticated","message":"Not Authenticated","url":"\/zm\/api\/monitors\/1.json","exception":{"class":"UnauthorizedException","code":401,"message":"Not Authenticated"}}}
When using the command: "curl http://server/zm/api/monitors.json -b cookies.txt" I get error message below.
{"success":false,"data":{"name":"Not Authenticated","message":"Not Authenticated","url":"\/zm\/api\/monitors\/1.json","exception":{"class":"UnauthorizedException","code":401,"message":"Not Authenticated"}}}
Re: Problem with Zoneminder component in Homeassistant
You need to add a stateful=1
The API is stateless, so now if you want to use cookies, etc you have to specifically tell it to. Otherwise add the user=&pass= to every request
The API is stateless, so now if you want to use cookies, etc you have to specifically tell it to. Otherwise add the user=&pass= to every request
Re: Problem with Zoneminder component in Homeassistant
Should home assistant be working with Zoneminder? I was under the impression that it was broken until the HA ZM component was updated to use newer API auth method.
With ZM 1.33.14~20191020114516-bionic I am still getting these in error log:
2019-10-21 22:04:24 Error: [UnauthorizedException] Not Authenticated
Request URL: /zm/api/host/getVersion.json
Stack Trace:
#0 /usr/share/zoneminder/www/api/lib/Cake/Event/CakeEventManager.php(243): AppController->beforeFilter(Object(CakeEvent))
#1 /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php(677): CakeEventManager->dispatch(Object(CakeEvent))
#2 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(189): Controller->startupProcess()
#3 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(HostController), Object(CakeRequest))
#4 /usr/share/zoneminder/www/api/app/webroot/index.php(107): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#5 {main}
With ZM 1.33.14~20191020114516-bionic I am still getting these in error log:
2019-10-21 22:04:24 Error: [UnauthorizedException] Not Authenticated
Request URL: /zm/api/host/getVersion.json
Stack Trace:
#0 /usr/share/zoneminder/www/api/lib/Cake/Event/CakeEventManager.php(243): AppController->beforeFilter(Object(CakeEvent))
#1 /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php(677): CakeEventManager->dispatch(Object(CakeEvent))
#2 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(189): Controller->startupProcess()
#3 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(HostController), Object(CakeRequest))
#4 /usr/share/zoneminder/www/api/app/webroot/index.php(107): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#5 {main}
-
- Posts: 7
- Joined: Sat Mar 25, 2017 6:32 am