starkillerOG/reolink_aio

failed mapping JSON data: 'name'

shlomki opened this issue · 4 comments

Describe the bug
When initializing, the Reolink Home Assistant integration takes a long time to finish, and an error is printed in the log:
(channel 0) failed mapping JSON data: 'name', traceback: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 2706, in map_channel_json_response patrol_name = patrol["name"] ~~~~~~^^^^^^^^ KeyError: 'name'

To Reproduce
Use the Reolink integration for Home Assistant, with an older "Reolink C1 Pro" camera. This doesn't happen to me with other models.

Expected behavior
Initialization should complete without errors.

Environment:
Please provide useful information about your environment, like:

  • Reolink C1 Pro
  • Home Assistant Core on Docker, using the official built-in integration.

Thanks for reporting this bug and sorry for not responding faster, have been very bussy.

Could you please turn on debug logging of the reolink HomeAssistant integration and then try to initialize the C1 pro?
Please post the resulting log.txt file here.

I don't have a C1 Pro to test with and have not seen this issue on modern reolink devices.

Will try and see what I can already do.

@shlomki @RobertD502 Hopfully this commit will solve the issue: 7067868
But I will need to see a debug log, specifically the response to the GetPtzPatrol command to know for sure how to solve this.

Sorry for the delay. I don't myself utilize PTZ patrol, but I'm sure someone else does and would like this error solved. Here are the PTZ Presets returned as well as the GetPtzPatrol command.

Note: This is for a RLC-423, Hardware: IPC_3816M, Firmware: v2.0.0.1441_19032111_v1.0.0.30.

Debug Log

   {
      "cmd" : "GetPtzPreset",
      "code" : 0,
      "value" : {
         "PtzPreset" : [
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 1,
               "name" : "Default"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 2,
               "name" : "Left"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 3,
               "name" : "House Left"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 4,
               "name" : "Below House"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 5,
               "name" : "House Right"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 6,
               "name" : "Street Right"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 7,
               "name" : "Street Out Right"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 8,
               "name" : "Street Out Middle"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 9,
               "name" : "Street Out Left"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 10,
               "name" : "pos10"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 11,
               "name" : "pos11"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 12,
               "name" : "pos12"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 13,
               "name" : "pos13"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 14,
               "name" : "pos14"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 15,
               "name" : "pos15"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 16,
               "name" : "pos16"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 17,
               "name" : "pos17"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 18,
               "name" : "pos18"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 19,
               "name" : "pos19"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 20,
               "name" : "pos20"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 21,
               "name" : "pos21"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 22,
               "name" : "pos22"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 23,
               "name" : "pos23"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 24,
               "name" : "pos24"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 25,
               "name" : "pos25"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 26,
               "name" : "pos26"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 27,
               "name" : "pos27"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 28,
               "name" : "pos28"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 29,
               "name" : "pos29"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 30,
               "name" : "pos30"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 31,
               "name" : "pos31"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 32,
               "name" : "pos32"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 33,
               "name" : "pos33"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 34,
               "name" : "pos34"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 35,
               "name" : "pos35"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 36,
               "name" : "pos36"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 37,
               "name" : "pos37"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 38,
               "name" : "pos38"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 39,
               "name" : "pos39"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 40,
               "name" : "pos40"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 41,
               "name" : "pos41"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 42,
               "name" : "pos42"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 43,
               "name" : "pos43"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 44,
               "name" : "pos44"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 45,
               "name" : "pos45"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 46,
               "name" : "pos46"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 47,
               "name" : "pos47"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 48,
               "name" : "pos48"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 49,
               "name" : "pos49"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 50,
               "name" : "pos50"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 51,
               "name" : "pos51"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 52,
               "name" : "pos52"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 53,
               "name" : "pos53"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 54,
               "name" : "pos54"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 55,
               "name" : "pos55"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 56,
               "name" : "pos56"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 57,
               "name" : "pos57"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 58,
               "name" : "pos58"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 59,
               "name" : "pos59"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 60,
               "name" : "pos60"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 61,
               "name" : "pos61"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 62,
               "name" : "pos62"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 63,
               "name" : "pos63"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 64,
               "name" : "pos64"
            }
         ]
      }
   },
   {
      "cmd" : "GetPtzPatrol",
      "code" : 0,
      "value" : {
         "PtzPatrol" : [
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 1,
               "preset" : [
                  {
                     "dwellTime" : 5,
                     "id" : 2,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 3,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 4,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 5,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 6,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 7,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 8,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 9,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 2,
                     "speed" : 10
                  }
               ],
               "running" : 0
            }
         ]
      }
   },
   {
      "cmd" : "GetPtzPatrol",
      "code" : 1,
      "error" : {
         "detail" : "not support",
         "rspCode" : -9
      }
   },
   {
      "cmd" : "GetPtzPatrol",
      "code" : 1,
      "error" : {
         "detail" : "not support",
         "rspCode" : -9
      }
   },

If it helps, here is the response from the API grabbed directly by navigating to the camera's Reolink portal in a browser

   {
      "cmd" : "GetPtzPatrol",
      "code" : 0,
      "range" : {
         "PtzPatrol" : {
            "enable" : "boolean",
            "id" : {
               "max" : 1,
               "min" : 1
            },
            "preset" : {
               "dwellTime" : {
                  "max" : 30,
                  "min" : 1
               },
               "id" : {
                  "max" : 64,
                  "min" : 1
               },
               "speed" : {
                  "max" : 64,
                  "min" : 1
               }
            },
            "running" : "boolean"
         }
      },
      "value" : {
         "PtzPatrol" : [
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 1,
               "preset" : [
                  {
                     "dwellTime" : 5,
                     "id" : 2,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 3,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 4,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 5,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 6,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 7,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 8,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 9,
                     "speed" : 10
                  },
                  {
                     "dwellTime" : 5,
                     "id" : 2,
                     "speed" : 10
                  }
               ],
               "running" : 0
            }
         ]
      }
   },
   {
      "cmd" : "GetPtzPreset",
      "code" : 0,
      "range" : {
         "PtzPreset" : {
            "channel" : 0,
            "enable" : "boolean",
            "id" : {
               "max" : 64,
               "min" : 1
            },
            "name" : {
               "maxLen" : 31
            }
         }
      },
      "value" : {
         "PtzPreset" : [
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 1,
               "name" : "Default"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 2,
               "name" : "Left"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 3,
               "name" : "House Left"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 4,
               "name" : "Below House"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 5,
               "name" : "House Right"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 6,
               "name" : "Street Right"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 7,
               "name" : "Street Out Right"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 8,
               "name" : "Street Out Middle"
            },
            {
               "channel" : 0,
               "enable" : 1,
               "id" : 9,
               "name" : "Street Out Left"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 10,
               "name" : "pos10"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 11,
               "name" : "pos11"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 12,
               "name" : "pos12"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 13,
               "name" : "pos13"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 14,
               "name" : "pos14"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 15,
               "name" : "pos15"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 16,
               "name" : "pos16"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 17,
               "name" : "pos17"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 18,
               "name" : "pos18"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 19,
               "name" : "pos19"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 20,
               "name" : "pos20"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 21,
               "name" : "pos21"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 22,
               "name" : "pos22"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 23,
               "name" : "pos23"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 24,
               "name" : "pos24"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 25,
               "name" : "pos25"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 26,
               "name" : "pos26"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 27,
               "name" : "pos27"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 28,
               "name" : "pos28"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 29,
               "name" : "pos29"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 30,
               "name" : "pos30"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 31,
               "name" : "pos31"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 32,
               "name" : "pos32"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 33,
               "name" : "pos33"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 34,
               "name" : "pos34"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 35,
               "name" : "pos35"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 36,
               "name" : "pos36"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 37,
               "name" : "pos37"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 38,
               "name" : "pos38"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 39,
               "name" : "pos39"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 40,
               "name" : "pos40"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 41,
               "name" : "pos41"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 42,
               "name" : "pos42"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 43,
               "name" : "pos43"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 44,
               "name" : "pos44"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 45,
               "name" : "pos45"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 46,
               "name" : "pos46"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 47,
               "name" : "pos47"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 48,
               "name" : "pos48"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 49,
               "name" : "pos49"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 50,
               "name" : "pos50"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 51,
               "name" : "pos51"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 52,
               "name" : "pos52"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 53,
               "name" : "pos53"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 54,
               "name" : "pos54"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 55,
               "name" : "pos55"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 56,
               "name" : "pos56"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 57,
               "name" : "pos57"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 58,
               "name" : "pos58"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 59,
               "name" : "pos59"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 60,
               "name" : "pos60"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 61,
               "name" : "pos61"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 62,
               "name" : "pos62"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 63,
               "name" : "pos63"
            },
            {
               "channel" : 0,
               "enable" : 0,
               "id" : 64,
               "name" : "pos64"
            }
         ]
      }
   }

@RobertD502 thank you very much for this info!
This confirms my fix will work as intended.
Once I release a new reolink-aio version and bump the version used in HomeAssistant this will be fixed.
Probably will happen before HA 2024.7.0 is released

If you appreciate the reolink integration and want to support its development, please consider sponsering the upstream library or purchase Reolink products through this affiliate link.