grzegorz914 / homebridge-meraki-control

Homebridge plugin for Meraki devices using RESTFull API, publish as independent external platform accessory.
MIT License
0 stars 3 forks source link

Client that is not on the network throws 404 error. #8

Closed magic7s closed 3 years ago

magic7s commented 3 years ago

I have a list of clients added and all are powered up and connected, except one. "name": "00:71:47:c7:6c:17" has been powered off for some time and no longer in the Meraki Dashboard. The plugin is throwing a 404 error because the api throws this for a client that is not found on the network. It would be best to handle this error a bit more gracefully and inform the user the client they added was not found and may be because it is not online or the mac-address/name could be wrong.

Config

"getClientByNameOrMac": [
                        {
                            "mode": true,
                            "name": "74:e1:b6:b0:b2:cc",
                            "customName": "Luka iPad"
                        },
                        {
                            "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"
                        }
                    ]

Logs

[29/08/2021, 20:44:35] [Meraki] Device: Meraki Network, update device state.
[29/08/2021, 20:44:35] [Meraki] Debug dashboardClientsPolicyData: { mac: '74:e1:b6:b0:b2:cc', devicePolicy: 'Blocked' }
[29/08/2021, 20:44:36] [Meraki] Debug dashboardClientsPolicyData: { mac: '10:40:f3:c5:ee:b6', devicePolicy: 'Blocked' }
[29/08/2021, 20:44:36] [Meraki] Debug dashboardClientsPolicyData: { mac: '4c:ef:c0:39:59:68', devicePolicy: 'Normal' }
[29/08/2021, 20:44:37] [Meraki] Device: Meraki Network, dashboardClientsPolicyData error: Error: Request failed with status code 404
    at createError (/usr/local/lib/node_modules/homebridge-meraki-control/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/usr/local/lib/node_modules/homebridge-meraki-control/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/homebridge-meraki-control/node_modules/axios/lib/adapters/http.js:260:11)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  config: [Object],
  request: [ClientRequest],
  response: [Object],
  isAxiosError: true,
  toJSON: [Function: toJSON]
}

edit: Also, if you have Scene that includes those devices, Homekit reports the Scene has failed because one of the devices failed to update.