I have created a way to use TP-Link Kasa lights for motion detection lighting through Blue Iris

JDfromDB

Getting the hang of it
Joined
Dec 20, 2019
Messages
41
Reaction score
34
Location
CA
I wanted to trigger some of my Kasa lights from Blue Iris when my cameras detect motion. There is no public API available but there are a few web pages that list enough of the protocol for what I need. I used this info to create an exe that that will turn on a light for n seconds and then turn it off, if the light is already on, then it will do nothing.

To use this from Blue Iris you need to go to the camera settings and in the Alert tab add an action to call the exe when triggered.

The exe is named KasaMotionLight and it targets the .Net framework 4.8 so that is the only requirement.

The command line is as follows: KasaMotionLight id:<your login id> pw:<your password> s:<number of seconds to leave the light on> dev:<light name in the Kasa app>
Example: KasaMotionLight id:userid pw:secret s:60 dev:driveway_light

I only have a few of the various Kasa devices so it is possible that it will not work for some of them. It is also possible that Kasa will change the API at some point to break this but for now it works.

If anyone finds this useful, let me know how it works for you.
 

Attachments

dannyhearn

n3wb
Joined
Jul 15, 2022
Messages
1
Reaction score
0
Location
08202
I wanted to trigger some of my Kasa lights from Blue Iris when my cameras detect motion. There is no public API available but there are a few web pages that list enough of the protocol for what I need. I used this info to create an exe that that will turn on a light for n seconds and then turn it off, if the light is already on, then it will do nothing.

To use this from Blue Iris you need to go to the camera settings and in the Alert tab add an action to call the exe when triggered.

The exe is named KasaMotionLight and it targets the .Net framework 4.8 so that is the only requirement.

The command line is as follows: KasaMotionLight id:<your login id> pw:<your password> s:<number of seconds to leave the light on> dev:<light name in the Kasa app>
Example: KasaMotionLight id:userid pw:secret s:60 dev:driveway_light

I only have a few of the various Kasa devices so it is possible that it will not work for some of them. It is also possible that Kasa will change the API at some point to break this but for now it works.

If anyone finds this useful, let me know how it works for you.
Hi JD,
Thanks for the original post. Interested in controlling a TP link device via my Blue Iris system / camera motion. I'm not as technical as some. To use this I see how to set the .exe in the action for an alert in the BI camera settings. Would the command line be entered into the Parameters box? Also, my BI machine is running MS .net runtime 5.0.17 (x64). Does that cover the requirement mentioned?
Thanks a lot.
Dan
 

JDfromDB

Getting the hang of it
Joined
Dec 20, 2019
Messages
41
Reaction score
34
Location
CA
Hi JD,
Thanks for the original post. Interested in controlling a TP link device via my Blue Iris system / camera motion. I'm not as technical as some. To use this I see how to set the .exe in the action for an alert in the BI camera settings. Would the command line be entered into the Parameters box? Also, my BI machine is running MS .net runtime 5.0.17 (x64). Does that cover the requirement mentioned?
Thanks a lot.
Dan
As long as you keep your PC updated, then you should have the .net requirements.
For the parameters, I use a batch file and put the name of the exe and the parameters in there and then call the batch file from the alert.
 

rdxny

Getting the hang of it
Joined
Oct 15, 2022
Messages
139
Reaction score
81
Location
ny
If anyone finds this useful, let me know how it works for you.
works great... I use it to trigger a light in the house at night to let me know it's time to run the deer off before they eat every darn plant in the garden! Thanks!
 

DavidW

Getting the hang of it
Joined
Apr 5, 2020
Messages
49
Reaction score
78
Location
Florida
Also, my BI machine is running MS .net runtime 5.0.17 (x64). Does that cover the requirement mentioned?
Thanks a lot.
Dan
Microsoft says new .net verisons are supposed to support older versions unlike before. So if you have a later version, which you do, you shouldn't need to install a previous one.

Would I be able to trigger this to only work between specified times? Like 3am - 6am?
 

looney2ns

IPCT Contributor
Joined
Sep 25, 2016
Messages
15,521
Reaction score
22,657
Location
Evansville, In. USA
Microsoft says new .net verisons are supposed to support older versions unlike before. So if you have a later version, which you do, you shouldn't need to install a previous one.

Would I be able to trigger this to only work between specified times? Like 3am - 6am?
Yes, set up a profile in BI that only includes this function during that time.
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,441
Reaction score
38,158
Location
Alabama
FWIW, the Shelly Wi-Fi smart switches, AC outlets and LED bulbs have a published API, including MQTT, that Blue Iris via HTTP can turn on/off via curl or that can receive input from them. For input to BI I have used them to trigger a cam, change profile and move to a preset; and for output from BI I have turned on lights and sounded an alarm.

More here ==>> Simple Blue Iris I/O using Shelly1 Wi-Fi Devices *
And here from @jaydeel ==>> Mailbox monitor using Shelly Wifi Motion sensor & Blue Iris
and lastly here ==>> Wireless siren to Hikvision NVR ?

* NOTE: See attached PDF.
 

Attachments

Last edited:

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,441
Reaction score
38,158
Location
Alabama
This has been working great up to now, but stopped. Any ideas? Yours still ok?
By any chance did you create an account with TP-LINK/Kasa/Tapo, get on your local Wi-Fi, install their app on your smartphone and have the app "add device"?
 

rdxny

Getting the hang of it
Joined
Oct 15, 2022
Messages
139
Reaction score
81
Location
ny
By any chance did you create an account with TP-LINK/Kasa/Tapo, get on your local Wi-Fi, install their app on your smartphone and have the app "add device"?
I was wrong, it is still working fine. (I had disabled the profile for that alert in BI during the daytime and forgot.... so it appeared to be not working. It is fine, user error!)
 

rdxny

Getting the hang of it
Joined
Oct 15, 2022
Messages
139
Reaction score
81
Location
ny
sorry, yes. I have the Kasa switch attached to lamps. works with Alexa well. Account on the Kasa app on phone, device added, on local wifi... and I created a .bat file with the KasaMotionLight as in the OP post which Blue Iris points to in the alerts tab. Works great (as long as I remember not to disable the profile first!)
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,441
Reaction score
38,158
Location
Alabama
sorry, yes. I have the Kasa switch attached to lamps. works with Alexa well. Account on the Kasa app on phone, device added, on local wifi... and I created a .bat file with the KasaMotionLight as in the OP post which Blue Iris points to in the alerts tab. Works great (as long as I remember not to disable the profile first!)
So what happens to the Kasa's switch function if your Internet (not your LAN) is down?
 

rdxny

Getting the hang of it
Joined
Oct 15, 2022
Messages
139
Reaction score
81
Location
ny
So what happens to the Kasa's switch function if your Internet (not your LAN) is down?
I guess Alexa wouldn't work, but BI functions should work as long as wifi / router/ LAN functioned? But that rarely happens and its not a crucial need, more convenience (I can always turn light on/off manually) and alerts for deer so I can chase them away! It's not a part of my home security system.
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,441
Reaction score
38,158
Location
Alabama
I guess Alexa wouldn't work, but BI functions should work as long as wifi / router/ LAN functioned? But that rarely happens and its not a crucial need, more convenience (I can always turn light on/off manually) and alerts for deer so I can chase them away! It's not a part of my home security system.
No, I understand that it's not a crucial need but I ask in order to determine if the switch's function is cloud-based and could explain why you asked previously in another post (which has since been deleted) "This has been working great up to now, but stopped. Any ideas? Yours still ok? "

In other words, if it IS cloud-based and either their server hiccupped OR your Internet was down, the switch would not work. Would you like to know the answer to that question?

If so, momentarily disconnect your Internet from the LAN, not your BI server, and see if the switch still works.
 

rdxny

Getting the hang of it
Joined
Oct 15, 2022
Messages
139
Reaction score
81
Location
ny
No, I understand that it's not a crucial need but I ask in order to determine if the switch's function is cloud-based and could explain why you asked previously in another post (which has since been deleted) "This has been working great up to now, but stopped. Any ideas? Yours still ok? "

In other words, if it IS cloud-based and either their server hiccupped OR your Internet was down, the switch would not work. Would you like to know the answer to that question?

If so, momentarily disconnect your Internet from the LAN, not your BI server, and see if the switch still works.
I had deleted the post because it wasn't correct.. I had asked why the KasaMotionLight.exe app that allowed the alert in BI to get to the Kasa switch app on my phone no longer worked, but it did... it was user error in that I had set a daytime profile to OFF for that alert and forgot.
Back to your question, though, I tested it and the Kasa switch app on the phone works just fine with the internet disabled but LAN and Wifi still on. It doesn't need cloud access. What didn't work was the above alert connection (the KasaMotionLight.exe and BAT file alert through BI. That seems to need internet, though I can't seem to figure out why. Maybe the microsoft .net framework needs the net... that would make some sense!
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,441
Reaction score
38,158
Location
Alabama
That seems to need internet, though I can't seem to figure out why.
if you created an account with TP-LINK/Kasa/Tapo, got on your local Wi-Fi, installed their app on your smartphone and had the app "add device", then you're most likely using their cloud; so, if no Internet, no switch.
 

rdxny

Getting the hang of it
Joined
Oct 15, 2022
Messages
139
Reaction score
81
Location
ny
if you created an account with TP-LINK/Kasa/Tapo, got on your local Wi-Fi, installed their app on your smartphone and had the app "add device", then you're most likely using their cloud; so, if no Internet, no switch.
Not really. If I turn off internet and leave wifi and router working, and tell the app on my phone to turn light off or on, it does. The phone is still on wifi (with a no internet warning), the Kasa device has no internet now, and the app still controls the light over the available wifi (with no net).
 

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
24,430
Reaction score
47,552
Location
USA
In my experience it will eventually wonk out without internet. From the research I did:

Your Kasa smart plug will still be able to use existing timer and schedule settings when the internet goes down. However, if the smart plug loses power it will forget those timers and schedule settings until the internet is back up. Zigbee and Z-Wave smart plugs are a little bit more resilient to internet outages than Wi-Fi smart plugs.



Q12: Will the Timer and Schedule function still take effect if internet is down?

A: Yes, those functions will take effect even if the Smart Home device loses its internet connection.

But during the time of losing the internet, please don't power off the Smart Home device, or the schedule will not take effect.

.
 
Top