Isaksson / node-red-contrib-unifi

MIT License
52 stars 20 forks source link

Example for a Special Command #13

Closed fendle closed 5 years ago

fendle commented 5 years ago

Hi Kristoffer,

could you maybe give me an example how to use the Special Commands?

I need for example a workflow, when I tigger a command through Alexa, some wifi clients shall be blocked after a specific period. Means I need to be able to block some wifi clients.

Thanks, Jacek

Isaksson commented 5 years ago

Hello. Sure, here is a simple example that is discussed in another issue.

Disable a WLan:

Add a function node and the below code to trigger the command disableWLan.

msg.payload = {command:"disableWLan",wlan_id:"5a5a6860e4b073cbb84a0a45",disable:true}; return msg;

That is how you could call the Special Commands. Do you need more help with your specific request or is this common instruction good enough?

fendle commented 5 years ago

Thanks a lot. that means I did it correct, but it's not working for me: Here my function code = msg.payload = { command: "blockClient", mac: "68:9a:87:1d:7c:49" }; return msg;

When I execute it, the client is still available and not blocked.

Isaksson commented 5 years ago

I just made a test myself to block a client, I used your code and changed only the mac, and it worked as it should. Do you get a response from the node that the client is blocked? I include my response so that you will see how it looks when it work. unifiBlocked

fendle commented 5 years ago

I checked it as well now, and it not blocked:

Maybe I have something wrong with my workflow? image

Isaksson commented 5 years ago

What is your output from the debug node? Why do you use two Unifi nodes in the example?

fendle commented 5 years ago

Here the output of the unifi node: { "site_id": "5a9474ade4b07c8e098285c6", "assoc_time": 1557605391, "latest_assoc_time": 1557739493, "oui": "", "user_id": "5bf01ba983106104482200f5", "_id": "5bf01ba983106104482200f5", "mac": "68:9a:87:1d:7c:49", ... "noted": true, "blocked": false,

Here of my function: image

I used the second node temporarily to get the output of all clients.

Isaksson commented 5 years ago

Is this a client connected with cable or WiFi? is_wired =

fendle commented 5 years ago

It is connected by Wifi "is_wired": false,

Within the unifi Controller it's working.

Isaksson commented 5 years ago

What version of the Unifi controller?