KUMO app to control KASA (TP-LINK) switches seems to work ok...

119 views
Skip to first unread message

Rod Laird

unread,
Nov 15, 2017, 4:28:34 AM11/15/17
to Wireless Sensor Tags

Dear Kumo colleagues,

Attached is a script that runs for me on KUMO and controls a KASA switch.

I use it to control a roof ventilation system, which is probably not going to be of interest to anyone but me.

I suspect, however, that the code for setting up and using a TP-LINK KASA switch may interest a number of you.

The KASA management needs (and the code requests) your:
  1. Kasa login credentials
  2. The alias for the target switch

The code provides for:

  1. Acquiring a token to authorise HTTP POST calls
  2. Acquiring the device ID to control the target switch
  3. Regularly fetching a fresh token to maintain continuity of access (they expire)
  4. Switch control
Hope some of you find it useful!


cheers


Rod Laird


Kasa vent controller with token update.txt

steve

unread,
Nov 15, 2017, 11:37:53 AM11/15/17
to Wireless Sensor Tags
Thanks Rod for sharing

Rod Laird

unread,
Nov 22, 2017, 7:34:53 AM11/22/17
to Wireless Sensor Tags
An update with
  • slicker code for error handling (recognises when switches offline or incorrect credentials)
  • fixed coding errors for some of the use-specific algorithms (in particular picked up failure to clone the temperature history array before sorting it...)

The first item will be of general interest (to the extent you were / are interested in linking to the Kasa API in the first place)


cheers


Rod

Kasa vent controller v2.txt

steve

unread,
Nov 29, 2017, 1:58:06 AM11/29/17
to Wireless Sensor Tags
Hi Rod,

I'm hoping you could help me as I'm rubbish at programming. I have written this kumo app that works really well.

var tag_to_beep = <#tag to beep_[12|13|21]_1#>;
<#door_[12|13|52|21]_N#>.forEach(function(t){
t.opened = function(){ tag_to_beep.beep(5); }
});

when any of my selected tag open(N#) it beeps 1 tag 5 times. I have tried to change the code to be able to select more than one tag to beep but i keep getting a syntax error when trying to add #N to the beep option can you help?

Many thanks
Steve

Seven Twenty

unread,
Jan 5, 2021, 8:03:11 PM1/5/21
to Wireless Sensor Tags
I know this is old, Rod, this has been MOST useful. Thanks!  I've refactored it to use in my environment where I needed to grab ALL DeviceID's and Statuses and then create and control scenes. I've not found any way to tap into the Scenes from the KASA app but can easily code that up in JS. What you supplied here was the key I needed to get my code grabbing the values needed from KASA. 

D

Reply all
Reply to author
Forward
0 new messages