Pre release/0.7.1 #488
@ -25,9 +25,12 @@ class _AlarmControlPanelControlsWidgetWidgetState extends State<AlarmControlPane
|
|||||||
|
|
||||||
|
|
||||||
void _callService(AlarmControlPanelEntity entity, String service) {
|
void _callService(AlarmControlPanelEntity entity, String service) {
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, service, entity.entityId,
|
entity.domain,
|
||||||
{"code": "$code"}));
|
service,
|
||||||
|
entity.entityId,
|
||||||
|
{"code": "$code"}
|
||||||
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
code = "";
|
code = "";
|
||||||
});
|
});
|
||||||
@ -58,7 +61,12 @@ class _AlarmControlPanelControlsWidgetWidgetState extends State<AlarmControlPane
|
|||||||
FlatButton(
|
FlatButton(
|
||||||
child: new Text("Yes"),
|
child: new Text("Yes"),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "alarm_trigger", entity.entityId, null));
|
ConnectionManager().callService(
|
||||||
|
entity.domain,
|
||||||
|
"alarm_trigger",
|
||||||
|
entity.entityId,
|
||||||
|
null
|
||||||
|
);
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -83,7 +83,12 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
_tempThrottleTimer = Timer(Duration(seconds: 2), () {
|
_tempThrottleTimer = Timer(Duration(seconds: 2), () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_temperature", entity.entityId,{"temperature": "${_tmpTemperature.toStringAsFixed(1)}"}));
|
ConnectionManager().callService(
|
||||||
|
entity.domain,
|
||||||
|
"set_temperature",
|
||||||
|
entity.entityId,
|
||||||
|
{"temperature": "${_tmpTemperature.toStringAsFixed(1)}"}
|
||||||
|
);
|
||||||
_resetStateTimer(entity);
|
_resetStateTimer(entity);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -101,7 +106,12 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
_targetTempThrottleTimer = Timer(Duration(seconds: 2), () {
|
_targetTempThrottleTimer = Timer(Duration(seconds: 2), () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_temperature", entity.entityId,{"target_temp_high": "${_tmpTargetHigh.toStringAsFixed(1)}", "target_temp_low": "${_tmpTargetLow.toStringAsFixed(1)}"}));
|
ConnectionManager().callService(
|
||||||
|
entity.domain,
|
||||||
|
"set_temperature",
|
||||||
|
entity.entityId,
|
||||||
|
{"target_temp_high": "${_tmpTargetHigh.toStringAsFixed(1)}", "target_temp_low": "${_tmpTargetLow.toStringAsFixed(1)}"}
|
||||||
|
);
|
||||||
_resetStateTimer(entity);
|
_resetStateTimer(entity);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -111,7 +121,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpTargetHumidity = value.roundToDouble();
|
_tmpTargetHumidity = value.roundToDouble();
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_humidity", entity.entityId,{"humidity": "$_tmpTargetHumidity"}));
|
ConnectionManager().callService(entity.domain, "set_humidity", entity.entityId, {"humidity": "$_tmpTargetHumidity"});
|
||||||
_resetStateTimer(entity);
|
_resetStateTimer(entity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -120,7 +130,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpHVACMode = value;
|
_tmpHVACMode = value;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_hvac_mode", entity.entityId,{"hvac_mode": "$_tmpHVACMode"}));
|
ConnectionManager().callService(entity.domain, "set_hvac_mode", entity.entityId, {"hvac_mode": "$_tmpHVACMode"});
|
||||||
_resetStateTimer(entity);
|
_resetStateTimer(entity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -129,7 +139,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpSwingMode = value;
|
_tmpSwingMode = value;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_swing_mode", entity.entityId,{"swing_mode": "$_tmpSwingMode"}));
|
ConnectionManager().callService(entity.domain, "set_swing_mode", entity.entityId, {"swing_mode": "$_tmpSwingMode"});
|
||||||
_resetStateTimer(entity);
|
_resetStateTimer(entity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -138,7 +148,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpFanMode = value;
|
_tmpFanMode = value;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_fan_mode", entity.entityId,{"fan_mode": "$_tmpFanMode"}));
|
ConnectionManager().callService(entity.domain, "set_fan_mode", entity.entityId, {"fan_mode": "$_tmpFanMode"});
|
||||||
_resetStateTimer(entity);
|
_resetStateTimer(entity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -147,7 +157,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpPresetMode = value;
|
_tmpPresetMode = value;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_preset_mode", entity.entityId,{"preset_mode": "$_tmpPresetMode"}));
|
ConnectionManager().callService(entity.domain, "set_preset_mode", entity.entityId, {"preset_mode": "$_tmpPresetMode"});
|
||||||
_resetStateTimer(entity);
|
_resetStateTimer(entity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -165,7 +175,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpAuxHeat = value;
|
_tmpAuxHeat = value;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_aux_heat", entity.entityId, {"aux_heat": "$_tmpAuxHeat"}));
|
ConnectionManager().callService(entity.domain, "set_aux_heat", entity.entityId, {"aux_heat": "$_tmpAuxHeat"});
|
||||||
_resetStateTimer(entity);
|
_resetStateTimer(entity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class _CoverControlWidgetState extends State<CoverControlWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpPosition = position.roundToDouble();
|
_tmpPosition = position.roundToDouble();
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_cover_position", entity.entityId,{"position": _tmpPosition.round()}));
|
ConnectionManager().callService(entity.domain, "set_cover_position", entity.entityId,{"position": _tmpPosition.round()});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ class _CoverControlWidgetState extends State<CoverControlWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpTiltPosition = position.roundToDouble();
|
_tmpTiltPosition = position.roundToDouble();
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(entity.domain, "set_cover_tilt_position", entity.entityId,{"tilt_position": _tmpTiltPosition.round()}));
|
ConnectionManager().callService(entity.domain, "set_cover_tilt_position", entity.entityId,{"tilt_position": _tmpTiltPosition.round()});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,18 +135,18 @@ class _CoverControlWidgetState extends State<CoverControlWidget> {
|
|||||||
|
|
||||||
class CoverTiltControlsWidget extends StatelessWidget {
|
class CoverTiltControlsWidget extends StatelessWidget {
|
||||||
void _open(CoverEntity entity) {
|
void _open(CoverEntity entity) {
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "open_cover_tilt", entity.entityId, null));
|
entity.domain, "open_cover_tilt", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _close(CoverEntity entity) {
|
void _close(CoverEntity entity) {
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "close_cover_tilt", entity.entityId, null));
|
entity.domain, "close_cover_tilt", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _stop(CoverEntity entity) {
|
void _stop(CoverEntity entity) {
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "stop_cover_tilt", entity.entityId, null));
|
entity.domain, "stop_cover_tilt", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -2,18 +2,18 @@ part of '../../../main.dart';
|
|||||||
|
|
||||||
class CoverStateWidget extends StatelessWidget {
|
class CoverStateWidget extends StatelessWidget {
|
||||||
void _open(CoverEntity entity) {
|
void _open(CoverEntity entity) {
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "open_cover", entity.entityId, null));
|
entity.domain, "open_cover", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _close(CoverEntity entity) {
|
void _close(CoverEntity entity) {
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "close_cover", entity.entityId, null));
|
entity.domain, "close_cover", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _stop(CoverEntity entity) {
|
void _stop(CoverEntity entity) {
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "stop_cover", entity.entityId, null));
|
entity.domain, "stop_cover", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -35,8 +35,7 @@ class DateTimeEntity extends Entity {
|
|||||||
return formattedState;
|
return formattedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNewState(newValue) {
|
void setNewState(Map newValue) {
|
||||||
eventBus
|
ConnectionManager().callService(domain, "set_datetime", entityId, newValue);
|
||||||
.fire(new ServiceCallEvent(domain, "set_datetime", entityId, newValue));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ class EntityPageLayout extends StatelessWidget {
|
|||||||
showClose ?
|
showClose ?
|
||||||
Container(
|
Container(
|
||||||
color: Colors.blue[300],
|
color: Colors.blue[300],
|
||||||
height: 36,
|
height: 40,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -37,7 +37,7 @@ class EntityPageLayout extends StatelessWidget {
|
|||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
icon: Icon(Icons.close),
|
icon: Icon(Icons.close),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
iconSize: 30.0,
|
iconSize: 36.0,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
eventBus.fire(ShowEntityPageEvent());
|
eventBus.fire(ShowEntityPageEvent());
|
||||||
},
|
},
|
||||||
|
@ -32,17 +32,15 @@ class EntityWrapper {
|
|||||||
void handleTap() {
|
void handleTap() {
|
||||||
switch (uiAction.tapAction) {
|
switch (uiAction.tapAction) {
|
||||||
case EntityUIAction.toggle: {
|
case EntityUIAction.toggle: {
|
||||||
eventBus.fire(
|
ConnectionManager().callService("homeassistant", "toggle", entity.entityId, null);
|
||||||
ServiceCallEvent("homeassistant", "toggle", entity.entityId, null));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EntityUIAction.callService: {
|
case EntityUIAction.callService: {
|
||||||
if (uiAction.tapService != null) {
|
if (uiAction.tapService != null) {
|
||||||
eventBus.fire(
|
ConnectionManager().callService(uiAction.tapService.split(".")[0],
|
||||||
ServiceCallEvent(uiAction.tapService.split(".")[0],
|
|
||||||
uiAction.tapService.split(".")[1], null,
|
uiAction.tapService.split(".")[1], null,
|
||||||
uiAction.tapServiceData));
|
uiAction.tapServiceData);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -76,17 +74,15 @@ class EntityWrapper {
|
|||||||
void handleHold() {
|
void handleHold() {
|
||||||
switch (uiAction.holdAction) {
|
switch (uiAction.holdAction) {
|
||||||
case EntityUIAction.toggle: {
|
case EntityUIAction.toggle: {
|
||||||
eventBus.fire(
|
ConnectionManager().callService("homeassistant", "toggle", entity.entityId, null);
|
||||||
ServiceCallEvent("homeassistant", "toggle", entity.entityId, null));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EntityUIAction.callService: {
|
case EntityUIAction.callService: {
|
||||||
if (uiAction.holdService != null) {
|
if (uiAction.holdService != null) {
|
||||||
eventBus.fire(
|
ConnectionManager().callService(uiAction.holdService.split(".")[0],
|
||||||
ServiceCallEvent(uiAction.holdService.split(".")[0],
|
|
||||||
uiAction.holdService.split(".")[1], null,
|
uiAction.holdService.split(".")[1], null,
|
||||||
uiAction.holdServiceData));
|
uiAction.holdServiceData);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@ class _FanControlsWidgetState extends State<FanControlsWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpOscillate = oscillate;
|
_tmpOscillate = oscillate;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
"fan", "oscillate", entity.entityId,
|
"fan", "oscillate", entity.entityId,
|
||||||
{"oscillating": oscillate}));
|
{"oscillating": oscillate});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,9 +34,9 @@ class _FanControlsWidgetState extends State<FanControlsWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpDirectionForward = forward;
|
_tmpDirectionForward = forward;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
"fan", "set_direction", entity.entityId,
|
"fan", "set_direction", entity.entityId,
|
||||||
{"direction": forward ? "forward" : "reverse"}));
|
{"direction": forward ? "forward" : "reverse"});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ class _FanControlsWidgetState extends State<FanControlsWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpSpeed = value;
|
_tmpSpeed = value;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
"fan", "set_speed", entity.entityId,
|
"fan", "set_speed", entity.entityId,
|
||||||
{"speed": value}));
|
{"speed": value});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class FlatServiceButton extends StatelessWidget {
|
|||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
void _setNewState() {
|
void _setNewState() {
|
||||||
eventBus.fire(new ServiceCallEvent(serviceDomain, serviceName, entityId, null));
|
ConnectionManager().callService(serviceDomain, serviceName, entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -28,9 +28,9 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpBrightness = value.round();
|
_tmpBrightness = value.round();
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "turn_on", entity.entityId,
|
entity.domain, "turn_on", entity.entityId,
|
||||||
{"brightness": _tmpBrightness}));
|
{"brightness": _tmpBrightness});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,9 +38,9 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpWhiteValue = value.round();
|
_tmpWhiteValue = value.round();
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "turn_on", entity.entityId,
|
entity.domain, "turn_on", entity.entityId,
|
||||||
{"white_value": _tmpWhiteValue}));
|
{"white_value": _tmpWhiteValue});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -49,9 +49,9 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tmpColorTemp = value.round();
|
_tmpColorTemp = value.round();
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "turn_on", entity.entityId,
|
entity.domain, "turn_on", entity.entityId,
|
||||||
{"color_temp": _tmpColorTemp}));
|
{"color_temp": _tmpColorTemp});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,9 +60,9 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
|||||||
_tmpColor = color;
|
_tmpColor = color;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
Logger.d( "HS Color: [${color.hue}, ${color.saturation}]");
|
Logger.d( "HS Color: [${color.hue}, ${color.saturation}]");
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "turn_on", entity.entityId,
|
entity.domain, "turn_on", entity.entityId,
|
||||||
{"hs_color": [color.hue, color.saturation*100]}));
|
{"hs_color": [color.hue, color.saturation*100]});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,9 +71,9 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
|||||||
_tmpEffect = value;
|
_tmpEffect = value;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
if (_tmpEffect != null) {
|
if (_tmpEffect != null) {
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "turn_on", entity.entityId,
|
entity.domain, "turn_on", entity.entityId,
|
||||||
{"effect": "$value"}));
|
{"effect": "$value"});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -227,8 +227,6 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
|||||||
|
|
||||||
Widget _buildEffectControl(LightEntity entity) {
|
Widget _buildEffectControl(LightEntity entity) {
|
||||||
if ((entity.supportEffect) && (entity.effectList != null)) {
|
if ((entity.supportEffect) && (entity.effectList != null)) {
|
||||||
Logger.d("[LIGHT] entity effects: ${entity.effectList}");
|
|
||||||
Logger.d("[LIGHT] current effect: $_tmpEffect");
|
|
||||||
List<String> list = List.from(entity.effectList);
|
List<String> list = List.from(entity.effectList);
|
||||||
if (_tmpEffect!= null && !list.contains(_tmpEffect)) {
|
if (_tmpEffect!= null && !list.contains(_tmpEffect)) {
|
||||||
list.insert(0, _tmpEffect);
|
list.insert(0, _tmpEffect);
|
||||||
|
@ -7,11 +7,11 @@ class LockStateWidget extends StatelessWidget {
|
|||||||
const LockStateWidget({Key key, this.assumedState: false}) : super(key: key);
|
const LockStateWidget({Key key, this.assumedState: false}) : super(key: key);
|
||||||
|
|
||||||
void _lock(Entity entity) {
|
void _lock(Entity entity) {
|
||||||
eventBus.fire(new ServiceCallEvent("lock", "lock", entity.entityId, null));
|
ConnectionManager().callService("lock", "lock", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _unlock(Entity entity) {
|
void _unlock(Entity entity) {
|
||||||
eventBus.fire(new ServiceCallEvent("lock", "unlock", entity.entityId, null));
|
ConnectionManager().callService("lock", "unlock", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -56,12 +56,12 @@ class _MediaPlayerSeekBarState extends State<MediaPlayerSeekBar> {
|
|||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
focusColor: Colors.white,
|
focusColor: Colors.white,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
eventBus.fire(ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
"media_player",
|
"media_player",
|
||||||
"media_seek",
|
"media_seek",
|
||||||
"${entity.entityId}",
|
"${entity.entityId}",
|
||||||
{"seek_position": _savedPosition}
|
{"seek_position": _savedPosition}
|
||||||
));
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
_savedPosition = 0;
|
_savedPosition = 0;
|
||||||
});
|
});
|
||||||
@ -103,12 +103,12 @@ class _MediaPlayerSeekBarState extends State<MediaPlayerSeekBar> {
|
|||||||
_seekStarted = false;
|
_seekStarted = false;
|
||||||
Timer(Duration(milliseconds: 500), () {
|
Timer(Duration(milliseconds: 500), () {
|
||||||
if (!_seekStarted) {
|
if (!_seekStarted) {
|
||||||
eventBus.fire(ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
"media_player",
|
"media_player",
|
||||||
"media_seek",
|
"media_seek",
|
||||||
"${entity.entityId}",
|
"${entity.entityId}",
|
||||||
{"seek_position": val}
|
{"seek_position": val}
|
||||||
));
|
);
|
||||||
setState(() {
|
setState(() {
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
_currentPosition = val;
|
_currentPosition = val;
|
||||||
|
@ -121,23 +121,23 @@ class MediaPlayerPlaybackControls extends StatelessWidget {
|
|||||||
if (entity.state != EntityState.unavailable && entity.state != EntityState.unknown) {
|
if (entity.state != EntityState.unavailable && entity.state != EntityState.unknown) {
|
||||||
if (entity.state == EntityState.off) {
|
if (entity.state == EntityState.off) {
|
||||||
Logger.d("${entity.entityId} turn_on");
|
Logger.d("${entity.entityId} turn_on");
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "turn_on", entity.entityId,
|
entity.domain, "turn_on", entity.entityId,
|
||||||
null));
|
null);
|
||||||
} else {
|
} else {
|
||||||
Logger.d("${entity.entityId} turn_off");
|
Logger.d("${entity.entityId} turn_off");
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "turn_off", entity.entityId,
|
entity.domain, "turn_off", entity.entityId,
|
||||||
null));
|
null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _callAction(MediaPlayerEntity entity, String action) {
|
void _callAction(MediaPlayerEntity entity, String action) {
|
||||||
Logger.d("${entity.entityId} $action");
|
Logger.d("${entity.entityId} $action");
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
entity.domain, "$action", entity.entityId,
|
entity.domain, "$action", entity.entityId,
|
||||||
null));
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -264,27 +264,27 @@ class _MediaPlayerControlsState extends State<MediaPlayerControls> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
_newVolumeLevel = value;
|
_newVolumeLevel = value;
|
||||||
eventBus.fire(ServiceCallEvent("media_player", "volume_set", entityId, {"volume_level": value}));
|
ConnectionManager().callService("media_player", "volume_set", entityId, {"volume_level": value});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setVolumeMute(bool isMuted, String entityId) {
|
void _setVolumeMute(bool isMuted, String entityId) {
|
||||||
eventBus.fire(ServiceCallEvent("media_player", "volume_mute", entityId, {"is_volume_muted": isMuted}));
|
ConnectionManager().callService("media_player", "volume_mute", entityId, {"is_volume_muted": isMuted});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setVolumeUp(String entityId) {
|
void _setVolumeUp(String entityId) {
|
||||||
eventBus.fire(ServiceCallEvent("media_player", "volume_up", entityId, null));
|
ConnectionManager().callService("media_player", "volume_up", entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setVolumeDown(String entityId) {
|
void _setVolumeDown(String entityId) {
|
||||||
eventBus.fire(ServiceCallEvent("media_player", "volume_down", entityId, null));
|
ConnectionManager().callService("media_player", "volume_down", entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setSoundMode(String value, String entityId) {
|
void _setSoundMode(String value, String entityId) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_newSoundMode = value;
|
_newSoundMode = value;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(ServiceCallEvent("media_player", "select_sound_mode", entityId, {"sound_mode": "$value"}));
|
ConnectionManager().callService("media_player", "select_sound_mode", entityId, {"sound_mode": "$value"});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ class _MediaPlayerControlsState extends State<MediaPlayerControls> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_newSource = source;
|
_newSource = source;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
eventBus.fire(ServiceCallEvent("media_player", "select_source", entityId, {"source": "$source"}));
|
ConnectionManager().callService("media_player", "select_source", entityId, {"source": "$source"});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ class SelectStateWidget extends StatefulWidget {
|
|||||||
class _SelectStateWidgetState extends State<SelectStateWidget> {
|
class _SelectStateWidgetState extends State<SelectStateWidget> {
|
||||||
|
|
||||||
void setNewState(domain, entityId, newValue) {
|
void setNewState(domain, entityId, newValue) {
|
||||||
eventBus.fire(new ServiceCallEvent(domain, "select_option", entityId,
|
ConnectionManager().callService(domain, "select_option", entityId,
|
||||||
{"option": "$newValue"}));
|
{"option": "$newValue"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -18,8 +18,8 @@ class _SliderControlsWidgetState extends State<SliderControlsWidget> {
|
|||||||
_newValue = newValue;
|
_newValue = newValue;
|
||||||
_changedHere = true;
|
_changedHere = true;
|
||||||
});
|
});
|
||||||
eventBus.fire(new ServiceCallEvent(domain, "set_value", entityId,
|
ConnectionManager().callService(domain, "set_value", entityId,
|
||||||
{"value": "${newValue.toString()}"}));
|
{"value": "${newValue.toString()}"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -38,8 +38,8 @@ class _SwitchStateWidgetState extends State<SwitchStateWidget> {
|
|||||||
} else {
|
} else {
|
||||||
domain = entity.domain;
|
domain = entity.domain;
|
||||||
}
|
}
|
||||||
eventBus.fire(new ServiceCallEvent(
|
ConnectionManager().callService(
|
||||||
domain, (newValue as bool) ? "turn_on" : "turn_off", entity.entityId, null));
|
domain, (newValue as bool) ? "turn_on" : "turn_off", entity.entityId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -26,8 +26,8 @@ class _TextInputStateWidgetState extends State<TextInputStateWidget> {
|
|||||||
|
|
||||||
void setNewState(newValue, domain, entityId) {
|
void setNewState(newValue, domain, entityId) {
|
||||||
if (validate(newValue, _minLength, _maxLength)) {
|
if (validate(newValue, _minLength, _maxLength)) {
|
||||||
eventBus.fire(new ServiceCallEvent(domain, "set_value", entityId,
|
ConnectionManager().callService(domain, "set_value", entityId,
|
||||||
{"value": "$newValue"}));
|
{"value": "$newValue"});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_tmpValue = _entityState;
|
_tmpValue = _entityState;
|
||||||
|
@ -77,9 +77,10 @@ class VacuumControls extends StatelessWidget {
|
|||||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:play")),
|
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:play")),
|
||||||
iconSize: iconSize,
|
iconSize: iconSize,
|
||||||
onPressed: () => ConnectionManager().callService(
|
onPressed: () => ConnectionManager().callService(
|
||||||
domain: "vacuum",
|
"vacuum",
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "start"
|
"start",
|
||||||
|
null
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -90,9 +91,10 @@ class VacuumControls extends StatelessWidget {
|
|||||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:play-pause")),
|
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:play-pause")),
|
||||||
iconSize: iconSize,
|
iconSize: iconSize,
|
||||||
onPressed: () => ConnectionManager().callService(
|
onPressed: () => ConnectionManager().callService(
|
||||||
domain: "vacuum",
|
"vacuum",
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "start_pause"
|
"start_pause",
|
||||||
|
null
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -102,9 +104,10 @@ class VacuumControls extends StatelessWidget {
|
|||||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:pause")),
|
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:pause")),
|
||||||
iconSize: iconSize,
|
iconSize: iconSize,
|
||||||
onPressed: () => ConnectionManager().callService(
|
onPressed: () => ConnectionManager().callService(
|
||||||
domain: "vacuum",
|
"vacuum",
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "pause"
|
"pause",
|
||||||
|
null
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -115,9 +118,10 @@ class VacuumControls extends StatelessWidget {
|
|||||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:stop")),
|
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:stop")),
|
||||||
iconSize: iconSize,
|
iconSize: iconSize,
|
||||||
onPressed: () => ConnectionManager().callService(
|
onPressed: () => ConnectionManager().callService(
|
||||||
domain: "vacuum",
|
"vacuum",
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "stop"
|
"stop",
|
||||||
|
null
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -128,9 +132,10 @@ class VacuumControls extends StatelessWidget {
|
|||||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:broom")),
|
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:broom")),
|
||||||
iconSize: iconSize,
|
iconSize: iconSize,
|
||||||
onPressed: () => ConnectionManager().callService(
|
onPressed: () => ConnectionManager().callService(
|
||||||
domain: "vacuum",
|
"vacuum",
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "clean_spot"
|
"clean_spot",
|
||||||
|
null
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -141,9 +146,10 @@ class VacuumControls extends StatelessWidget {
|
|||||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:map-marker")),
|
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:map-marker")),
|
||||||
iconSize: iconSize,
|
iconSize: iconSize,
|
||||||
onPressed: () => ConnectionManager().callService(
|
onPressed: () => ConnectionManager().callService(
|
||||||
domain: "vacuum",
|
"vacuum",
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "locate"
|
"locate",
|
||||||
|
null
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -154,9 +160,10 @@ class VacuumControls extends StatelessWidget {
|
|||||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:home-map-marker")),
|
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:home-map-marker")),
|
||||||
iconSize: iconSize,
|
iconSize: iconSize,
|
||||||
onPressed: () => ConnectionManager().callService(
|
onPressed: () => ConnectionManager().callService(
|
||||||
domain: "vacuum",
|
"vacuum",
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "return_to_base"
|
"return_to_base",
|
||||||
|
null
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -194,10 +201,10 @@ class VacuumControls extends StatelessWidget {
|
|||||||
options: entity.fanSpeedList,
|
options: entity.fanSpeedList,
|
||||||
value: entity.fanSpeed,
|
value: entity.fanSpeed,
|
||||||
onChange: (val) => ConnectionManager().callService(
|
onChange: (val) => ConnectionManager().callService(
|
||||||
domain: "vacuum",
|
"vacuum",
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "set_fan_speed",
|
"set_fan_speed",
|
||||||
additionalServiceData: {"fan_speed": val}
|
{"fan_speed": val}
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -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.0";
|
const appVersionNumber = "0.7.1";
|
||||||
const appVersionAdd = "";
|
const appVersionAdd = "alpha1";
|
||||||
const appVersion = "$appVersionNumber-$appVersionAdd";
|
const appVersion = "$appVersionNumber-$appVersionAdd";
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
|
@ -195,7 +195,7 @@ class ConnectionManager {
|
|||||||
_messageResolver.remove("${data["id"]}");
|
_messageResolver.remove("${data["id"]}");
|
||||||
} else if (data["type"] == "event") {
|
} else if (data["type"] == "event") {
|
||||||
if ((data["event"] != null) && (data["event"]["event_type"] == "state_changed")) {
|
if ((data["event"] != null) && (data["event"]["event_type"] == "state_changed")) {
|
||||||
//Logger.d("[Received] <== ${data['type']}.${data["event"]["event_type"]}: ${data["event"]["data"]["entity_id"]}");
|
Logger.d("[Received] <== ${data['type']}.${data["event"]["event_type"]}: ${data["event"]["data"]["entity_id"]}");
|
||||||
onStateChangeCallback(data["event"]["data"]);
|
onStateChangeCallback(data["event"]["data"]);
|
||||||
} else if (data["event"] != null) {
|
} else if (data["event"] != null) {
|
||||||
Logger.w("Unhandled event type: ${data["event"]["event_type"]}");
|
Logger.w("Unhandled event type: ${data["event"]["event_type"]}");
|
||||||
@ -348,7 +348,8 @@ class ConnectionManager {
|
|||||||
_currentMessageId += 1;
|
_currentMessageId += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
Completer completer = Completer();
|
Completer completer = Completer();
|
||||||
Map serviceData = {};
|
Map serviceData = {};
|
||||||
if (entityId != null) {
|
if (entityId != null) {
|
||||||
|
@ -45,7 +45,7 @@ class MobileAppIntegrationManager {
|
|||||||
positiveText: "Restart now",
|
positiveText: "Restart now",
|
||||||
negativeText: "Later",
|
negativeText: "Later",
|
||||||
onPositive: () {
|
onPositive: () {
|
||||||
ConnectionManager().callService(domain: "homeassistant", service: "restart", entityId: null);
|
ConnectionManager().callService("homeassistant","restart", null, null);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
@ -42,7 +42,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void decLocationInterval() {
|
void decLocationInterval() {
|
||||||
if (_locationInterval > 1) {
|
if (_locationInterval > 15) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_locationInterval = _locationInterval - 1;
|
_locationInterval = _locationInterval - 1;
|
||||||
});
|
});
|
||||||
@ -56,7 +56,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
|||||||
positiveText: "Sure. Make it so",
|
positiveText: "Sure. Make it so",
|
||||||
negativeText: "What?? No!",
|
negativeText: "What?? No!",
|
||||||
onPositive: () {
|
onPositive: () {
|
||||||
ConnectionManager().callService(domain: "homeassistant", service: "restart", entityId: null);
|
ConnectionManager().callService("homeassistant", "restart", null, null);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
|||||||
positiveText: "Sure. Make it so",
|
positiveText: "Sure. Make it so",
|
||||||
negativeText: "What?? No!",
|
negativeText: "What?? No!",
|
||||||
onPositive: () {
|
onPositive: () {
|
||||||
ConnectionManager().callService(domain: "homeassistant", service: "stop", entityId: null);
|
ConnectionManager().callService("homeassistant","stop", null, null);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
bool _showLoginButton = false;
|
bool _showLoginButton = false;
|
||||||
bool _preventAppRefresh = false;
|
bool _preventAppRefresh = false;
|
||||||
String _savedSharedText;
|
String _savedSharedText;
|
||||||
String _entityToShow;
|
Entity _entityToShow;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -142,6 +142,9 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
_viewsTabController = TabController(vsync: this, length: currentViewCount);
|
_viewsTabController = TabController(vsync: this, length: currentViewCount);
|
||||||
_previousViewCount = currentViewCount;
|
_previousViewCount = currentViewCount;
|
||||||
}
|
}
|
||||||
|
if (_entityToShow != null) {
|
||||||
|
_entityToShow = HomeAssistant().entities.get(_entityToShow.entityId);
|
||||||
|
}
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
if (e is HAError) {
|
if (e is HAError) {
|
||||||
_setErrorState(e);
|
_setErrorState(e);
|
||||||
@ -218,9 +221,8 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
}
|
}
|
||||||
if (_serviceCallSubscription == null) {
|
if (_serviceCallSubscription == null) {
|
||||||
_serviceCallSubscription =
|
_serviceCallSubscription =
|
||||||
eventBus.on<ServiceCallEvent>().listen((event) {
|
eventBus.on<NotifyServiceCallEvent>().listen((event) {
|
||||||
_callService(event.domain, event.service, event.entityId,
|
_notifyServiceCalled(event.domain, event.service, event.entityId);
|
||||||
event.additionalParams);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,27 +320,28 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO remove this shit.... maybe
|
void _notifyServiceCalled(String domain, String service, String entityId) {
|
||||||
void _callService(String domain, String service, String entityId, Map additionalParams) {
|
|
||||||
_showInfoBottomBar(
|
_showInfoBottomBar(
|
||||||
message: "Calling $domain.$service",
|
message: "Calling $domain.$service",
|
||||||
duration: Duration(seconds: 3)
|
duration: Duration(seconds: 4)
|
||||||
);
|
);
|
||||||
ConnectionManager().callService(domain: domain, service: service, entityId: entityId, additionalServiceData: additionalParams).catchError((e) => _setErrorState(e));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showEntityPage(String entityId) {
|
void _showEntityPage(String entityId) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_entityToShow = entityId;
|
_entityToShow = HomeAssistant().entities.get(entityId);
|
||||||
|
if (_entityToShow != null) {
|
||||||
|
_mainScrollController?.jumpTo(0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (_entityToShow!= null && MediaQuery.of(context).size.width < Sizes.tabletMinWidth) {
|
/*if (_entityToShow!= null && MediaQuery.of(context).size.width < Sizes.tabletMinWidth) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => EntityViewPage(entityId: entityId),
|
builder: (context) => EntityViewPage(entityId: entityId),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showPage(String path, bool goBackFirst) {
|
void _showPage(String path, bool goBackFirst) {
|
||||||
@ -368,12 +371,7 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
menuItems.add(
|
menuItems.add(
|
||||||
UserAccountsDrawerHeader(
|
UserAccountsDrawerHeader(
|
||||||
accountName: Text(HomeAssistant().userName),
|
accountName: Text(HomeAssistant().userName),
|
||||||
accountEmail: Text(ConnectionManager().displayHostname ?? "Not configured"),
|
accountEmail: Text(HomeAssistant().locationName ?? ""),
|
||||||
onDetailsPressed: () {
|
|
||||||
Launcher.launchURLInCustomTab(
|
|
||||||
url: "${ConnectionManager().httpWebHost}/profile?external_auth=1"
|
|
||||||
);
|
|
||||||
},
|
|
||||||
currentAccountPicture: CircleAvatar(
|
currentAccountPicture: CircleAvatar(
|
||||||
child: Text(
|
child: Text(
|
||||||
HomeAssistant().userAvatarText,
|
HomeAssistant().userAvatarText,
|
||||||
@ -636,6 +634,7 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
}
|
}
|
||||||
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||||
|
final ScrollController _mainScrollController = ScrollController();
|
||||||
|
|
||||||
Widget _buildScaffoldBody(bool empty) {
|
Widget _buildScaffoldBody(bool empty) {
|
||||||
List<PopupMenuItem<String>> serviceMenuItems = [];
|
List<PopupMenuItem<String>> serviceMenuItems = [];
|
||||||
@ -730,7 +729,6 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_entityToShow != null && MediaQuery.of(context).size.width >= Sizes.tabletMinWidth) {
|
if (_entityToShow != null && MediaQuery.of(context).size.width >= Sizes.tabletMinWidth) {
|
||||||
Entity entity = HomeAssistant().entities.get(_entityToShow);
|
|
||||||
mainScrollBody = Flex(
|
mainScrollBody = Flex(
|
||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -743,12 +741,13 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
),
|
),
|
||||||
ConstrainedBox(
|
ConstrainedBox(
|
||||||
constraints: BoxConstraints.tightFor(width: Sizes.entityPageMaxWidth),
|
constraints: BoxConstraints.tightFor(width: Sizes.entityPageMaxWidth),
|
||||||
child: EntityPageLayout(entity: entity, showClose: true,),
|
child: EntityPageLayout(entity: _entityToShow, showClose: true,),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
} else if (_entityToShow != null) {
|
||||||
|
mainScrollBody = EntityPageLayout(entity: _entityToShow, showClose: true,);
|
||||||
} else {
|
} else {
|
||||||
_entityToShow = null;
|
|
||||||
mainScrollBody = HomeAssistant().buildViews(context, _viewsTabController);
|
mainScrollBody = HomeAssistant().buildViews(context, _viewsTabController);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -804,7 +803,7 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
_scaffoldKey.currentState.openDrawer();
|
_scaffoldKey.currentState.openDrawer();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
bottom: empty ? null : TabBar(
|
bottom: (empty || _entityToShow != null) ? null : TabBar(
|
||||||
controller: _viewsTabController,
|
controller: _viewsTabController,
|
||||||
tabs: buildUIViewTabs(),
|
tabs: buildUIViewTabs(),
|
||||||
isScrollable: true,
|
isScrollable: true,
|
||||||
@ -813,7 +812,8 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
|
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
body: mainScrollBody
|
body: mainScrollBody,
|
||||||
|
controller: _mainScrollController,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -879,12 +879,24 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
body: _buildScaffoldBody(true)
|
body: _buildScaffoldBody(true)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Scaffold(
|
return WillPopScope(
|
||||||
|
child: Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
drawer: _buildAppDrawer(),
|
drawer: _buildAppDrawer(),
|
||||||
primary: false,
|
primary: false,
|
||||||
bottomNavigationBar: bottomBar,
|
bottomNavigationBar: bottomBar,
|
||||||
body: _buildScaffoldBody(false)
|
body: _buildScaffoldBody(false)
|
||||||
|
),
|
||||||
|
onWillPop: () {
|
||||||
|
if (_entityToShow != null) {
|
||||||
|
setState(() {
|
||||||
|
_entityToShow = null;
|
||||||
|
});
|
||||||
|
return Future.value(false);
|
||||||
|
} else {
|
||||||
|
return Future.value(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,17 +89,22 @@ class _PlayMediaPageState extends State<PlayMediaPage> {
|
|||||||
}
|
}
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
ConnectionManager().callService(
|
ConnectionManager().callService(
|
||||||
domain: serviceDomain,
|
serviceDomain,
|
||||||
entityId: entity.entityId,
|
entity.entityId,
|
||||||
service: "play_media",
|
"play_media",
|
||||||
additionalServiceData: {
|
{
|
||||||
"media_content_id": _mediaUrl,
|
"media_content_id": _mediaUrl,
|
||||||
"media_content_type": _contentType
|
"media_content_type": _contentType
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
HomeAssistant().sendToPlayerId = entity.entityId;
|
HomeAssistant().sendToPlayerId = entity.entityId;
|
||||||
if (HomeAssistant().sendFromPlayerId != null && HomeAssistant().sendFromPlayerId != HomeAssistant().sendToPlayerId) {
|
if (HomeAssistant().sendFromPlayerId != null && HomeAssistant().sendFromPlayerId != HomeAssistant().sendToPlayerId) {
|
||||||
eventBus.fire(ServiceCallEvent(HomeAssistant().sendFromPlayerId.split(".")[0], "turn_off", HomeAssistant().sendFromPlayerId, null));
|
ConnectionManager().callService(
|
||||||
|
HomeAssistant().sendFromPlayerId.split(".")[0],
|
||||||
|
"turn_off",
|
||||||
|
HomeAssistant().sendFromPlayerId,
|
||||||
|
null
|
||||||
|
);
|
||||||
HomeAssistant().sendFromPlayerId = null;
|
HomeAssistant().sendFromPlayerId = null;
|
||||||
}
|
}
|
||||||
eventBus.fire(ShowEntityPageEvent(entity: entity));
|
eventBus.fire(ShowEntityPageEvent(entity: entity));
|
||||||
|
@ -33,13 +33,12 @@ class StartAuthEvent {
|
|||||||
StartAuthEvent(this.oauthUrl, this.showButton);
|
StartAuthEvent(this.oauthUrl, this.showButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ServiceCallEvent {
|
class NotifyServiceCallEvent {
|
||||||
String domain;
|
String domain;
|
||||||
String service;
|
String service;
|
||||||
String entityId;
|
String entityId;
|
||||||
Map<String, dynamic> additionalParams;
|
|
||||||
|
|
||||||
ServiceCallEvent(this.domain, this.service, this.entityId, this.additionalParams);
|
NotifyServiceCallEvent(this.domain, this.service, this.entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ShowPopupDialogEvent {
|
class ShowPopupDialogEvent {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: hass_client
|
name: hass_client
|
||||||
description: Home Assistant Android Client
|
description: Home Assistant Android Client
|
||||||
|
|
||||||
version: 0.7.0+706
|
version: 0.7.1+711
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||||
|
Reference in New Issue
Block a user