Compare commits

...

8 Commits

Author SHA1 Message Date
9cc60a136b 0.7.7 2019-12-10 22:05:12 +00:00
78eb1e779c Fix state event handling before fetch complete 2019-12-10 22:04:24 +00:00
8db2d8508e Resolves #515 tabs controller issue 2019-12-10 22:00:17 +00:00
3f1ece26ec Remove background task logging and reporting 2019-12-10 21:19:29 +00:00
d1912a44c6 Replace Discord with Spectrum 2019-12-10 19:54:02 +00:00
36a05eb390 Update README.md 2019-12-06 10:58:23 +02:00
4f39ea1ad8 Update README.md 2019-12-04 16:31:03 +02:00
a241cc1d61 Resolves #494 2019-11-29 13:40:51 +00:00
7 changed files with 33 additions and 33 deletions

View File

@ -7,7 +7,7 @@ Visit [homemade.systems](http://ha-client.homemade.systems/) for more info.
Download the app from [Google Play](https://play.google.com/apps/testing/com.keyboardcrumbs.haclient) Download the app from [Google Play](https://play.google.com/apps/testing/com.keyboardcrumbs.haclient)
Discuss it in [Home Assistant community](https://community.home-assistant.io/t/alpha-testing-ha-client-native-android-client-for-home-assistant/69912) or on [Discord server](https://discord.gg/AUzEvwn) Discuss it on [Spectrum.chat](https://spectrum.chat/ha-client) or at [Home Assistant community](https://community.home-assistant.io/c/mobile-apps/ha-client-android)
#### Pre-release CI build #### Pre-release CI build
[![Codemagic build status](https://api.codemagic.io/apps/5da8bdab9f20ef798f7c2c65/5da8bdab9f20ef798f7c2c64/status_badge.svg)](https://codemagic.io/apps/5da8bdab9f20ef798f7c2c65/5da8bdab9f20ef798f7c2c64/latest_build) [![Codemagic build status](https://api.codemagic.io/apps/5da8bdab9f20ef798f7c2c65/5da8bdab9f20ef798f7c2c64/status_badge.svg)](https://codemagic.io/apps/5da8bdab9f20ef798f7c2c65/5da8bdab9f20ef798f7c2c64/latest_build)

View File

@ -63,10 +63,6 @@ class HomeAssistant {
futures.add(_getServices()); futures.add(_getServices());
futures.add(_getUserInfo()); futures.add(_getUserInfo());
futures.add(_getPanels()); futures.add(_getPanels());
futures.add(ConnectionManager().sendSocketMessage(
type: "subscribe_events",
additionalData: {"event_type": "state_changed"},
));
Future.wait(futures).then((_) { Future.wait(futures).then((_) {
if (isMobileAppEnabled) { if (isMobileAppEnabled) {
if (!childMode) _createUI(); if (!childMode) _createUI();
@ -108,6 +104,7 @@ class HomeAssistant {
Future _getLovelace() { Future _getLovelace() {
Completer completer = Completer(); Completer completer = Completer();
ConnectionManager().sendSocketMessage(type: "lovelace/config").then((data) { ConnectionManager().sendSocketMessage(type: "lovelace/config").then((data) {
_rawLovelaceData = data; _rawLovelaceData = data;
completer.complete(); completer.complete();
@ -163,7 +160,7 @@ class HomeAssistant {
void _handleEntityStateChange(Map eventData) { void _handleEntityStateChange(Map eventData) {
//TheLogger.debug( "New state for ${eventData['entity_id']}"); //TheLogger.debug( "New state for ${eventData['entity_id']}");
if (_fetchCompleter.isCompleted) { if (_fetchCompleter != null && _fetchCompleter.isCompleted) {
Map data = Map.from(eventData); Map data = Map.from(eventData);
eventBus.fire(new StateChangedEvent( eventBus.fire(new StateChangedEvent(
entityId: data["entity_id"], entityId: data["entity_id"],

View File

@ -143,7 +143,7 @@ final SentryClient _sentry = SentryClient(dsn: "https://03ef364745cc4c23a60ddbc8
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
const String appName = "HA Client"; const String appName = "HA Client";
const appVersionNumber = "0.7.6"; const appVersionNumber = "0.7.7";
const appVersionAdd = ""; const appVersionAdd = "";
const appVersion = "$appVersionNumber$appVersionAdd"; const appVersion = "$appVersionNumber$appVersionAdd";

View File

@ -148,11 +148,17 @@ class ConnectionManager {
}); });
} else if (data["type"] == "auth_ok") { } else if (data["type"] == "auth_ok") {
Logger.d("[Received] <== ${data.toString()}"); Logger.d("[Received] <== ${data.toString()}");
Logger.d("[Connection] Subscribing to events");
sendSocketMessage(
type: "subscribe_events",
additionalData: {"event_type": "state_changed"},
).whenComplete((){
_messageResolver["auth"]?.complete(); _messageResolver["auth"]?.complete();
_messageResolver.remove("auth"); _messageResolver.remove("auth");
if (_token != null) { if (_token != null) {
if (!connecting.isCompleted) connecting.complete(); if (!connecting.isCompleted) connecting.complete();
} }
});
} else if (data["type"] == "auth_invalid") { } else if (data["type"] == "auth_invalid") {
Logger.d("[Received] <== ${data.toString()}"); Logger.d("[Received] <== ${data.toString()}");
_messageResolver["auth"]?.completeError(HAError("${data["message"]}", actions: [HAErrorAction.loginAgain()])); _messageResolver["auth"]?.completeError(HAError("${data["message"]}", actions: [HAErrorAction.loginAgain()]));

View File

@ -149,15 +149,14 @@ class LocationManager {
void updateDeviceLocationIsolate() { void updateDeviceLocationIsolate() {
workManager.Workmanager.executeTask((backgroundTask, data) { workManager.Workmanager.executeTask((backgroundTask, data) {
print("[Background $backgroundTask] Started"); //print("[Background $backgroundTask] Started");
final SentryClient sentryBackgroundClient = SentryClient(dsn: "https://5c868e5ef26947e2b61b189e391ec31b@sentry.io/1836366");
Geolocator geolocator = Geolocator(); Geolocator geolocator = Geolocator();
var battery = Battery(); var battery = Battery();
int batteryLevel = 100; int batteryLevel = 100;
String webhookId = data["webhookId"]; String webhookId = data["webhookId"];
String httpWebHost = data["httpWebHost"]; String httpWebHost = data["httpWebHost"];
if (webhookId != null && webhookId.isNotEmpty) { if (webhookId != null && webhookId.isNotEmpty) {
print("[Background $backgroundTask] hour=$battery"); //print("[Background $backgroundTask] hour=$battery");
String url = "$httpWebHost/api/webhook/$webhookId"; String url = "$httpWebHost/api/webhook/$webhookId";
Map<String, String> headers = {}; Map<String, String> headers = {};
headers["Content-Type"] = "application/json"; headers["Content-Type"] = "application/json";
@ -169,15 +168,15 @@ void updateDeviceLocationIsolate() {
"battery": batteryLevel "battery": batteryLevel
} }
}; };
print("[Background $backgroundTask] Getting battery level..."); //print("[Background $backgroundTask] Getting battery level...");
battery.batteryLevel.then((val) => data["data"]["battery"] = val).whenComplete((){ battery.batteryLevel.then((val) => data["data"]["battery"] = val).whenComplete((){
print("[Background $backgroundTask] Getting device location..."); //print("[Background $backgroundTask] Getting device location...");
geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high, locationPermissionLevel: GeolocationPermission.locationAlways).then((location) { geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high, locationPermissionLevel: GeolocationPermission.locationAlways).then((location) {
if (location != null) { if (location != null) {
print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}"); //print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}");
data["data"]["gps"] = [location.latitude, location.longitude]; data["data"]["gps"] = [location.latitude, location.longitude];
data["data"]["gps_accuracy"] = location.accuracy; data["data"]["gps_accuracy"] = location.accuracy;
print("[Background $backgroundTask] Sending data home."); //print("[Background $backgroundTask] Sending data home.");
http.post( http.post(
url, url,
headers: headers, headers: headers,
@ -187,10 +186,7 @@ void updateDeviceLocationIsolate() {
throw "Can't get device location. Location is null"; throw "Can't get device location. Location is null";
} }
}).catchError((e) { }).catchError((e) {
sentryBackgroundClient.captureException( //print("[Background $backgroundTask] Error getting current location: ${e.toString()}");
exception: "${e.toString()}"
);
print("[Background $backgroundTask] Error getting current location: ${e.toString()}");
}); });
}); });
} }

View File

@ -139,12 +139,6 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
} }
await HomeAssistant().fetchData().then((_) { await HomeAssistant().fetchData().then((_) {
_hideBottomBar(); _hideBottomBar();
int currentViewCount = HomeAssistant().ui?.views?.length ?? 0;
if (_previousViewCount != currentViewCount) {
Logger.d("Views count changed ($_previousViewCount->$currentViewCount). Creating new tabs controller.");
_viewsTabController = TabController(vsync: this, length: currentViewCount);
_previousViewCount = currentViewCount;
}
if (_entityToShow != null) { if (_entityToShow != null) {
_entityToShow = HomeAssistant().entities.get(_entityToShow.entityId); _entityToShow = HomeAssistant().entities.get(_entityToShow.entityId);
} }
@ -464,11 +458,11 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
}, },
), ),
new ListTile( new ListTile(
leading: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:discord")), leading: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:forum")),
title: Text("Join Discord channel"), title: Text("Contacts/Discussion"),
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
Launcher.launchURL("https://discord.gg/AUzEvwn"); Launcher.launchURL("https://spectrum.chat/ha-client");
}, },
), ),
new AboutListTile( new AboutListTile(
@ -643,6 +637,13 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
List<PopupMenuItem<String>> serviceMenuItems = []; List<PopupMenuItem<String>> serviceMenuItems = [];
List<PopupMenuItem<String>> mediaMenuItems = []; List<PopupMenuItem<String>> mediaMenuItems = [];
int currentViewCount = HomeAssistant().ui?.views?.length ?? 0;
if (_previousViewCount != currentViewCount) {
Logger.d("Views count changed ($_previousViewCount->$currentViewCount). Creating new tabs controller.");
_viewsTabController = TabController(vsync: this, length: currentViewCount);
_previousViewCount = currentViewCount;
}
serviceMenuItems.add(PopupMenuItem<String>( serviceMenuItems.add(PopupMenuItem<String>(
child: new Text("Reload"), child: new Text("Reload"),
value: "reload", value: "reload",

View File

@ -1,7 +1,7 @@
name: hass_client name: hass_client
description: Home Assistant Android Client description: Home Assistant Android Client
version: 0.7.6+760 version: 0.7.7+770
environment: environment: