plasticrake / homebridge-tplink-smarthome

TP-Link Smarthome Plugin for Homebridge
MIT License
467 stars 70 forks source link

Move HS-300 to surge protector outlet icon #303

Open roberkane212 opened 1 year ago

roberkane212 commented 1 year ago

Current Situation

Currently all plugs show separately as individual outlets not all as one

Proposed Change

That it will show as it is a power strip instead of individual outlets

roberkane212 commented 1 year ago

I currently have homebridge-tuya installed and have no issue with that plugin showing it IMG_1660

ZeliardM commented 4 months ago

@plasticrake I am looking to get some of the Kasa HS-300 power strips, but I would like for this functionality. I don't know much in the way of coding, but I did find the following information out about this: It seems that Tuya adds multiple outlet services to the same accessory. I am not sure how to do this but would be willing to test anything that comes up.

https://github.com/iRayanKhan/homebridge-tuya/blob/main/lib/MultiOutletAccessory.js https://github.com/iRayanKhan/homebridge-tuya/wiki/Supported-Device-Types#smart-power-strips

roberkane212 commented 4 months ago

@plasticrake what can I do to help?

ZeliardM commented 4 months ago

I was able to create this with the homebridge-meross plugin, I will take a stab at this one and see if I can create a PR.

roberkane212 commented 4 months ago

@ZeliardM let me know if I can help in anyway

ZeliardM commented 4 months ago

I’m going to have to see, I just ordered an HS300 and will see what happens when I get it. Will start working on the code now.

ZeliardM commented 3 months ago

I was able to get the basic premise done for this. Had to make api calls in the plugin because the built api doesn't support passing the childId as an argument, but right now I have basic functionality up and working, just need to clean it up and fix some of the status updates in HomeKit. Once I'm finished, I'll push a PR to let them merge it if they're good with it and maybe can get them to update the API to support passing the childId and that may clean it up even more.

roberkane212 commented 3 months ago

@ZeliardM thats awesome. Again let me know if there’s anything I can do

ZeliardM commented 3 months ago

The code has been cleaned up and the PR has been submitted. We will see what the dev says and go from there. Until then, I'm going to keep running my local copy, lol

roberkane212 commented 3 months ago

@ZeliardM awesome, hopefully he responds to this asap

roberkane212 commented 3 months ago

@ZeliardM I wish I knew more coding. I’d get run a local copy myself lol

roberkane212 commented 3 months ago

@ZeliardM i see you have a forked version of the plugin. Is there anyway for me to install it by chance?

ZeliardM commented 3 months ago

I would not as the dev hasn't tested everything and I may have made mistakes. I cannot support it like they did.

roberkane212 commented 3 months ago

@ZeliardM I have against you saying so installed your fork, however when I changed plug to power strip. It says it’s not supported. I know you can not support your version that’s much. But the power strip this the only item I use with this plugin and would really appreciate your help. If it doesn’t work as well. I will go back to original version

ZeliardM commented 3 months ago

What did you change from plug to power strip? The process for my change is to check a box under the HomeKit (Optional) configuration to enable creating a power strip. Leave all the rest of your stuff alone and put it back to plug. That is a reference to his api that I did not change.

roberkane212 commented 3 months ago

@ZeliardM ok I must have not install yours right. Because I don’t have the option.

roberkane212 commented 3 months ago

@ZeliardM did you have to remove the original plugin, to make your changes?

ZeliardM commented 3 months ago

No, just need to run the following command from the terminal in the homebridge web console: npm install ZeliardM/homebridge-tplink-smarthome

Again, I'm not responsible for anything that happens when and if you choose to do this nor will I support any problems you have.

I have told you I don't support this as it is the plugin creators invention and I'm trying to help out but I'm not taking over.

roberkane212 commented 3 months ago

@ZeliardM Yes thank you I appreciate it, and again if there is an issue I will go back to original. How I have ran what you told me in terminal and still don’t have the option. Thank you again for your help. I know your don’t plan to support

ZeliardM commented 3 months ago

Did you restart Homebridge or child bridge after you ran the command?

roberkane212 commented 3 months ago

@ZeliardM yes but when I ran the command I got a few error messages back. So I’m guessing it did not install

ZeliardM commented 3 months ago

Most likely, what were the error messages?

roberkane212 commented 3 months ago

@ZeliardM npm ERR! code 127 npm ERR! git dep preparation failed npm ERR! command /opt/homebridge/bin/node /opt/homebridge/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/home/pi/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run npm ERR! > homebridge-tplink-smarthome@8.0.3 prepare npm ERR! > npm run build npm ERR! npm ERR! npm ERR! > homebridge-tplink-smarthome@8.0.3 prebuild npm ERR! > npm run clean npm ERR! npm ERR! npm ERR! > homebridge-tplink-smarthome@8.0.3 clean npm ERR! > rimraf lib/ build/ npm ERR! sh: 1: rimraf: not found npm ERR! npm ERR! code 127 npm ERR! npm ERR! path /home/pi/.npm/_cacache/tmp/git-cloneUsurQf npm ERR! npm ERR! command failed npm ERR! npm ERR! command sh -c npm run build npm ERR! npm ERR! npm ERR! A complete log of this run can be found in: /home/pi/.npm/_logs/2024-03-20T16_47_49_792Z-debug-0.log

npm ERR! A complete log of this run can be found in: /home/pi/.npm/_logs/2024-03-20T16_47_37_291Z-debug-0.log

ZeliardM commented 3 months ago

Ah, I remember. Had to run npm install -g rimraf first. Something in the deployment missing for manually installing.

roberkane212 commented 3 months ago

@ZeliardM ok so run npm install-g rimraf. Then run your npm install ZeliardM/homebridge-tplink-smarthome. Right?

ZeliardM commented 3 months ago

Yes

ZeliardM commented 3 months ago

@roberkane212 any luck?

roberkane212 commented 3 months ago

@ZeliardM yes it worked thank you!!!!!

roberkane212 commented 3 months ago

@ZeliardM had to use tcp communication to get it to work though

ZeliardM commented 3 months ago

Ok, udp worked for me, so it could be a difference in models or something else. But glad to help.

roberkane212 commented 3 months ago

@ZeliardM it is working wonderful for me right now. Thank you so so much!!! I appreciate all your help and work. I will not be asking for anymore advise as I’m sure you have plugins you actually are apart of. However I very much appreciate you helping me to get that power strip working. I will let you know if I get upd to work, but that’s it. A million thanks, I’ve wanted this for over a year now!!

ZeliardM commented 3 months ago

Glad I could help and I can help where I can but specifics would have to wait on the plugin creator. Not sure if udp is required, I use it because of a bunch of errors that come up when it's tcp. I don't use any other custom entries in the plugin or settings, I just leave it all as default, if that helps.

roberkane212 commented 3 months ago

@ZeliardM i still get error logs, but it works. I don’t know how to get the error logs to go away

ZeliardM commented 3 months ago

I got them to go away by switching the transport in the settings to udp. But you said you had to change it to tcp.

roberkane212 commented 3 months ago

@ZeliardM I do have one more question for you if you can answer it if not I understand. do you know why I might be gettin this error now?

[TP-LINK_Power Strip_8A5D] device.send() Error: UDP Timeout after 15000ms 10.0.0.25:9999 {"system":{"get_sysinfo":{}}} at Timeout._onTimeout (/var/lib/homebridge/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/udp-socket.ts:64:15) at listOnTimeout (node:internal/timers:573:17) at processTimers (node:internal/timers:514:7) Error: UDP Timeout after 15000ms 10.0.0.25:9999 {"system":{"get_sysinfo":{}}} at Timeout._onTimeout (/var/lib/homebridge/node_modules/homebridge-tplink-smarthome/node_modules/tplink-smarthome-api/src/network/udp-socket.ts:64:15) at listOnTimeout (node:internal/timers:573:17) at processTimers (node:internal/timers:514:7)

ZeliardM commented 3 months ago

Is the transport udp or tcp? I think that's related to that.

roberkane212 commented 3 months ago

@ZeliardM UDP, however it does it on both. and didn't do it before. So I thought maybe there was something I was missing. like when I needed to install rimraf

ZeliardM commented 3 months ago

Hmm, I haven't seen it on my end so I'm not sure.

roberkane212 commented 3 months ago

@ZeliardM Ok no problem, I just figured I'd ask. I appreciate you taking the time