Kuna Surveillance Camera Support

Thanks Mark, but unfortunately I still have the same issue even if I deleted all the folder and reinstall from scratch, I am sure I have your last version.
I will double check everything and keep you update.
Have a great evening and thanks for your help.

*** LOG ***
2019-03-30 19:48:30 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
2019-03-30 19:48:30 ERROR (MainThread) [custom_components.kuna] There was an error logging into Kuna: No Kuna API token response returned, check username and password.
2019-03-30 19:48:30 ERROR (MainThread) [homeassistant.setup] Setup failed for kuna: Component ā€˜kunaā€™ did not return boolean if setup was successful. Disabling component.

Impossible to find where is the issue with v7, so I came back to the previous one :frowning:
If someone have an idea, I would appreciate your help.

New version fixes the issue for me, completely different behavior than last night. Thanks.

Just double checking, are you using v7 or v7.1?

I donā€™t think so - the main request method in pykuna now adds the Content-Type application/json header to every request.

Are you getting images returned at all? If so then the occasional timeout is probably nothing to worry about. It would be interesting to see if raising the timeout value from 3s would cause less requests to actually end in timeout.

I do get images, but itā€™s hit or miss, and was with v6. Iā€™d say about 80% of the time I got an image, and so far 7.1 is similar. From my log:

Request to Kuna API timed out
2:28 PM deps/lib/python3.7/site-packages/pykuna/kuna.py (ERROR) - message first occured at 6:20 AM and shows up 19 times

The annoying thing is it makes notifications unreliable. I.e. I have had an automation when it detects motion to take a snapshot and include it in an html5 notification, but when it fails I get no snapshot AND no notification (since the snapshot part fails). Which now that I think on it is weird since as far as Iā€™ve observed the motion doesnā€™t fail, just the snapshot.

Would it be possible to make the timeout an optional parameter to the component? Just a thought, and not high priority.

Man, this thing is so close to perfectā€¦

Iā€™ve been playing around today (slow day at work). I found the timeout and changed it in my local from 3 to 5 seconds. Iā€™ve had no timeout getting the image since, so Iā€™ll see how that goes.

BUT, on the first restart after the component login did the timeout/cannot load bit again. The second restart it loaded fine. Go figure.

Whatā€™s also odd is I played with the API call being used to get the image. It does consistently return in 4-5 seconds for me. Exceptā€¦when I call it with no parameters, and it returns right away! Meaning, apparently you donā€™t have to be authorized to get an image from the camera. Thatā€™sā€¦niceā€¦

Hello All,
I Finally got my camera installed, and am ready to add on this custom component! Thanks @marthocoo for all your hard work!
However, before I start messing with my Home Assistant, I have a question about the camera. I see on the Kuna app, when I click on my Maximus cam, it gives me a live shot for 2-3 seconds, then it goes black. My Wifi strength is farily good (46) to the device, and my Google Wifi shows good speed to the device (50 Mbps).
Do you think I have a wonky cam that I should replace? Any other tips? Will the video feed into Home Assistant work if the app doesnā€™t? Iā€™ve ready on Amazon that this is happening to a lot of customers.
I appreciate your guysā€™ thoughts / help.

16 API timeouts since yesterday. So going to 5 seconds certainly helps me a lot, but still has some hiccups.

@DKrics Yeah Iā€™d say that isnā€™t normal. If youā€™re sure itā€™s not your network nor power to the device, then it must be a defective cam. Mine has intermittent connectivity issues but I donā€™t have issues that reliablyā€¦I have streamed the cam for hours when Iā€™m expecting a package. I assume youā€™ll have the same issues with Home Assistant.

Thanks for the response. Reading reports on Amazon, the cut-outs are a sign of a defective cam. Likely will need to take it back. Will try one more thing, putting my Google Wifi directly next to it. But my signal strength is good as it is (-45). Weā€™ll see.

First off, @marthocoo, thank you for your work here ā€“ this is awesome.

Iā€™m running four Maximus cams with three on one wifi network and one on another. I use the Kuna app on my phone with no issues generally from the same network that has the single cam and the Pi running hass. Iā€™m 1-week new to Home Assistant and Iā€™m currently running hassbian after dabbling with hassio and a local VDI. Iā€™m currently just looking at the overview page and have not yet played with downloading recordings and such.

v7 ā€“ works for me with individual overview page thumbnails periodically flaking out, but coming back on their own in a matter of seconds. In the logs, the components all load up, then I see periodic timeouts continuing forever and lining up with when a UI thumbnail doesnā€™t load.

Apr  2 17:17:00 hassbian hass[488]: 2019-04-02 17:17:00 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:17:20 hassbian hass[488]: 2019-04-02 17:17:20 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:17:25 hassbian hass[488]: 2019-04-02 17:17:25 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:18:10 hassbian hass[488]: 2019-04-02 17:18:10 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:18:20 hassbian hass[488]: 2019-04-02 17:18:20 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:18:20 hassbian hass[488]: 2019-04-02 17:18:20 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:18:30 hassbian hass[488]: 2019-04-02 17:18:30 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:18:30 hassbian hass[488]: 2019-04-02 17:18:30 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:18:40 hassbian hass[488]: 2019-04-02 17:18:40 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:18:40 hassbian hass[488]: 2019-04-02 17:18:40 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:18:50 hassbian hass[488]: 2019-04-02 17:18:50 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:19:00 hassbian hass[488]: 2019-04-02 17:19:00 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:19:10 hassbian hass[488]: 2019-04-02 17:19:10 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out

On the first run with v7 Iā€™ll see a little more verbosity in the logs as well:

Apr  2 17:43:47 hassbian hass[489]: 2019-04-02 17:43:47 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:43:47 hassbian hass[489]:   File "/home/homeassistant/.homeassistant/custom_components/kuna/__init__.py", line 208, in scan_for_recordings
Apr  2 17:43:47 hassbian hass[489]:   File "/srv/homeassistant/lib/python3.5/site-packages/pykuna/recording.py", line 73, in get_download_link

v7.1 wonā€™t load for me at all with the same disable / timeout note in the logs that others have seen:

Apr  2 17:30:19 hassbian hass[468]: 2019-04-02 17:30:19 INFO (MainThread) [homeassistant.setup] Setting up kuna
Apr  2 17:30:22 hassbian hass[468]: 2019-04-02 17:30:22 ERROR (MainThread) [pykuna.kuna] Request to Kuna API timed out
Apr  2 17:30:22 hassbian hass[468]: 2019-04-02 17:30:22 ERROR (MainThread) [custom_components.kuna] There was an error logging into Kuna: No Kuna API token response returned, check username and password.
Apr  2 17:30:22 hassbian hass[468]: 2019-04-02 17:30:22 INFO (MainThread) [homeassistant.setup] Setup of domain kuna took 3.1 seconds.
Apr  2 17:30:22 hassbian hass[468]: 2019-04-02 17:30:22 ERROR (MainThread) [homeassistant.setup] Setup failed for kuna: Component 'kuna' did not return boolean if setup was successful. Disabling component.

Iā€™ve noticed some funky troubleshooting behavior, like if I have v7 running properly, checkout v7.1 then restart hass from the UI, but do not reboot the Pi, everything starts up again and continues working. Once I reboot the Pi though, v7.1 refuses to start back up. Maybe something to do with how the dependencies are loaded?

@DKrics ā€“ are you sure itā€™s actually giving you the live shot for those 2-3 seconds as opposed to just showing you the still thumbnail. I had one cam that would show the thumbnails fine, but when you switched to live view it would show the thumbnail for a second or two, then go black after switching to the stream. The app saw the camera as online the whole time. Power cycling the camera cleared it up for me and itā€™s been working fine for months.

I had another cam that had trouble staying online even with strong signal until one day it wouldnā€™t go back online at all. Kuna support easily replaced the defective cam, shipping me a replacement along with a pre-paid label to send them back the defective unit. If power cycling doesnā€™t work for you, Iā€™m betting Kuna support can take care of you.

@cilynx - my problem is when I click the thumbnail to go to the live feed, the picture goes black. May be 1 in 20 times will it work. Audio works, however. I can record video despite not being able to see it live, and the playback is fine. I got good signal strength, wifi speed, etc. Iā€™ve power cycled. Nothing works. I suspect its a bad camera. Iā€™m emailing support back and forth. If they donā€™t have a fix Iā€™ll return it to Costco.

Bad news, but Iā€™m seeing if that timeout following restarts again, with the latest HA release. Recording functionality works great though!

I am having issues with the last few updates, I can no longer see my camera. Havenā€™t dug into the logs, but was wondering if others are having similar issues. Also wondering if I should revert to Ver.6

@TarheelGrad1998 @DKrics @HITChris @cilynx

I have to say this is hard issue to troubleshoot given that I canā€™t seem to replicate it at all, but given that the errors seem to be centred on timeouts Iā€™m taking a stab at it.

Iā€™m trying out a different approach to timeout handling. If you want to test it, you will need to pull and then switch to the ā€œtestingā€ branch:

git pull
git checkout testing

As TarHeelGrad1998 has observed, you may need to restart in order for HASS to load the dependency correctly. Try that if it doesnā€™t come up the first time.

Iā€™d say that increasing the timeout from 3-5 seconds cut down on my timeouts, and I was only getting maybe 25% as many as before. But yes, still getting themā€¦including a failed component load after I updated to 0.91 today. So I updated to your testing branch. No timeouts yet, but will keep an eye on it.

Pulled testing this morning and it loaded and is working fine with no timeouts. Looking good here.

Same here.

Went all weekend without any timeouts at all, including Saturday after I remembered to set mine back to 3 seconds from 5. Seems you nailed it. Nice!