Thank you very much. The inject node is the part I was having trouble with. I didn’t understand what the input to Kasa should be. Your notes have cleared things up immensely. Thank you for taking the time to post such detail.
Regards
Thank you very much. The inject node is the part I was having trouble with. I didn’t understand what the input to Kasa should be. Your notes have cleared things up immensely. Thank you for taking the time to post such detail.
Regards
great work! I’ll save this for when I move off of a Raspberry Pi
I’ve moved to aN RPi 4 with 8gb and an SSD. Works very well. Speed on the SSD far surpasses that of the SDCard. If you have an RPi 4 it would be worth looking into updating to an SSD.
Good to know… I’ll give NodeRed a try.
I thought the short polling time ( <= 2 seconds) would be a problem. I glad to hear that it is not an issue
My system (RPiv4, 4GB mem, 16GB SD card) is stable at Core: 0.117.5, HassOS: 4.15, Supervisor: 202011.0
CPU Utilization < 2%
Full Snapshot and SDcard image saved for some future disaster recovery.
Obviously, now is the time to start tinkering with Node-Red. Installation from HACS complete.
I’ll move onto configuration when I get some free time
I thought the next step would be to install the TP-Link Contrib but I do not see the “npm” command. Is there an alternate install process?
Run the following command in the root directory of your Node-RED install
$ npm install node-red-contrib-tplink
Look under Pallete in the menu. There you’ll find the nodes that are installed and be able to search for nodes to install.
Robert
I’ve nearly got it working, but nearly is not close enough.
My connection to the HA server FAILS.
“Call-Service attempted without connection to server.”
Call Service Node:
Server Node Entry:
Flow with Debug info:
I’ve tried both http & https
I created a 2nd Long Lived Access token and re-entered the copy/save/paste into the NodeRed Server Node entry, still no joy.
Do Long Lived Access tokens update with “last used” info?
Your help has been invaluable. Please let me know if you can identify my error.
Thanks!
[EDIT 2 hours later]
Never mind… it now works:
I changed the Sever Node Entry to “I use the Home Assistant Add-on”
I also deleted my Long Lived Access Token… apparently it is not required with the “Home Assistant Add-on”.
I wouldn’t have got it working without your hints along the way. Very much appreciated!
[Edit 12 hours later]
It turns out that “toggle” is not the function I want to use. I want:
…but that is for another day…
[Edit 23 hours later]
On means ON and Off means OFF (not toggle or flip/flop)
…unfortunately this does quite work…
I replaced the Home Assistant “current state” node with a Function “switch” node:
This now works as expected. The “trick” (also known as reading the documentation) was to ensure that the state variable was properly identified in switch node: “payload.state”
For some reason my inject is different than the original example. Posting mine in case someone else is the same as mine. It took a few minutes for me to figure it out!
How do you get the startPowerEvents to start up without clicking on the inject when you restart HA? Mine seems to stop working and then when I go click the inject it starts processing.
"Processing input for device 192.168.0.24: {"_msgid":"52e29724.319fa8","topic":"","payload":"startPowerEvents"}"
I see the same data on “Edit inject node”. It does work for me without any special action.
Perhaps you can try changing the “Inject once after” value from 0.1 to 1.0 seconds to allow the system to complete its initialization processes before sending the inject message.
(this is a pure guess on my part)
Ok everything is working now. I was being thrown off by using the get current state of the switch and then passing the on or off state through.
Then it was a matter of adding .state to the payload to read the right value. It’s been awhile since I have dabbled in past basic flows in NodeRed. Thank you for the illustration @YetAnotherDave
I had a related issue with my TP Link HS210 3 way switches. These switches seem to be the only decent 3 ways switches that will work with the wiring in my house since they will sense the current flow to the lights if the other 3 way switch is toggled (and I only have a neutral wire at one of the switches).
There is a slight delay when sensing the current to the light, so turning the light on from HA causes HA to show ON, then (I assume) read back and determine the light was OFF, then a little while later decide the light was actually ON. It could take 30 sec + for this indecision to stabilize.
The node red solution described above worked perfectly from both switches and HA. They show the state almost instantly and don’t flicker ON-OFF-ON like they used to. Thanks for the detailed posts.
Unfortunately, I experience the same delay. I have been using about 20x HS110 for more than one year and they all worked fine. However, a while ago they all started to show this delay behavior. Maybe the entire problem has something to do with a firmware update because the delay did definitely not appear, e.g., two months ago.
I have implemented the suggested fix in Node-RED and it seems to work fine. It is a nice workaround for a couple of plugs, but IMHO it is not a good solution if someone owns more plugs.
Hey everyone, I think this is a bug.
There’s no way that it’s reasonable for the integration to have a 30 second delay nor should we need to use node red hacks or home assistant update calls every 3 seconds to get the status of the switch. Other polling integrations don’t have this long of a delay (Hue for instance).
Looking at the docs I think the developer of this integration may have left the polling period set at the default (30 seconds) so I’m hoping this is an easy fix (change the period to a smaller value).
I’ve opened a bug if anyone wants to add addition feedback or anything I might have missed (I am new to this integration having just bought the switch on Black Friday):
Just for any one that views this I went the node red route mine for some reason was not quite as straight forward as above because I wanted separate on/off not just toggle. this is the flow I added to the mix.
[{"id":"8f1b41b9.23b37","type":"switch","z":"384fca3a.995fd6","g":"25465464.d2c08c","name":"On/Off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":120,"wires":[[],[]]}]
Has anybody experienced issues with the Kasa node causing node-red to crash?
Whenever I deploy the node with my devices IP, I get a NGIX 502 Bad Gateway popup and then the add-on UI goes completely black. If I go into the config file and remove the Kasa node, everything goes back to normal working condition.
No Kasa/NodeRed issues here.
System Health
version: core-2021.12.10
installation_type: Home Assistant OS
dev: false
hassio: true
docker: true
user: root
virtualenv: false
python_version: 3.9.7
os_name: Linux
os_version: 5.10.63-v7l
arch: armv7l
host_os: Home Assistant OS 7.2
update_channel: stable
supervisor_version: supervisor-2021.12.2
docker_version: 20.10.9
healthy: true
supported: true
board: rpi4
supervisor_api: ok
version_api: ok
installed_addons: File editor (5.3.3), Samba share (9.5.1), SSH & Web Terminal (10.0.2), Duck DNS (1.14.0), Node-RED (10.3.4), Check Home Assistant configuration (3.9.0)
Thank you for the reply. Would you mind posting your inject and Kasa node settings? Maybe I have a node setting throwing an error.
You can change the poll timing for the Kasa switches in
homeassistant/components/tplink/coordinator.py
change the line:
update_interval = timedelta(seconds=10)
to:
update_interval = timedelta(seconds=1)
It changes the polling interval to one second (similar to the node red interval above) and the delay for hass to notice the state change will be minimal. You can either modify the installation or copy the tplink component code into your custom_components directory to override.
I have more than a dozen Kasa smart switches/plugs and this works with no issues. I had been worried that this would flood my network or cause issues with Hass but this change seems to work with minimal (if any) impact.
My dude, many thanks for this, it worked like a charm!!
Also, many thanks to @YetAnotherDave for starting the thread.
Just one note regarding the folder access for whomever is trying this: