TP-Link Kasa Spot KC100

Glad to hear you found a way to run multiple instances of the add-on. I definitely agree that support for more cameras in the add-on itself would be ideal since it would involve less overhead. I’m still looking into it but have been pretty busy lately. If anyone is interested in helping to get this implemented I’ve created an issue on GitHub outlining how it could work. Fair warning I’m not super experienced with python, so you may have to sift through some spaghetti code :smile:.

Unfortunately i couldn’t get it to work. The streams don’t come up. I’m running duckdns so i suspect that might be the issue. I tried both the ip address and the duck dns address.

Working with my KC200 Outdoor Cameras too! Awesome stuff man… lets hope TP-Link dont patch this in an update!!

Hi guys,
I have added the repository into Addon Store, installed it.
Then edited the config and entered the details:

kasausername: email_address
kasapassword: password
cameraip: 192.xxx.xxx.xxx
cameraname: office
retrylimit: 5
retrysleep: 30
toggleentity: input_boolean.office_camera_enabled

went to configuration.yaml and added the lines:

camera:
  - platform: generic
    name: "Office Camera"
    still_image_url: "http://HA_IP:43330/thumbnails/office.jpg"
    stream_source: "http://HA_IP:43330/hls/office.m3u8"

restarted HA, and added the component in Lovelace.
However, when I try to start the addon I get the following in the logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Starting Nginx
Nginx Started
Starting controller
[Controller] Controller is starting.
[Controller] Loading configuration.
Traceback (most recent call last):
  File "/Controller/Controller.py", line 105, in <module>
    main()
  File "/Controller/Controller.py", line 102, in main
    controller.run()
  File "/Controller/Controller.py", line 92, in run
    initialState = self.getToggleValue()
  File "/Controller/Controller.py", line 31, in getToggleValue
    return response["state"] == "on"
KeyError: 'state'
[cmd] /run.sh exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

If I take out from config toggleentity: input_boolean.office_camera_enabled it starts and works ok - image is present.
By using this, is there a way to add multiple cameras? Or can I turn it on/off (privacy mode on/off)?
I have 3 KC100 cameras and 1 KC120 that I would like to have turn on/off automatically with automations.

I cannot get the audio to work with mine, is it working for you guys?

Thank you for creating and spending time on what you did! I tried your add-on for the new kasa cam EC70. Where would I find the stream once it’s set up?
I’m new to this…

I added the entity to the dash but there is no stream (idle).
Here are some of the errors I’m receiving in the log:

No trailing CRLF found in HTTP header. Adding it.
[rtmp @ …] Detected librtmp style URL parameters, these aren’t supported by the libavformat internal RTMP handler currently enabled. See the documentation for the correct way to pass parameters.
[flv @ …] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly

Tried this on a new install (latest stable version) am having quite a few issues getting this working with the add on. I’ve installed the add on with no other add ons and got the below error.

[tcp @ 0x74f2eb40] Connection to tcp://192.168.x.x:19443 failed: Operation timed out
https://192.168.x.x:19443/https/stream/mixed?video=h264&audio=g711&resolution=hd: Operation timed out

My config is below with user/pass/ip retracted. I’ve checked the user/pass is correct to a point where I’ve changed the password just to be sure. I’ve restarted the add on service with any change as well as well as HA.

kasausername:username
kasapassword: password
cameraip: 192.168.x.x
cameraname: kasacam
retrylimit: 5
retrysleep: 30

It is almost as if there is an issue authenticating but know for sure that the creds are correct. I even tried the manual method using the curl command (see below) with my creds base64 encoded which worked perfectly. Even tried the addon using the encoded credentials and still no luck.

url -vv -k -u username:password== --ignore-content-length “https://192.168.68.x.x:19443/https/stream/mixed?video=h264&audio=g711&resolution=hd” --output - | ffmpeg -y -i - test.mp4

You need to base64 encode your password twice. Curl will base64 encode it once, so you just need to provide it encoded again.

curl -u [email protected]:$(echo -n password | base64)  -k "https://ec70.lan:19443/https/stream/mixed?video=h264&audio=g711&resolution=hd" --ignore-content-length --output -

see this blog post.

Has anyone figured out how to remove the Kasa logo from the footage?

Hi, I have just tested from a CentOS7 terminal inside my network, and the below cURL command works perfectly:

curl -vv -k -u user:base64encodedpassword --ignore-content-length "https://192.168.x.x:19443/https/stream/mixed?video=h264&audio=g711&resolution=hd&deviceId=CAFEDEADBEAFCAFEDEADBEAFCAFEDEADBEAFCAFE" --output - | ffmpeg -y -i - test.mp4

It generates the mp4 test file. The question comes then - what and how to integrate this into HA? I have 4 KC100 cameras.
Is there a way to disable/enable privacy (as from the Kasa app?) as if the camera is in Privacy Mode, the cURL does not work (obviously), so a trigger to “wake” the camera needs to be first, then the curl to extract the stream, then another trigger to “sleep” the camera (when you are at home for ex).
Also, how to put this into HA?
Any ideas?

Has anyone got this working on Home Assistant OS ? Currently running Home Assistant 2021.2.3 and have installed and configured Kasa Camera 1.4 without issue. Though I can’t access the camera image via the url;

I am able to do the previous posters curl command so know my HASS install can reach the cameras, but I can’t invoke the ffmpeg on the docker image to write the test.mp4 file, could this be the root of my issue ?

Solved my issue, the camera name is the URL is case sensitive, correcting this typo enable the camera image to be visable.

I am new to HA to this might be documented elsewhere but…
I have HA Core running Docker so I don’t have Supervisor.
My research pointed me at something which just said to run the addon as a container, I can see a Dockerfile for kasa-camera. Addon-Node-Red is just another plugin I can ignore right?

As for config it looks like this is being read from /data/options.json?
So that variables just need converting to json and storing in that location?

I see a few references to Supervisor in the code. Will this even run in Core ?

Mate, you’re a legend! Up and running here fine, the Pi struggles a little though under the additional load.

I thought I might have been able to take your work and that from the medium article to try and get motioneye to talk directly to the stream from the camera, however motion doesn’t look like it will use a https stream :frowning:

The main reason I wanted to do this was to avoid the additional overhead running the addon on the Home Assistant Raspberry Pi. Would it be possible to run this outside of HA? I have a separate Ubuntu linux box I use to run MotionEye on that would handle the load a little better.

Regards
James

Hey everyone. I’ve got an update releasing right now that will be adding multi-camera support. Just wanted to let people know that I’ve only tested this a bit but it did work with two KC105 cameras on my network. I should add that at this point all of the Kasa cameras will need to be under the same Kasa account. Anyways keep an eye out for version 1.6 of the Kasa Camera add-on.

3 Likes

Hey @weyrling - unfortunately this add-on will probably only work within the context of home assistant, since the docker image “integrates” with Home Assistant Supervisor. It may be possible but off the top of my head I’m not exactly sure how that’d work :slightly_frowning_face:. Definitely would love to know if you figure it out though.

Thanks @joshgetter I was previously running four instances of this, now all up and running with four cameras on one instance. Much appreciated.

1 Like

Thanks @joshgetter, after a bit of fiddling, I managed to create a fork of your amd64-addon-kasa-camera container that works outside of Home Assistant, its not pretty (my first go at this stuff) but it seems to work. Anyone interested can find it here:

https://hub.docker.com/repository/docker/gryphy/amd64-kasa-camera

P.S. this is based on the single camera version of the container. I only have the one KC100 so have no need for the multi camera.
P.P.S. For those that were not aware, TPLINK have been selling what looks to be a re-badged updated version of this camera as the TAPO C-100 which has RTSP streaming built into it. Here in AU theyre retailing at JB-HIFI for $57 although I managed to pick a couple up for $49 each

1 Like

Hi Everyone,

Thanks @joshgetter for all your hard work! I had an issue today where the addon keeps reporting:

[https @ 0x7f79f16b9ec0] HTTP error 503 Service Unavailable

I tried running the curl piping the output to a file locally, but no joy. Is there a chance that TP-Link have patched the firmware? I have a V2.0 KC100 running Firmware version 2.3.6 - that works fine in the app.

Hi everyone. This is just what I was looking for. I have a KC100 and was thinking about getting a couple more if I can get this nicely integrated with HA.

I have it all set up per the docs, but I can only see the thumbnails (which are great!)… how do I achieve the stream? When I click on the thumbnail, I get a window that pops up, with a spinning circle only and no video no matter how long I wait.

I’m clueless as to what I’m doing wrong!

Thanks.

EDIT: I unplugged and relocated the camera and the stream is working now. No idea what that was all about!! Thanks for the great add-on @joshgetter this is fantastic!