Hello,
as the title says, my Zoneminder integration is not loading any entities after I’ve upgraed from 2021.7.3 to 2021.8.7 (as far as i could tell, might be mistaken).
I haven’t done any changes to Home Assistant nor to Zoneminder instance.
Camera and switch entities are shown as “Entity not available” and log file only displays following:
2021-08-18 20:31:12 ERROR (SyncWorker_3) [zoneminder.zm] Unable to get API response from ZoneMinder
2021-08-18 20:31:12 ERROR (MainThread) [homeassistant.components.switch] Error while setting up zoneminder platform for switch
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/zoneminder/switch.py", line 31, in setup_platform
monitors = zm_client.get_monitors()
File "/usr/local/lib/python3.9/site-packages/zoneminder/zm.py", line 152, in get_monitors
for raw_result in raw_monitors["monitors"]:
KeyError: 'monitors'
I tried to use zoneminder python client to login myself in shell. I did that by logging physically to HassOS cli and issuing docker exec -it homeassistant bash
, then opened python3 shell under /usr/local/lib/python3.9/site-packages
following “code” is used:
from zoneminder.zm import ZoneMinder
zm = ZoneMinder("https://domain.com", "user", "pass", zms_path="/cgi-bin-zm/nph-zms")
zm.get_monitors() --> Returned below
Unable to get API response from ZoneMinder
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/zoneminder/zm.py", line 152, in get_monitors
for raw_result in raw_monitors["monitors"]:
KeyError: 'monitors'
zm.is_available --> Returned "True"
zm.login() --> Returned "True"
So I’m not really sure how to further troubleshoot this and any assistance would be greatly appreciated.
On the other note, I’ve also tried to login to zoneminder API using python requests manually, following code is used:
import requests
req = requests.post("https://domain.com/zm/api/host/login.json", data={'user': 'user', 'pass': 'pass'})
req.ok --> Returned "True"
req.json()["access_token"] --> Returned long access token
Considering i managed to login using requests manually and to get a token i believe ZM API seems to be working. However further digging i tried to open path to /api/monitors.json and i get 500 Internal Server Error.
This is what I’ve found in zoneminder cake_error.log
Request URL: /zm/api/monitors.json?token=long_token
Stack Trace:
#0 /usr/share/zoneminder/www/api/lib/Cake/Model/Model.php(3686): Model->setSource('Event_Summaries')
#1 /usr/share/zoneminder/www/api/lib/Cake/Model/Model.php(1394): Model->getDataSource()
#2 /usr/share/zoneminder/www/api/lib/Cake/Model/Datasource/DboSource.php(2663): Model->schema()
#3 /usr/share/zoneminder/www/api/lib/Cake/Model/Datasource/DboSource.php(1870): DboSource->fields(Object(Event_Summary), 'Event_Summary', '')
#4 /usr/share/zoneminder/www/api/lib/Cake/Model/Datasource/DboSource.php(1213): DboSource->generateAssociationQuery(Object(Monitor), Object(Event_Summary), 'hasOne', 'Event_Summary', Array, Array, false)
#5 /usr/share/zoneminder/www/api/lib/Cake/Model/Model.php(3053): DboSource->read(Object(Monitor), Array)
#6 /usr/share/zoneminder/www/api/lib/Cake/Model/Model.php(3025): Model->_readDataSource('all', Array)
#7 /usr/share/zoneminder/www/api/app/Controller/MonitorsController.php(67): Model->find('all', Array)
#8 [internal function]: MonitorsController->index()
#9 /usr/share/zoneminder/www/api/lib/Cake/Controller/Controller.php(499): ReflectionMethod->invokeArgs(Object(MonitorsController), Array)
#10 /usr/share/zoneminder/www/api/app/Plugin/Crud/Lib/CrudControllerTrait.php(31): Controller->invokeAction(Object(CakeRequest))
#11 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(193): AppController->invokeAction(Object(CakeRequest))
#12 /usr/share/zoneminder/www/api/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(MonitorsController), Object(CakeRequest))
#13 /usr/share/zoneminder/www/api/app/webroot/index.php(117): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#14 {main}
2021-08-18 21:45:45 Error: [MissingControllerException] Controller class GetVersionController could not be found.
Exception Attributes: array (
'class' => 'GetVersionController',
'plugin' => NULL,
)
Now… Since I was troubleshooting and writing this simoultaneously i figure out now that this is not an issue related to Home Assistant and upgrade itself, but something to do with the Zoneminder… Not sure what broke it or when or why… But do you have any idea of possible solution when looking at it …?