This commit is contained in:
estevez-dev
2019-06-21 12:53:03 +03:00
parent c7fc5afbb8
commit 3417c38426
2 changed files with 33 additions and 43 deletions

View File

@ -122,8 +122,8 @@ class HomeAssistant {
Connection().webhookId = responseObject["webhook_id"]; Connection().webhookId = responseObject["webhook_id"];
completer.complete(); completer.complete();
eventBus.fire(ShowDialogEvent( eventBus.fire(ShowDialogEvent(
title: "App was registered with your Home Assistant", title: "Mobile app Integration was created",
body: "To start using notifications you need to restart your Home Assistant", body: "HA Client was registered as MobileApp in your Home Assistant. To start using notifications you need to restart your Home Assistant",
positiveText: "Restart now", positiveText: "Restart now",
negativeText: "Later", negativeText: "Later",
onPositive: () { onPositive: () {

View File

@ -38,17 +38,13 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
Row( Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
FlatServiceButton( FlatButton(
text: "Restart", child: Text('Restart', style: TextStyle(color: Colors.blue)),
serviceName: "restart", onPressed: () => restart(),
serviceDomain: "homeassistant",
entityId: null,
), ),
FlatServiceButton( FlatButton(
text: "Stop", child: Text("Stop", style: TextStyle(color: Colors.blue)),
serviceName: "stop", onPressed: () => stop(),
serviceDomain: "homeassistant",
entityId: null,
), ),
], ],
) )
@ -68,18 +64,14 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
Container(height: Sizes.rowPadding,), Container(height: Sizes.rowPadding,),
Text("${HomeAssistant().userName}'s ${Device().model}, ${Device().osName} ${Device().osVersion}"), Text("${HomeAssistant().userName}'s ${Device().model}, ${Device().osName} ${Device().osVersion}"),
Container(height: 6.0,), Container(height: 6.0,),
Text("Reseting mobile app registration will not remove integration from Home Assistant but creates a new one with different device. If you want to reset mobile app registration completally you need to remove MobileApp from Configuretion -> Integrations of your Home Assistant."), Text("Here you can manually check if HA Client integration with your Home Assistant works fine."),
Divider(), Divider(),
Row( Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
FlatButton(
onPressed: () => resetRegistration(),
child: Text("Reset registration")
),
FlatButton( FlatButton(
onPressed: () => updateRegistration(), onPressed: () => updateRegistration(),
child: Text("Update registration") child: Text("Check registration", style: TextStyle(color: Colors.blue))
) )
], ],
) )
@ -90,34 +82,32 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
]; ];
} }
resetRegistration() { restart() {
HomeAssistant().checkAppRegistration(forceRegister: true).then((_) {
Navigator.of(context).pop();
eventBus.fire(ShowDialogEvent( eventBus.fire(ShowDialogEvent(
title: "App registered", title: "Are you sure you want to restart Home Assistant?",
body: "To start using notifications you need to restart your Home Assistant", body: "This will restart your Home Assistant server.",
positiveText: "Restart now", positiveText: "Sure. Make it so",
negativeText: "Later", negativeText: "What?? No!",
onPositive: () { onPositive: () {
Connection().callService(domain: "homeassistant", service: "restart", entityId: null); Connection().callService(domain: "homeassistant", service: "restart", entityId: null);
}, },
)); ));
}); }
stop() {
eventBus.fire(ShowDialogEvent(
title: "Are you sure you wanr to STOP Home Assistant?",
body: "This will STOP your Home Assistant server. It means that your web interface as well as HA Client will not work untill you'll find a way to start your server using ssh or something.",
positiveText: "Sure. Make it so",
negativeText: "What?? No!",
onPositive: () {
Connection().callService(domain: "homeassistant", service: "stop", entityId: null);
},
));
} }
updateRegistration() { updateRegistration() {
HomeAssistant().checkAppRegistration().then((_) { HomeAssistant().checkAppRegistration();
//Navigator.of(context).pop();
/*eventBus.fire(ShowDialogEvent(
title: "App registration updated",
body: "To start using notifications you need to restart your Home Assistant",
positiveText: "Restart now",
negativeText: "Later",
onPositive: () {
Connection().callService(domain: "homeassistant", service: "restart", entityId: null);
},
));*/
});
} }
@override @override