Resolves #523 Change device name for integration
This commit is contained in:
@ -14,9 +14,6 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
int _locationInterval = LocationManager().defaultUpdateIntervalMinutes;
|
||||
bool _locationTrackingEnabled = false;
|
||||
bool _wait = false;
|
||||
String _deviceName = '';
|
||||
bool _applyNameEnabled = false;
|
||||
String _newDeviceName = '';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -30,7 +27,6 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
await prefs.reload();
|
||||
SharedPreferences.getInstance().then((prefs) {
|
||||
setState(() {
|
||||
_deviceName = _newDeviceName = ConnectionManager().mobileAppDeviceName ?? MobileAppIntegrationManager.getDefaultDeviceName();
|
||||
_locationTrackingEnabled = prefs.getBool("location-enabled") ?? false;
|
||||
_locationInterval = prefs.getInt("location-interval") ?? LocationManager().defaultUpdateIntervalMinutes;
|
||||
if (_locationInterval % 5 != 0) {
|
||||
@ -40,7 +36,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
});
|
||||
}
|
||||
|
||||
void incLocationInterval() {
|
||||
void _incLocationInterval() {
|
||||
if (_locationInterval < 720) {
|
||||
setState(() {
|
||||
_locationInterval = _locationInterval + 5;
|
||||
@ -48,7 +44,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
void decLocationInterval() {
|
||||
void _decLocationInterval() {
|
||||
if (_locationInterval > 5) {
|
||||
setState(() {
|
||||
_locationInterval = _locationInterval - 5;
|
||||
@ -56,52 +52,6 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
restart() {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
title: "Are you sure you want to restart Home Assistant?",
|
||||
body: "This will restart your Home Assistant server.",
|
||||
positiveText: "Sure. Make it so",
|
||||
negativeText: "What?? No!",
|
||||
onPositive: () {
|
||||
ConnectionManager().callService(domain: "homeassistant", service: "restart");
|
||||
}
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
stop() {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
title: "Are you sure you want 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: () {
|
||||
ConnectionManager().callService(domain: "homeassistant", service: "stop");
|
||||
},
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
updateRegistration() {
|
||||
MobileAppIntegrationManager.checkAppRegistration(showOkDialog: true);
|
||||
}
|
||||
|
||||
resetRegistration() {
|
||||
eventBus.fire(ShowPopupEvent(
|
||||
Popup(
|
||||
title: "Waaaait",
|
||||
body: "If you don't whant to have duplicate integrations and entities in your HA for your current device, first you need to remove MobileApp integration from Integration settings in HA and restart server.",
|
||||
positiveText: "Done it already",
|
||||
negativeText: "Ok, I will",
|
||||
onPositive: () {
|
||||
MobileAppIntegrationManager.checkAppRegistration(showOkDialog: true, forceRegister: true);
|
||||
},
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
_switchLocationTrackingState(bool state) async {
|
||||
if (state) {
|
||||
await LocationManager().updateDeviceLocation();
|
||||
@ -156,37 +106,16 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
FlatButton(
|
||||
padding: EdgeInsets.all(0.0),
|
||||
child: Text("-", style: Theme.of(context).textTheme.title),
|
||||
onPressed: () => decLocationInterval(),
|
||||
onPressed: () => _decLocationInterval(),
|
||||
),
|
||||
Text("$_locationInterval", style: Theme.of(context).textTheme.title),
|
||||
FlatButton(
|
||||
padding: EdgeInsets.all(0.0),
|
||||
child: Text("+", style: Theme.of(context).textTheme.title),
|
||||
onPressed: () => incLocationInterval(),
|
||||
onPressed: () => _incLocationInterval(),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
Text("Device name", style: Theme.of(context).textTheme.title),
|
||||
Container(height: Sizes.rowPadding,),
|
||||
TextField(
|
||||
/*decoration: InputDecoration(
|
||||
labelText: "Long-lived token"
|
||||
),*/
|
||||
controller: TextEditingController.fromValue(TextEditingValue(text: _newDeviceName)),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_newDeviceName = value;
|
||||
_applyNameEnabled = _newDeviceName != _deviceName;
|
||||
});
|
||||
}
|
||||
),
|
||||
Container(height: 6.0,),
|
||||
RaisedButton(
|
||||
color: Colors.blue,
|
||||
onPressed: () => _applyNameEnabled ? updateRegistration() : null,
|
||||
child: Text("Update device name", style: Theme.of(context).textTheme.button)
|
||||
),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user