/* Note: You'll need to install the ArduinoJson library first before this will work See https://www.youtube.com/watch?v=GUTpaY1YaXo for a 30-sec video showing how More examples here: https://arduinojson.org/v6/how-to/use-arduinojson-with-esp8266httpclient/ */ #include #include #include // WiFi credentials const char* ssid = "WIFI_NETWORK_NAME"; const char* password = "WIFI_NETWORK_PASSWORD"; void setup() { // Connect to WiFi Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting..."); } } void loop() { if (WiFi.status() == WL_CONNECTED) { HTTPClient http; // Login to Home Assistant http.begin("URL_GOES_HERE"); http.addHeader("Authorization", "Bearer API_KEY_GOES_HERE"); http.addHeader("Content-Type", "application/json"); http.GET(); // Parse response DynamicJsonDocument doc(2048); deserializeJson(doc, http.getStream()); // Read values Serial.println(doc["attributes"]["media_artist"].as()); Serial.println(doc["attributes"]["media_title"].as()); // Disconnect http.end(); } delay(60000); }