Isaksson / node-red-contrib-unifi

MIT License
50 stars 19 forks source link

UNVR supported? #91

Closed 877dev closed 1 year ago

877dev commented 1 year ago

Hi, I have just added a UNVR to my system, wondering if I can read info from it such as temperature?

If so, would the node be configured for the UDMP IP or the UNVR IP? I'm asking as the UNVR does run it's own OS separate to the UDMP. The UNVR does show in the client devices from the UDMP as well.

On a secondary note, is there a way of searching the output of the 'Client Devices' instead of clicking and expanding each one in Node Red debug tab? For now I'm using a write file node and searching with a text editor.

Thanks

Isaksson commented 1 year ago

Hello. I do not think its possible to connect to an UNVR.

Your next question, maybe this will help you to search Change Default to what you are looking for and change network in element.network for where you want to search in the array. Let me know if you need anything else.

var search = "Default" var found = msg.payload.find(element => element.network === search) // if exists, returns object if (found) { msg.payload = found return msg; } else { node.warn(search + " is not found") }

877dev commented 1 year ago

@Isaksson so sorry I seem to have missed your reply! Yesterday I tried to get your suggestion working but have a question if I may?

Here is the contents of my function node, I'm not sure what to do regarding the element.network part..

var search = "iPhone-12";
var found = msg.payload.find(element => element.network === search); // if exists, returns object 
if (found)
{
msg.payload = found;
return msg;
} 
else
{
node.warn(search + " is not found")
};

image

877dev commented 1 year ago

Answering my own question, it's now working, my own ignorance (I needed to use element.hostname for example).

What confused me was that hostname is not getting populated as it used to do.

Example: in UniFi: image

And corresponding output from the node (some info obscured by x's):

"user_id":"622797ab0233c505xxx0","_id":"622797ab0233c50xxxx0da0","mac":"xx:xx:xx:xx:a6:bd","is_guest":false,"first_seen":1646761894,"last_seen":1672662870,"is_wired":false,"usergroup_id":"","fingerprint_source":0,"dev_cat":44,"dev_family":9,"dev_vendor":320,"dev_id":4438,"device_name":"Apple Watch Series 6 44mm","fw_version":"","score":48,"fingerprint_engine_version":"0.0.0","os_name":24,"confidence":100,"hostname":"","disconnect_timestamp":1672660681,"wlanconf_id":"5d7cd63axxxxx6c1d7cebf0","local_dns_record_enabled":false,"local_dns_record":"","name":"iPhone-chris","use_fixedip":false,"network_id":"5d7a9ba345xxxx77b0515","fixed_ap_enabled":false,"noted":true,"fixed_ip":"192.168.1.106","_uptime_by_uap":2188,"_last_seen_by_uap":1672662870,"_is_guest_by_uap":false,"ap_mac":"xx:xx:xx:xx:05:85","channel":48,"radio":"na","radio_name":"wifi1","essid":"Smithy_5G","bssid":"xx:xx:xx:xx:05:85","powersave_enabled":true,"is_11r":false,"user_group_id_computed":"5d7a9ba345d1xxxx77b0516","anomalies":-1,"anon_client_id":"00f875ff95ca2adf9xxxx9413f6d1","ccq":333,"dhcpend_time":0,"idletime":13,"noise":-106,"nss":2,"rx_rate":173300,"rssi":40,"satisfaction":97,"satisfaction_now":97,"satisfaction_real":97,"satisfaction_reason":2,"signal":-56,"tx_mcs":4,"tx_power":40,"tx_rate":78000,"vlan":0,"radio_proto":"ac","satisfaction_avg":{"total":39291,"count":400},"uptime":2188,"tx_retries":375,"wifi_tx_attempts":3770,"authorized":true,"qos_policy_applied":true,"_uptime_by_ugw":1559659,"_last_seen_by_ugw":1672662870,"_is_guest_by_ugw":false,"gw_mac":"xx:xx:xx:xx:5f:d1","network":"Default","tx_bytes":936688,"rx_bytes":359244,"tx_packets":2615,"rx_packets":2598,"tx_bytes-r":0,"rx_bytes-r":0,"_uptime_by_usw":1559659,"_last_seen_by_usw":1672662870,"_is_guest_by_usw":false,"sw_mac":"xx:xx:xx:xx:5f:d1","sw_depth":0,"sw_port":11,"wired_rate_mbps":1000,"hostname_source":"ubios","ip":"192.168.1.106","bytes-r":0},{"site_id":"5d7a9b9945d14f04b77b0507","assoc_time":1671449399,"latest_assoc_time":1671449399,"oui":"Espressif Inc.",

Seems like it's now name rather than hostname, maybe old info but new to me. Also for some reason it's showing this for some strange reason?

"device_name":"Apple Watch Series 6 44mm"
Isaksson commented 1 year ago

Good that you solved it, I didn't respond fast enough 🙂 Maybe that has changed in some firmware update from Unifi what information they store where.