discoverBridgesEndpoint static method

Future<List<String>> discoverBridgesEndpoint()

Searches the network for bridges using the endpoint method.

Implementation

static Future<List<String>> discoverBridgesEndpoint() async {
  List<String> bridges = [];

  Client client = Client();

  Response response =
      await client.get(Uri.parse("https://discovery.meethue.com"));

  if (response.statusCode >= 200 && response.statusCode < 300) {
    List<Map<String, dynamic>> results = List<Map<String, dynamic>>.from(
      jsonDecode(response.body).map(
        (result) => Map<String, dynamic>.from(result),
      ),
    );

    for (Map<String, dynamic> result in results) {
      bridges.add(result["internalipaddress"]);
    }
  }

  return bridges;
}