Problem with Zoneminder component in Homeassistant

Forum for questions and support relating to 1.33.x development only.
Locked
Johnny1337
Posts: 14
Joined: Tue Oct 15, 2019 11:22 am

Problem with Zoneminder component in Homeassistant

Post by Johnny1337 »

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?
User avatar
iconnor
Posts: 2896
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Problem with Zoneminder component in Homeassistant

Post by iconnor »

Login denied basically means that the password was wrong, or the user is disabled or not found.
Johnny1337
Posts: 14
Joined: Tue Oct 15, 2019 11:22 am

Re: Problem with Zoneminder component in Homeassistant

Post by Johnny1337 »

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"}}}
User avatar
iconnor
Posts: 2896
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Problem with Zoneminder component in Homeassistant

Post by iconnor »

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
blauter
Posts: 7
Joined: Fri Dec 07, 2018 7:23 pm

Re: Problem with Zoneminder component in Homeassistant

Post by blauter »

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}
alfvicente
Posts: 7
Joined: Sat Mar 25, 2017 6:32 am

Re: Problem with Zoneminder component in Homeassistant

Post by alfvicente »

iconnor wrote: Fri Oct 18, 2019 5:32 pm 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
Thank you for this! if you can please add it to the API documentation
Locked