Compare commits
6 Commits
beta/0.7.1
...
beta/0.7.2
Author | SHA1 | Date | |
---|---|---|---|
139533d2ca | |||
889682f771 | |||
f16c98057f | |||
26ec807c25 | |||
45af6cbe3c | |||
5dd9cde12d |
@ -431,14 +431,10 @@ class _MediaPlayerControlsState extends State<MediaPlayerControls> {
|
|||||||
|
|
||||||
void _duplicateTo(entity) {
|
void _duplicateTo(entity) {
|
||||||
HomeAssistant().savedPlayerPosition = entity.getActualPosition().toInt();
|
HomeAssistant().savedPlayerPosition = entity.getActualPosition().toInt();
|
||||||
if (MediaQuery.of(context).size.width < Sizes.tabletMinWidth) {
|
Navigator.of(context).pushNamed("/play-media", arguments: {
|
||||||
Navigator.of(context).popAndPushNamed("/play-media", arguments: {"url": entity.attributes["media_content_id"], "type": entity.attributes["media_content_type"]});
|
|
||||||
} else {
|
|
||||||
Navigator.of(context).pushNamed("/play-media", arguments: {
|
|
||||||
"url": entity.attributes["media_content_id"],
|
"url": entity.attributes["media_content_id"],
|
||||||
"type": entity.attributes["media_content_type"]
|
"type": entity.attributes["media_content_type"]
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _switchTo(entity) {
|
void _switchTo(entity) {
|
||||||
|
@ -180,9 +180,17 @@ class HomeAssistant {
|
|||||||
|
|
||||||
if (rawView['badges'] != null && rawView['badges'] is List) {
|
if (rawView['badges'] != null && rawView['badges'] is List) {
|
||||||
rawView['badges'].forEach((entity) {
|
rawView['badges'].forEach((entity) {
|
||||||
if (entities.isExist(entity)) {
|
if (entity is String) {
|
||||||
Entity e = entities.get(entity);
|
if (entities.isExist(entity)) {
|
||||||
view.badges.add(e);
|
Entity e = entities.get(entity);
|
||||||
|
view.badges.add(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String eId = '${entity['entity']}';
|
||||||
|
if (entities.isExist(eId)) {
|
||||||
|
Entity e = entities.get(eId);
|
||||||
|
view.badges.add(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -141,8 +141,8 @@ EventBus eventBus = new EventBus();
|
|||||||
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.1";
|
const appVersionNumber = "0.7.2";
|
||||||
const appVersionAdd = "alpha1";
|
const appVersionAdd = "";
|
||||||
const appVersion = "$appVersionNumber-$appVersionAdd";
|
const appVersion = "$appVersionNumber-$appVersionAdd";
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
@ -350,6 +350,7 @@ class ConnectionManager {
|
|||||||
|
|
||||||
Future callService(String domain, String service, String entityId, Map additionalServiceData) {
|
Future callService(String domain, String service, String entityId, Map additionalServiceData) {
|
||||||
eventBus.fire(NotifyServiceCallEvent(domain, service, entityId));
|
eventBus.fire(NotifyServiceCallEvent(domain, service, entityId));
|
||||||
|
Logger.d("Service call: $domain.$service, $entityId, $additionalServiceData");
|
||||||
Completer completer = Completer();
|
Completer completer = Completer();
|
||||||
Map serviceData = {};
|
Map serviceData = {};
|
||||||
if (entityId != null) {
|
if (entityId != null) {
|
||||||
@ -367,7 +368,7 @@ class ConnectionManager {
|
|||||||
else
|
else
|
||||||
sendHTTPPost(
|
sendHTTPPost(
|
||||||
endPoint: "/api/services/$domain/$service"
|
endPoint: "/api/services/$domain/$service"
|
||||||
).then((data) => completer.complete(data)).catchError((e) => completer.completeError(HAError("${e["message"]}")));;
|
).then((data) => completer.complete(data)).catchError((e) => completer.completeError(HAError("${e["message"]}")));
|
||||||
//return sendSocketMessage(type: "call_service", additionalData: {"domain": domain, "service": service});
|
//return sendSocketMessage(type: "call_service", additionalData: {"domain": domain, "service": service});
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
@ -408,10 +409,11 @@ class ConnectionManager {
|
|||||||
headers: headers,
|
headers: headers,
|
||||||
body: data
|
body: data
|
||||||
).then((response) {
|
).then((response) {
|
||||||
Logger.d("[Received] <== HTTP ${response.statusCode}");
|
|
||||||
if (response.statusCode >= 200 && response.statusCode < 300 ) {
|
if (response.statusCode >= 200 && response.statusCode < 300 ) {
|
||||||
|
Logger.d("[Received] <== HTTP ${response.statusCode}");
|
||||||
completer.complete(response.body);
|
completer.complete(response.body);
|
||||||
} else {
|
} else {
|
||||||
|
Logger.d("[Received] <== HTTP ${response.statusCode}: ${response.body}");
|
||||||
completer.completeError({"code": response.statusCode, "message": "${response.body}"});
|
completer.completeError({"code": response.statusCode, "message": "${response.body}"});
|
||||||
}
|
}
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
|
@ -87,32 +87,57 @@ class LocationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateDeviceLocation() async {
|
updateDeviceLocation() async {
|
||||||
if (ConnectionManager().webhookId != null &&
|
Logger.d("[Test location] Started");
|
||||||
ConnectionManager().webhookId.isNotEmpty) {
|
Logger.d("[Test location] Forcing Android location manager...");
|
||||||
String url = "${ConnectionManager()
|
Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
|
||||||
.httpWebHost}/api/webhook/${ConnectionManager().webhookId}";
|
var battery = Battery();
|
||||||
|
int batteryLevel = 100;
|
||||||
|
String webhookId = ConnectionManager().webhookId;
|
||||||
|
String httpWebHost = ConnectionManager().httpWebHost;
|
||||||
|
if (webhookId != null && webhookId.isNotEmpty) {
|
||||||
|
String url = "$httpWebHost/api/webhook/$webhookId";
|
||||||
Map<String, String> headers = {};
|
Map<String, String> headers = {};
|
||||||
Logger.d("[Location] Getting device location...");
|
headers["Content-Type"] = "application/json";
|
||||||
Position location = await Geolocator().getCurrentPosition(
|
Map data = {
|
||||||
desiredAccuracy: LocationAccuracy.medium);
|
|
||||||
Logger.d("[Location] Got location: ${location.latitude} ${location
|
|
||||||
.longitude}. Sending home...");
|
|
||||||
int battery = await Battery().batteryLevel;
|
|
||||||
var data = {
|
|
||||||
"type": "update_location",
|
"type": "update_location",
|
||||||
"data": {
|
"data": {
|
||||||
"gps": [location.latitude, location.longitude],
|
"gps": [],
|
||||||
"gps_accuracy": location.accuracy,
|
"gps_accuracy": 0,
|
||||||
"battery": battery
|
"battery": batteryLevel
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
headers["Content-Type"] = "application/json";
|
Logger.d("[Test location] Getting battery level...");
|
||||||
await http.post(
|
battery.batteryLevel.then((val) => data["data"]["battery"] = val).whenComplete((){
|
||||||
url,
|
Logger.d("[Test location] Getting device location...");
|
||||||
headers: headers,
|
geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high, locationPermissionLevel: GeolocationPermission.locationAlways).then((location) {
|
||||||
body: json.encode(data)
|
Logger.d("[Test location] Got location: ${location.latitude} ${location.longitude} with accuracy of ${location.accuracy}");
|
||||||
);
|
if (location != null) {
|
||||||
Logger.d("[Location] ...done.");
|
data["data"]["gps"] = [location.latitude, location.longitude];
|
||||||
|
data["data"]["gps_accuracy"] = location.accuracy;
|
||||||
|
Logger.d("[Test location] Sending data home...");
|
||||||
|
http.post(
|
||||||
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: json.encode(data)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}).catchError((e) {
|
||||||
|
Logger.d("[Test location] Error getting current location: ${e.toString()}. Trying last known...");
|
||||||
|
geolocator.getLastKnownPosition(desiredAccuracy: LocationAccuracy.medium).then((location){
|
||||||
|
Logger.d("[Test location] Got last known location: ${location.latitude} ${location.longitude} with accuracy of ${location.accuracy}");
|
||||||
|
if (location != null) {
|
||||||
|
data["data"]["gps"] = [location.latitude, location.longitude];
|
||||||
|
data["data"]["gps_accuracy"] = location.accuracy;
|
||||||
|
Logger.d("[Test location] Sending data home...");
|
||||||
|
http.post(
|
||||||
|
url,
|
||||||
|
headers: headers,
|
||||||
|
body: json.encode(data)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +146,7 @@ class LocationManager {
|
|||||||
void updateDeviceLocationIsolate() {
|
void updateDeviceLocationIsolate() {
|
||||||
workManager.Workmanager.executeTask((backgroundTask, data) {
|
workManager.Workmanager.executeTask((backgroundTask, data) {
|
||||||
//print("[Background $backgroundTask] Started");
|
//print("[Background $backgroundTask] Started");
|
||||||
|
Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
|
||||||
var battery = Battery();
|
var battery = Battery();
|
||||||
int batteryLevel = 100;
|
int batteryLevel = 100;
|
||||||
String webhookId = data["webhookId"];
|
String webhookId = data["webhookId"];
|
||||||
@ -141,7 +167,7 @@ void updateDeviceLocationIsolate() {
|
|||||||
//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.medium).then((location) {
|
geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high, locationPermissionLevel: GeolocationPermission.locationAlways).then((location) {
|
||||||
//print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}");
|
//print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}");
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
data["data"]["gps"] = [location.latitude, location.longitude];
|
data["data"]["gps"] = [location.latitude, location.longitude];
|
||||||
@ -155,7 +181,7 @@ void updateDeviceLocationIsolate() {
|
|||||||
}
|
}
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
//print("[Background $backgroundTask] Error getting current location: ${e.toString()}. Trying last known...");
|
//print("[Background $backgroundTask] Error getting current location: ${e.toString()}. Trying last known...");
|
||||||
Geolocator().getLastKnownPosition(desiredAccuracy: LocationAccuracy.medium).then((location){
|
geolocator.getLastKnownPosition(desiredAccuracy: LocationAccuracy.medium).then((location){
|
||||||
//print("[Background $backgroundTask] Got last known location: ${location.latitude} ${location.longitude}");
|
//print("[Background $backgroundTask] Got last known location: ${location.latitude} ${location.longitude}");
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
data["data"]["gps"] = [location.latitude, location.longitude];
|
data["data"]["gps"] = [location.latitude, location.longitude];
|
||||||
|
@ -889,9 +889,7 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
),
|
),
|
||||||
onWillPop: () {
|
onWillPop: () {
|
||||||
if (_entityToShow != null) {
|
if (_entityToShow != null) {
|
||||||
setState(() {
|
eventBus.fire(ShowEntityPageEvent());
|
||||||
_entityToShow = null;
|
|
||||||
});
|
|
||||||
return Future.value(false);
|
return Future.value(false);
|
||||||
} else {
|
} else {
|
||||||
return Future.value(true);
|
return Future.value(true);
|
||||||
|
@ -90,8 +90,8 @@ class _PlayMediaPageState extends State<PlayMediaPage> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
ConnectionManager().callService(
|
ConnectionManager().callService(
|
||||||
serviceDomain,
|
serviceDomain,
|
||||||
entity.entityId,
|
|
||||||
"play_media",
|
"play_media",
|
||||||
|
entity.entityId,
|
||||||
{
|
{
|
||||||
"media_content_id": _mediaUrl,
|
"media_content_id": _mediaUrl,
|
||||||
"media_content_type": _contentType
|
"media_content_type": _contentType
|
||||||
|
@ -24,7 +24,7 @@ class _WhatsNewPageState extends State<WhatsNewPage> {
|
|||||||
error = "";
|
error = "";
|
||||||
});
|
});
|
||||||
http.Response response;
|
http.Response response;
|
||||||
response = await http.get("http://ha-client.homemade.systems/service/whats_new_$appVersionNumber.md");
|
response = await http.get("http://ha-client.homemade.systems/service/whats_new_0.7.0.md");
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
setState(() {
|
setState(() {
|
||||||
data = response.body;
|
data = response.body;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: hass_client
|
name: hass_client
|
||||||
description: Home Assistant Android Client
|
description: Home Assistant Android Client
|
||||||
|
|
||||||
version: 0.7.1+712
|
version: 0.7.2+720
|
||||||
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
Reference in New Issue
Block a user