Announcement

Collapse
No announcement yet.

Notify HS4 of WiFi device appearance

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ksum
    replied
    I have not been able to get the UnifiEvents contrib to work with my Dream Machine Pro (UDMP) but I did see that there is a newer contrib called node-red-contrib-unifi-os which I was able to get to work and get events sent to Node-RED. It sends a LOT of events with various information. Interestingly the same happens when you are viewing the device's web pages. You can see them all through the Developer Tools in the web browser. I could use that contrib and filter through but finding the correct message, but . Ideally I would find an Endpoint I could use to only return the needed events.

    Below is the CPU and Memory load on my UDMP. I have seen the CPU usage stay above 45% while using my polling method (every 2 seconds) at times, but it never reached 50%. The chart below has my flow in the earlier post running as well as a test flow which just gets the websocket data.

    As for the delay in devices going "off line" when going out of range, maybe the latest_assoc_time or one of the last_seen/last_seen_by... variables could be helpful? No idea and I am far from an expert on the data available from the Unifi API.

    Thedude Why not just use Node-RED to change a HomeSeer device directly?
    Click image for larger version

Name:	HS1.png
Views:	160
Size:	41.0 KB
ID:	1518652

    Leave a comment:


  • Thedude
    replied
    stefxx You did a great job with your plug-in and will consider it if I'm to get serious about tracking of multiple devices. My current task at hand is quite small tracking the arrival of one car and my Node-Red implementation is good enough.

    ksum There is another node called "UnifiEvents" that doesn't require polling as it reports instantaneously events that happen on the Unify network. Give it a try without any filtering and you'll see all of the information that it reports. After you know that than you design your own filter(s) to pick the info that you need and pass to HomeSeer. I'm using Big6 plug-in at HS4 to process the incoming information. While Big6 has good JSON parsing why bother. I designed the filters at Node-Red so that HS4 and Big6 have very little work to do. At Node-Red I'm doing it with 3 "switch" nodes that act as filters. See attached flowchart.

    Click image for larger version

Name:	Screenshot (477).png
Views:	171
Size:	83.4 KB
ID:	1518245

    Leave a comment:


  • stefxx
    replied
    Note that device connect is quite quickly reported by Unifi. Disconnect will depend on a lot of variables. For instance, if you shut down a client device properly, or disconnect from WiFi, it should properly disconnect from the network which makes it almost instant. However, if a device is getting out of range slowly, it might take up to 10 minutes before Unifi reports it as offline. All that time the device is not able to communicate to the network, and thus offline.

    The Unifi plugin uses Web Sockets, so all information is "pushed" to the plugin as soon as it becomes available. But polling - assuming it is done frequently enough - should not add that much, and especially on disconnect it will probably be negligible considering all other variables. And I do not have any experience with Node-Red, but I don't believe that will add any noticeable delay either.

    Leave a comment:


  • ksum
    replied
    Originally posted by Thedude View Post
    This is in stark contradiction with the results reported by ksum that it takes 30-40 seconds using Node-Red approach. I don't think that Node-Red adds delay at all. It seems that the Node-Red Unifi node connects to different properties of the Unifi controller that are not updated that often.
    Note that the slower response is a worse case I have seen when changing a client between my Guest and House WLAN. Normally it was faster. I was polling every 2 seconds then, if the Guest count changes, retrieving a list of all clients. I Split the message twice so that I have a message for each item attached the the network (client). I look for any on the guest network, and allow those to pass beyond the Switch node. Those messages are modified to set msg.payload to be formatted for the line in the email body which lists this client. I then have a timeout of 2 seconds to get all the guest clients before sending the email. I JUST sped up the Join by making a change to the split data and no longer waiting for a timeout. This has sped up the results. So my initial inefficiencies are likely from how I was handling the split message. This really didn't matter to my needs and was done in haste to test my Google speakers apparently connecting randomly to my guest network.

    This is what my flow looks like. The only difference from the recent edit to improve the Split/Join portion is an added change to the Change node prior to the Join node:
    Click image for larger version

Name:	HS1.png
Views:	147
Size:	88.2 KB
ID:	1518187



    I am sure this is all complicated and am willing to expand on this if desired.

    Karl

    Leave a comment:


  • Thedude
    replied
    I did it with Node-Red. Needed to go through the learning curve but it was worth it and ended up well. It is reasonably fast about 10 sec. from a device connect/disconnect to activate HS4 event. Notably I did it without polling which was the major concern. Unifi controller does report internal events such as connect/disconnect among others so that polling is possible but not necessary in my case. Willing to share details if someone is interested.

    Happy Holidays,

    Thedude

    Leave a comment:


  • pistacheL0
    replied
    Here with the syslog approch it is instant.
    I’m using an asus router that can send it’s log to a syslog server.

    Events writing to a log are instant. So no delay .

    Leave a comment:


  • Thedude
    replied

    It is confirmed now that Unifi plug-in by stefxx detects connect/disconnect almost instantaneously average 8 sec. to connect and 4 sec. to disconnect. Furthermore it provides information about the current AP that the device is connected to.

    This is in stark contradiction with the results reported by ksum that it takes 30-40 seconds using Node-Red approach. I don't think that Node-Red adds delay at all. It seems that the Node-Red Unifi node connects to different properties of the Unifi controller that are not updated that often.

    Leave a comment:


  • randy
    replied
    Originally posted by Thedude View Post
    Call me stupid but I can't find plug-in with name rccnm or RCCNM or Rccnm. How to find and install the damn thing?
    To add to what Jeff wrote, Jon00’s plug-ins are not in the updater. They need to be manually installed. Look at his forum here, there is a link to his website in his signature.

    Leave a comment:


  • stefxx
    replied
    Originally posted by Thedude View Post
    I can poll the Unifi controller now and obtain a long JSON with information of all APs and ALL devices on the network. I can send this info to HS4 and process it with Big6 PI, that is very good at parsing JSON. Not happy with this though as it adds significant extra burden to HS4. I need to do that every few seconds so that device detection is close to real time.
    Perhaps I misunderstand but if you are using a Unifi console you can get this information near-realtime with the HS4 Unifi plugin.

    https://forums.homeseer.com/forum/hs...atus-explained

    Leave a comment:


  • jgreenberg01
    replied
    Originally posted by Thedude View Post
    Call me stupid but I can't find plug-in with name rccnm or RCCNM or Rccnm. How to find and install the damn thing?
    The full name is "Jon00 Remote Computer Control & Network Monitor for Homeseer 3 & Homeseer 4"

    Just search for "Network Monitor".

    Leave a comment:


  • ksum
    replied
    The output from the unifi node should be an object with msg.paylaod being made up of a nested array. The node should be dry to get SiteStats for this output. Pass it through 2 Split nodes with default settings and you should then have a message for each attached device. From there, a Switch node set with the property looking at msg.payload.static_ip (guessing on the static IP entry, a debug node can be used to find this). This should then look for your static IP.

    I can say that from experience, expect up to 30 second, maybe more, before you get output matching what you are looking for. This has been the case on my watch for attachments to my guest network. I polled every 2 seconds.

    Leave a comment:


  • Thedude
    replied
    ksum

    Making good progress with Node-Red's Unifi node. I can poll the Unifi controller now and obtain a long JSON with information of all APs and ALL devices on the network. I can send this info to HS4 and process it with Big6 PI, that is very good at parsing JSON. Not happy with this though as it adds significant extra burden to HS4. I need to do that every few seconds so that device detection is close to real time.
    The task at hand now is to process the JSON locally at Node-Red (separate server than HS4) and to pass the information to HS4 only when monitored device(s) appear/disappear on the LAN. This is a bit beyond me as I'm Node-Red rookie, but I'm sure it is doable.

    Leave a comment:


  • Thedude
    replied
    Call me stupid but I can't find plug-in with name rccnm or RCCNM or Rccnm. How to find and install the damn thing?

    Leave a comment:


  • jgreenberg01
    replied
    I have been experimenting with the same thing and, for now anyway, found that Jon00's utility as @randy above shows, works well.

    I've incorporated it into my HSTouch screens like in this example:

    Click image for larger version

Name:	Floor Plan-Clients.png
Views:	307
Size:	643.5 KB
ID:	1516585

    The buttons on the left show what each Wi-Fi device that I want to track is doing. I use Jon00's utility to trigger events that change the status of virtual devices for each Wi-Fi device.

    The colors tell me what their network status is:
    • Red - not connected to router or to HS4 via internet
    • Yellow - connected to router, but not logged in to HS4
    • Green - connected to router and logged in to HS4
    • Blue - connected to HS4 via internet (not at home)

    Handling the HS4 login status (and tracking the current screen) is a separate topic, but I found Jon00's utility to be really responsive for LAN connections. BLLan works too, but in my case the device status took longer to register.

    To add to what randy said, it's not just iOS devices that connect intermittently. Some Android smartphones do the same thing.

    When they arrive home, they connect to the router immediately. If the screen is off though, you can see them connect/disconnect intermittently. I assume it's a power-saving scheme built-in to the phones.

    Constantly powered Android devices rarely drop the router connection from what I can tell.

    I was going to try the Node-Red route, but since I got it to work completely under the HS4 umbrella, I decided to not make it more complicated than it already is. YMMV of course.

    Leave a comment:


  • randy
    replied
    Any of the network monitoring plug-ins will do this. Jon00’s rccnm, BLLan and UltraMon3. The UniFi plug-in will do it as well, but I believe it does not work with the EdgeRouter, only with a USG or UDM. One thing to note is that IOS devices intermittently connect, they do not remain connected. Here are devices from Ultramon3. Michelle’s mini was connected to a power supply until she began using it this morning, so it has been online the longest. When they’re not powered, they just check in to WiFi periodically.

    Click image for larger version  Name:	A7A75A6A-57EB-421B-B951-1267BAA7E4A4.jpeg Views:	0 Size:	84.3 KB ID:	1516528

    Leave a comment:

Working...
X