michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
411 stars 114 forks source link

GetEntertainmentConfigurationsAsync throwing JsonException #288

Closed joao-mambelli closed 1 year ago

joao-mambelli commented 1 year ago

I was trying to get the Entertainment groups but I was getting a JSON exception. Decided to download your project to debug it and come here with more information on that, so:

In ProcessResponseAsync in BaseHueApi.cs it was throwing when trying to do await response.Content.ReadFromJsonAsync<T>(), with the following exception: The JSON value could not be converted to HueApi.Models.EntertainmentConfigurationType.

This is the JSON it got from await client.GetAsync(url) (I masked part of the Ids because I don't know if they are sensible data): Raw: Screenshot 2022-10-18 081929 Formatted:

{
   "errors":[

   ],
   "data":[
      {
         "id":"xxxxxxxx-xxxx-404f-xxxx-xxxxxxxxxxxx",
         "id_v1":"/groups/2",
         "metadata":{
            "name":"Entertainment area"
         },
         "type":"entertainment_configuration",
         "configuration_type":"monitor",
         "locations":{
            "service_locations":[
               {
                  "service":{
                     "rtype":"entertainment",
                     "rid":"xxxxxxxx-xxxx-4358-xxxx-xxxxxxxxxxxx"
                  },
                  "positions":[
                     {
                        "x":1.0,
                        "y":-1.0,
                        "z":1.0
                     }
                  ],
                  "position":{
                     "x":1.0,
                     "y":-1.0,
                     "z":1.0
                  }
               }
            ]
         },
         "channels":[
            {
               "channel_id":0,
               "position":{
                  "x":1.0,
                  "y":-1.0,
                  "z":1.0
               },
               "members":[
                  {
                     "index":0,
                     "service":{
                        "rtype":"entertainment",
                        "rid":"xxxxxxxx-xxxx-4358-xxxx-xxxxxxxxxxxx"
                     }
                  }
               ]
            }
         ],
         "light_services":[
            {
               "rtype":"light",
               "rid":"xxxxxxxx-xxxx-4d5b-xxxx-xxxxxxxxxxxx"
            }
         ],
         "stream_proxy":{
            "mode":"auto",
            "node":{
               "rtype":"entertainment",
               "rid":"xxxxxxxx-xxxx-469a-xxxx-xxxxxxxxxxxx"
            }
         },
         "status":"inactive",
         "name":"Entertainment area"
      }
   ]
}
joao-mambelli commented 1 year ago

I understood the problem, the EntertainmentConfigurationType is missing monitor.

FYI, monitor is defined when I edit the Entertainment Area and select Gaming as the area type in the Philips Hue App on android.

From https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_entertainment_configuration_get: Screenshot 2022-10-18 094214

For now I changed from Gaming to TV so I could keep going with my development.

michielpost commented 1 year ago

Thanks, I added the monitor value. A new release will be on NuGet shortly.

joao-mambelli commented 1 year ago

Nice!

Hey, I'm getting trouble trying to locate bridges using only the new HueApi because only HttpBridgeLocator is available and after some few times hitting it, it gives me HTTP ERROR 429.

On Q42.HueApi, LocalNetworkScanBridgeLocator was working great... Could you also add the safer options to the new HueApi?

michielpost commented 1 year ago

The Http Error 429 is caused by rate limiting on the HTTP endpoint.

I migrated the other Network bridge locators to the new HueApi. It's in version 0.9.4 on NuGet