Make integration work with HA < 0.104

This commit is contained in:
Yegor Vialov
2020-05-06 16:40:19 +00:00
parent 17ec73b176
commit 8cd5776bc6
2 changed files with 12 additions and 2 deletions

View File

@ -19,6 +19,7 @@ class ConnectionManager {
String _tempToken;
String oauthUrl;
String webhookId;
double haVersion;
String mobileAppDeviceName;
bool settingsLoaded = false;
int appIntegrationVersion;
@ -154,7 +155,12 @@ class ConnectionManager {
if (!connecting.isCompleted) connecting.completeError(e);
});
} else if (data["type"] == "auth_ok") {
Logger.d("[Received] <== ${data.toString()}");
String v = data["ha_version"];
if (v != null && v.isNotEmpty) {
haVersion = double.tryParse(v.replaceFirst('0.','')) ?? 0;
}
Logger.d("Home assistant version: $v ($haVersion)");
Crashlytics.instance.setString('ha_version', v);
Logger.d("[Connection] Subscribing to events");
sendSocketMessage(
type: "subscribe_events",