Closed magic7s closed 3 years ago
Hi,
I can add possibility to filter network clients by given client name.
For every filtered client will be created switch for set client policy.
Switch set ON
apply policy Blocked
, Switch set OFF
apply policy Normal
.
Is that what You want.?
Switch set ON apply policy Blocked, Switch set OFF apply policy Normal.
My opinion is that ON should mean "has access to the network" which would have a policy of Normal
and OFF would mean "does not have access to the network" which would have a policy of Blocked
. This would be consistent with SSIDs, ON is "network is providing access" and OFF is "network is not providing access".
Yes You are right, my mistake. I will realize this today or tomorrow.
added in 8.3
It's working!
@grzegorz914 so awesome and I'm jealous how quickly you could do that so quickly. Thanks!
My only feedback is you are using device name, which makes it much more user friendly but I don't think it's a unique value. TBH I haven't tested duplicate names, but that was the first concern. In my own script, I used mac address
, but I can see how that would be less friendly for users.
One more thing I found was that if the client was off line for too long the API call would fail causing an error in my script. I had to catch the error and log it gracefully. I found the same thing here, I think. I added a client named "Fake-ipad" and now I'm seeing errors in the log. If a user puts a client name in, but that client stays offline for to long the api call will start to fail and generate errors.
Log
[28/08/2021, 14:07:21] [homebridge-meraki-control] This plugin generated a warning from the characteristic 'On': characteristic value expected boolean and received undefined. See https://git.io/JtMGR for more info.
[28/08/2021, 14:07:21] [homebridge-meraki-control] Error:
at On.Characteristic.characteristicWarning (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2038:105)
at On.Characteristic.validateUserInput (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1915:14)
at On.Characteristic.updateValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1379:20)
at Switch.Service.updateCharacteristic (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Service.ts:465:35)
at merakiDevice.updateDeviceState (/usr/local/lib/node_modules/homebridge-meraki-control/index.js:254:16)
at merakiDevice.updateMerakiMrSsidsData (/usr/local/lib/node_modules/homebridge-meraki-control/index.js:166:82)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
OK, i will look tomorrow on that
We can use MAC address to filter it but quickly and friendly is use device description. May be will be god option to add choice which method to filter we want to use, Mac or Description. I add this possibility tomorrow.
0.8.5 ready to test
Testing on v0.8.6
I'm seeing a lot of churn (device goes on/off due to status polling).
I'm not pushing any buttons (or changing any status, just keeping the Home app open) Screen Recording
[29/08/2021, 10:15:28] [Meraki] Device: Meraki Network, requesting dashboardClientsData.
[29/08/2021, 10:15:28] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' }
[29/08/2021, 10:15:29] [Meraki] Debug dashboardClientsPolicyData: { mac: '1a:2f:76:0d:58:1f', devicePolicy: 'Normal' }
[29/08/2021, 10:15:29] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' }
[29/08/2021, 10:15:29] [Meraki] Debug dashboardClientsData: {
[29/08/2021, 10:15:29] [Meraki] Device: Meraki Network, requesting wirelessData.
[29/08/2021, 10:15:29] [Meraki] Debug dashboardClientsPolicyData: { mac: '10:40:f3:c5:ee:b6', devicePolicy: 'Normal' }
[29/08/2021, 10:15:30] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' }
[29/08/2021, 10:15:30] [Meraki] Debug merakiMrData: {
[29/08/2021, 10:15:30] [Meraki] Device: Meraki Network, update device state.
[29/08/2021, 10:15:30] [Meraki] Debug dashboardClientsPolicyData: { mac: '10:40:f3:c5:ee:b6', devicePolicy: 'Normal' }
[29/08/2021, 10:15:30] [Meraki] Debug dashboardClientsPolicyData: { mac: 'ec:0d:e4:f9:7d:de', devicePolicy: 'Normal' }
[29/08/2021, 10:15:30] [Meraki] Debug dashboardClientsPolicyData: { mac: '4c:ef:c0:39:59:68', devicePolicy: 'Normal' }
[29/08/2021, 10:15:31] [Meraki] Debug dashboardClientsPolicyData: { mac: 'ec:0d:e4:f9:7d:de', devicePolicy: 'Normal' }
[29/08/2021, 10:15:31] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:82:c2', devicePolicy: 'Normal' }
[29/08/2021, 10:15:31] [Meraki] Debug dashboardClientsPolicyData: { mac: 'f0:b3:ec:3f:fa:1a', devicePolicy: 'Normal' }
[29/08/2021, 10:15:31] [Meraki] Debug dashboardClientsPolicyData: { mac: '8c:85:80:60:e7:f3', devicePolicy: 'Normal' }
[29/08/2021, 10:15:32] [Meraki] Debug dashboardClientsPolicyData: { mac: 'f0:b3:ec:3f:fa:1a', devicePolicy: 'Normal' }
[29/08/2021, 10:15:32] [Meraki] Debug dashboardClientsPolicyData: { mac: '9c:8e:cd:0d:39:61', devicePolicy: 'Normal' }
[29/08/2021, 10:15:32] [Meraki] Debug dashboardClientsPolicyData: { mac: 'b8:3e:59:8b:b7:53', devicePolicy: 'Normal' }
[29/08/2021, 10:15:32] [Meraki] Debug dashboardClientsPolicyData: { mac: 'a4:83:e7:28:86:b7', devicePolicy: 'Normal' }
[29/08/2021, 10:15:33] [Meraki] Debug dashboardClientsPolicyData: { mac: 'b8:3e:59:8b:b7:53', devicePolicy: 'Normal' }
[29/08/2021, 10:15:33] [Meraki] Debug dashboardClientsPolicyData: { mac: '8c:85:80:9d:5f:e2', devicePolicy: 'Normal' }
[29/08/2021, 10:15:33] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:e1:b6:b0:b2:cc', devicePolicy: 'Blocked' }
[29/08/2021, 10:15:33] [Meraki] Debug dashboardClientsPolicyData: { mac: 'b8:27:eb:ff:a5:4a', devicePolicy: 'Normal' }
[29/08/2021, 10:15:34] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:e1:b6:b0:b2:cc', devicePolicy: 'Blocked' }
[29/08/2021, 10:15:34] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:7d:4f', devicePolicy: 'Normal' }
[29/08/2021, 10:15:34] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:e1:b6:b0:b2:cc', devicePolicy: 'Blocked' }
[29/08/2021, 10:15:34] [Meraki] Debug dashboardClientsPolicyData: { mac: 'b8:78:2e:02:24:fd', devicePolicy: 'Normal' }
[29/08/2021, 10:15:35] [Meraki] Debug dashboardClientsPolicyData: { mac: '84:a9:3e:35:6e:b1', devicePolicy: 'Normal' }
[29/08/2021, 10:15:35] [Meraki] Debug dashboardClientsPolicyData: { mac: '9c:8e:cd:0d:39:de', devicePolicy: 'Normal' }
[29/08/2021, 10:15:35] [Meraki] Debug dashboardClientsPolicyData: { mac: '84:a9:3e:35:6e:b1', devicePolicy: 'Normal' }
[29/08/2021, 10:15:35] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:95:85', devicePolicy: 'Normal' }
[29/08/2021, 10:15:36] [Meraki] Debug dashboardClientsPolicyData: { mac: '84:a9:3e:35:6e:b1', devicePolicy: 'Normal' }
[29/08/2021, 10:15:36] [Meraki] Debug dashboardClientsPolicyData: { mac: '38:f9:d3:63:c4:35', devicePolicy: 'Normal' }
[29/08/2021, 10:15:36] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' }
[29/08/2021, 10:15:36] [Meraki] Debug dashboardClientsPolicyData: { mac: '44:61:32:21:a6:cb', devicePolicy: 'Normal' }
[29/08/2021, 10:15:37] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' }
[29/08/2021, 10:15:37] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:75:48:41:55:ce', devicePolicy: 'Normal' }
[29/08/2021, 10:15:37] [Meraki] Debug dashboardClientsPolicyData: { mac: '12:35:22:46:34:47', devicePolicy: 'Normal' }
[29/08/2021, 10:15:38] [Meraki] Debug dashboardClientsPolicyData: { mac: '1a:2f:76:0d:58:1f', devicePolicy: 'Normal' }
[29/08/2021, 10:15:38] [Meraki] Debug dashboardClientsPolicyData: { mac: '10:40:f3:c5:ee:b6', devicePolicy: 'Normal' }
Config
{
"devices": [
{
"name": "Meraki Network",
"apiKey": "0000REMOVED00000",
"organizationId": "0000000",
"networkId": "L_removed",
"refreshInterval": 10,
"disableLogInfo": true,
"hideUnconfiguredSsids": true,
"hideSsidByName": [
{
"name": "1HOTBR"
},
{
"name": "b_only"
}
],
"getClientByNameOrMac": [
{
"mode": true,
"name": "74:e1:b6:b0:b2:cc",
"customName": "Luka iPad"
},
{
"mode": true,
"name": "b8:53:ac:d6:f1:83",
"customName": "Luka iPhone"
},
{
"mode": true,
"name": "10:40:f3:c5:ee:b6",
"customName": "Luna iPad"
},
{
"mode": true,
"name": "4c:ef:c0:39:59:68",
"customName": "Luka Fire"
},
{
"mode": true,
"name": "00:71:47:c7:6c:17",
"customName": "Luna Fire"
}
]
}
],
"platform": "Meraki"
},
Note: the fire devices are not online (or in the meraki dashboard) due to timeout.
Other logs
[29/08/2021, 10:23:45] [Meraki] Device: Meraki Network, dashboardClientsData error: Error: Client network socket disconnected before secure TLS connection was established
at connResetException (internal/errors.js:628:14)
at TLSSocket.onConnectEnd (_tls_wrap.js:1561:19)
at TLSSocket.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'ECONNRESET',
path: null,
host: 'api.meraki.com',
port: 443,
localAddress: undefined,
config: [Object],
request: [Writable],
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON]
}
[29/08/2021, 10:26:22] [homebridge-meraki-control] This plugin generated a warning from the characteristic 'On': characteristic value expected boolean and received undefined. See https://git.io/JtMGR for more info.
[29/08/2021, 10:26:22] [homebridge-meraki-control] This plugin generated a warning from the characteristic 'On': characteristic value expected boolean and received undefined. See https://git.io/JtMGR for more info.
[29/08/2021, 10:26:22] [homebridge-meraki-control] This plugin generated a warning from the characteristic 'On': characteristic value expected boolean and received undefined. See https://git.io/JtMGR for more info.
[29/08/2021, 10:26:22] [homebridge-meraki-control] This plugin generated a warning from the characteristic 'On': characteristic value expected boolean and received undefined. See https://git.io/JtMGR for more info.
Testing on v0.8.6
I'm seeing a lot of churn (device goes on/off due to status polling).
I'm not pushing any buttons (or changing any status, just keeping the Home app open) Screen Recording
[29/08/2021, 10:15:28] [Meraki] Device: Meraki Network, requesting dashboardClientsData. [29/08/2021, 10:15:28] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' } [29/08/2021, 10:15:29] [Meraki] Debug dashboardClientsPolicyData: { mac: '1a:2f:76:0d:58:1f', devicePolicy: 'Normal' } [29/08/2021, 10:15:29] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' } [29/08/2021, 10:15:29] [Meraki] Debug dashboardClientsData: { [29/08/2021, 10:15:29] [Meraki] Device: Meraki Network, requesting wirelessData. [29/08/2021, 10:15:29] [Meraki] Debug dashboardClientsPolicyData: { mac: '10:40:f3:c5:ee:b6', devicePolicy: 'Normal' } [29/08/2021, 10:15:30] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' } [29/08/2021, 10:15:30] [Meraki] Debug merakiMrData: { [29/08/2021, 10:15:30] [Meraki] Device: Meraki Network, update device state. [29/08/2021, 10:15:30] [Meraki] Debug dashboardClientsPolicyData: { mac: '10:40:f3:c5:ee:b6', devicePolicy: 'Normal' } [29/08/2021, 10:15:30] [Meraki] Debug dashboardClientsPolicyData: { mac: 'ec:0d:e4:f9:7d:de', devicePolicy: 'Normal' } [29/08/2021, 10:15:30] [Meraki] Debug dashboardClientsPolicyData: { mac: '4c:ef:c0:39:59:68', devicePolicy: 'Normal' } [29/08/2021, 10:15:31] [Meraki] Debug dashboardClientsPolicyData: { mac: 'ec:0d:e4:f9:7d:de', devicePolicy: 'Normal' } [29/08/2021, 10:15:31] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:82:c2', devicePolicy: 'Normal' } [29/08/2021, 10:15:31] [Meraki] Debug dashboardClientsPolicyData: { mac: 'f0:b3:ec:3f:fa:1a', devicePolicy: 'Normal' } [29/08/2021, 10:15:31] [Meraki] Debug dashboardClientsPolicyData: { mac: '8c:85:80:60:e7:f3', devicePolicy: 'Normal' } [29/08/2021, 10:15:32] [Meraki] Debug dashboardClientsPolicyData: { mac: 'f0:b3:ec:3f:fa:1a', devicePolicy: 'Normal' } [29/08/2021, 10:15:32] [Meraki] Debug dashboardClientsPolicyData: { mac: '9c:8e:cd:0d:39:61', devicePolicy: 'Normal' } [29/08/2021, 10:15:32] [Meraki] Debug dashboardClientsPolicyData: { mac: 'b8:3e:59:8b:b7:53', devicePolicy: 'Normal' } [29/08/2021, 10:15:32] [Meraki] Debug dashboardClientsPolicyData: { mac: 'a4:83:e7:28:86:b7', devicePolicy: 'Normal' } [29/08/2021, 10:15:33] [Meraki] Debug dashboardClientsPolicyData: { mac: 'b8:3e:59:8b:b7:53', devicePolicy: 'Normal' } [29/08/2021, 10:15:33] [Meraki] Debug dashboardClientsPolicyData: { mac: '8c:85:80:9d:5f:e2', devicePolicy: 'Normal' } [29/08/2021, 10:15:33] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:e1:b6:b0:b2:cc', devicePolicy: 'Blocked' } [29/08/2021, 10:15:33] [Meraki] Debug dashboardClientsPolicyData: { mac: 'b8:27:eb:ff:a5:4a', devicePolicy: 'Normal' } [29/08/2021, 10:15:34] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:e1:b6:b0:b2:cc', devicePolicy: 'Blocked' } [29/08/2021, 10:15:34] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:7d:4f', devicePolicy: 'Normal' } [29/08/2021, 10:15:34] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:e1:b6:b0:b2:cc', devicePolicy: 'Blocked' } [29/08/2021, 10:15:34] [Meraki] Debug dashboardClientsPolicyData: { mac: 'b8:78:2e:02:24:fd', devicePolicy: 'Normal' } [29/08/2021, 10:15:35] [Meraki] Debug dashboardClientsPolicyData: { mac: '84:a9:3e:35:6e:b1', devicePolicy: 'Normal' } [29/08/2021, 10:15:35] [Meraki] Debug dashboardClientsPolicyData: { mac: '9c:8e:cd:0d:39:de', devicePolicy: 'Normal' } [29/08/2021, 10:15:35] [Meraki] Debug dashboardClientsPolicyData: { mac: '84:a9:3e:35:6e:b1', devicePolicy: 'Normal' } [29/08/2021, 10:15:35] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:95:85', devicePolicy: 'Normal' } [29/08/2021, 10:15:36] [Meraki] Debug dashboardClientsPolicyData: { mac: '84:a9:3e:35:6e:b1', devicePolicy: 'Normal' } [29/08/2021, 10:15:36] [Meraki] Debug dashboardClientsPolicyData: { mac: '38:f9:d3:63:c4:35', devicePolicy: 'Normal' } [29/08/2021, 10:15:36] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' } [29/08/2021, 10:15:36] [Meraki] Debug dashboardClientsPolicyData: { mac: '44:61:32:21:a6:cb', devicePolicy: 'Normal' } [29/08/2021, 10:15:37] [Meraki] Debug dashboardClientsPolicyData: { mac: 'd4:a6:51:2a:84:08', devicePolicy: 'Normal' } [29/08/2021, 10:15:37] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:75:48:41:55:ce', devicePolicy: 'Normal' } [29/08/2021, 10:15:37] [Meraki] Debug dashboardClientsPolicyData: { mac: '12:35:22:46:34:47', devicePolicy: 'Normal' } [29/08/2021, 10:15:38] [Meraki] Debug dashboardClientsPolicyData: { mac: '1a:2f:76:0d:58:1f', devicePolicy: 'Normal' } [29/08/2021, 10:15:38] [Meraki] Debug dashboardClientsPolicyData: { mac: '10:40:f3:c5:ee:b6', devicePolicy: 'Normal' }
Config
{ "devices": [ { "name": "Meraki Network", "apiKey": "0000REMOVED00000", "organizationId": "0000000", "networkId": "L_removed", "refreshInterval": 10, "disableLogInfo": true, "hideUnconfiguredSsids": true, "hideSsidByName": [ { "name": "1HOTBR" }, { "name": "b_only" } ], "getClientByNameOrMac": [ { "mode": true, "name": "74:e1:b6:b0:b2:cc", "customName": "Luka iPad" }, { "mode": true, "name": "b8:53:ac:d6:f1:83", "customName": "Luka iPhone" }, { "mode": true, "name": "10:40:f3:c5:ee:b6", "customName": "Luna iPad" }, { "mode": true, "name": "4c:ef:c0:39:59:68", "customName": "Luka Fire" }, { "mode": true, "name": "00:71:47:c7:6c:17", "customName": "Luna Fire" } ] } ], "platform": "Meraki" },
Note: the fire devices are not online (or in the meraki dashboard) due to timeout.
Here is all OK in the log
Here is all OK in the log
Yes, but if you watch the screen recording the switches in the home app blink every 10 seconds off then back on. It's not caching the state and refreshing in the background.
fixed
Today I use a custom python script to turn my kids devices on or off (to help control screen time). I could use this as a replacement by adding all their devices to a single SSID or use the
updateNetworkClientPolicy
as an on off switch. I'd be happy to help contribute this but I don't know Javascript. I could help with my experience using the Meraki API and share the code I wrote in Python if that would help.Adding a bit more detail here: The plugin today exposes SSIDs (all clients on or off), what I am proposing as a feature request is Clients exposed as an accessory with a simple on/off switch. The updateNetworkClientPolicy endpoint could be used. It would be important to take a list of Clients (mac-address) as a filter to limit the Clients exposed to homebridge.
Status:
dashboard.networks.getNetworkClientPolicy(networkId=network_id, clientId=client["mac"])
Off:dashboard.networks.updateNetworkClientPolicy(networkId=network_id, clientId=client["mac"], devicePolicy="Blocked")
On:dashboard.networks.updateNetworkClientPolicy(networkId=network_id, clientId=client["mac"], devicePolicy="Normal")
If there was a way to add more than simple on/off, then adding support for
dashboard.networks.updateNetworkClientPolicy(networkId=network_id, clientId=client["mac"], devicePolicy="Group policy", groupPolicyId="101")
where the groupPolicyId is mapped to a friendly name like "Kids limited access".