Isaksson / node-red-contrib-unifi

MIT License
52 stars 20 forks source link

Cmd request: locate/unlocate #37

Closed mariusbach closed 4 years ago

mariusbach commented 4 years ago

EDIT: I created a pull request to include the functions. But please check if that actually works, I looked at how other functions were written and derived the new ones from those.

Dear Kristoffer,

thanks a lot for the work on this unifi node!

I've got a question: Would you be able to implement the set-locate/unset-locate device command?

My UDMpro is next to my raspberryPi with a little display in my corridor, and there is also a motion detector for the corridor light. Whenever I go to the corridor, based on the motion detection, my raspberry turns on the display (simple LCD which degrades a lot if left active 24/7, so I just activate it automatically when I pass by).

The UDMpro switches on its display either upon touching it, or as I found out when you hit "locate device" in the unifi app. It then displays an animated unifi logo and once you unset locate, the display stays active for 10-20s showing the actual data and then turns off. My idea would be to use the motion detection to set locate immediately followed by un-set, so it turns on automatically.

Per the API wiki (quoted below) the following is necessary (the same as you have done for the other commands already):

Posting to the endpoint api/s/{site}/cmd/<manager> with the json {"cmd": "command"} you can invoke commands on the controller.

devmgr | set-locate | mac = device mac ( required ) blink unit to locate devmgr | unset-locate | mac = device mac ( required ) led to normal state

I'm not yet too familiar with node programming and your code, otherwise I'd have tried to add it myself. It seems to be fairly easy mimicking the commands which you implemented already, hence my request.

All the Best Marius

Isaksson commented 4 years ago

Hello. Thanks for the PRs. I will modify some of the code but I will use your code as a base, I will try to make this changes today.

Isaksson commented 4 years ago

In the Unifi helper there is already a function for this, its called setLocateAccessPoint So I will use that function and just make it available to use

Isaksson commented 4 years ago

Version 0.1.14 is pushed to NPM and it contains this new function

mariusbach commented 4 years ago

Thanks so much! It works!

Indeed I didn’t notice the helper already had this function implemented.

All the Best Marius

Am 11.06.2020 um 09:43 schrieb Kristoffer Isaksson notifications@github.com:

Version 0.1.14 is pushed to NPM and it contains this new function

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Isaksson/node-red-contrib-unifi/issues/37#issuecomment-642472689, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOBICPI6V6GDWZ6FDGM2KCTRWCDJ3ANCNFSM4N24G55A.