Fixx service calls
This commit is contained in:
parent
139533d2ca
commit
551a8dfa31
@ -26,10 +26,10 @@ class _AlarmControlPanelControlsWidgetWidgetState extends State<AlarmControlPane
|
||||
|
||||
void _callService(AlarmControlPanelEntity entity, String service) {
|
||||
ConnectionManager().callService(
|
||||
entity.domain,
|
||||
service,
|
||||
entity.entityId,
|
||||
{"code": "$code"}
|
||||
domain: entity.domain,
|
||||
service: service,
|
||||
entityId: entity.entityId,
|
||||
data: {"code": "$code"}
|
||||
);
|
||||
setState(() {
|
||||
code = "";
|
||||
@ -62,10 +62,9 @@ class _AlarmControlPanelControlsWidgetWidgetState extends State<AlarmControlPane
|
||||
child: new Text("Yes"),
|
||||
onPressed: () {
|
||||
ConnectionManager().callService(
|
||||
entity.domain,
|
||||
"alarm_trigger",
|
||||
entity.entityId,
|
||||
null
|
||||
domain: entity.domain,
|
||||
service: "alarm_trigger",
|
||||
entityId: entity.entityId
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
|
@ -84,10 +84,10 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
setState(() {
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(
|
||||
entity.domain,
|
||||
"set_temperature",
|
||||
entity.entityId,
|
||||
{"temperature": "${_tmpTemperature.toStringAsFixed(1)}"}
|
||||
domain: entity.domain,
|
||||
service: "set_temperature",
|
||||
entityId: entity.entityId,
|
||||
data: {"temperature": "${_tmpTemperature.toStringAsFixed(1)}"}
|
||||
);
|
||||
_resetStateTimer(entity);
|
||||
});
|
||||
@ -107,10 +107,10 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
setState(() {
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(
|
||||
entity.domain,
|
||||
"set_temperature",
|
||||
entity.entityId,
|
||||
{"target_temp_high": "${_tmpTargetHigh.toStringAsFixed(1)}", "target_temp_low": "${_tmpTargetLow.toStringAsFixed(1)}"}
|
||||
domain: entity.domain,
|
||||
service: "set_temperature",
|
||||
entityId: entity.entityId,
|
||||
data: {"target_temp_high": "${_tmpTargetHigh.toStringAsFixed(1)}", "target_temp_low": "${_tmpTargetLow.toStringAsFixed(1)}"}
|
||||
);
|
||||
_resetStateTimer(entity);
|
||||
});
|
||||
@ -121,7 +121,12 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
setState(() {
|
||||
_tmpTargetHumidity = value.roundToDouble();
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(entity.domain, "set_humidity", entity.entityId, {"humidity": "$_tmpTargetHumidity"});
|
||||
ConnectionManager().callService(
|
||||
domain: entity.domain,
|
||||
service: "set_humidity",
|
||||
entityId: entity.entityId,
|
||||
data: {"humidity": "$_tmpTargetHumidity"}
|
||||
);
|
||||
_resetStateTimer(entity);
|
||||
});
|
||||
}
|
||||
@ -130,7 +135,12 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
setState(() {
|
||||
_tmpHVACMode = value;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(entity.domain, "set_hvac_mode", entity.entityId, {"hvac_mode": "$_tmpHVACMode"});
|
||||
ConnectionManager().callService(
|
||||
domain: entity.domain,
|
||||
service: "set_hvac_mode",
|
||||
entityId: entity.entityId,
|
||||
data: {"hvac_mode": "$_tmpHVACMode"}
|
||||
);
|
||||
_resetStateTimer(entity);
|
||||
});
|
||||
}
|
||||
@ -139,7 +149,12 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
setState(() {
|
||||
_tmpSwingMode = value;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(entity.domain, "set_swing_mode", entity.entityId, {"swing_mode": "$_tmpSwingMode"});
|
||||
ConnectionManager().callService(
|
||||
domain: entity.domain,
|
||||
service: "set_swing_mode",
|
||||
entityId: entity.entityId,
|
||||
data: {"swing_mode": "$_tmpSwingMode"}
|
||||
);
|
||||
_resetStateTimer(entity);
|
||||
});
|
||||
}
|
||||
@ -148,7 +163,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
setState(() {
|
||||
_tmpFanMode = value;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(entity.domain, "set_fan_mode", entity.entityId, {"fan_mode": "$_tmpFanMode"});
|
||||
ConnectionManager().callService(domain: entity.domain, service: "set_fan_mode", entityId: entity.entityId, data: {"fan_mode": "$_tmpFanMode"});
|
||||
_resetStateTimer(entity);
|
||||
});
|
||||
}
|
||||
@ -157,7 +172,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
setState(() {
|
||||
_tmpPresetMode = value;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(entity.domain, "set_preset_mode", entity.entityId, {"preset_mode": "$_tmpPresetMode"});
|
||||
ConnectionManager().callService(domain: entity.domain, service: "set_preset_mode", entityId: entity.entityId, data: {"preset_mode": "$_tmpPresetMode"});
|
||||
_resetStateTimer(entity);
|
||||
});
|
||||
}
|
||||
@ -175,7 +190,7 @@ class _ClimateControlWidgetState extends State<ClimateControlWidget> {
|
||||
setState(() {
|
||||
_tmpAuxHeat = value;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(entity.domain, "set_aux_heat", entity.entityId, {"aux_heat": "$_tmpAuxHeat"});
|
||||
ConnectionManager().callService(domain: entity.domain, service: "set_aux_heat", entityId: entity.entityId, data: {"aux_heat": "$_tmpAuxHeat"});
|
||||
_resetStateTimer(entity);
|
||||
});
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class _CoverControlWidgetState extends State<CoverControlWidget> {
|
||||
setState(() {
|
||||
_tmpPosition = position.roundToDouble();
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(entity.domain, "set_cover_position", entity.entityId,{"position": _tmpPosition.round()});
|
||||
ConnectionManager().callService(domain: entity.domain, service: "set_cover_position", entityId: entity.entityId, data: {"position": _tmpPosition.round()});
|
||||
});
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ class _CoverControlWidgetState extends State<CoverControlWidget> {
|
||||
setState(() {
|
||||
_tmpTiltPosition = position.roundToDouble();
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(entity.domain, "set_cover_tilt_position", entity.entityId,{"tilt_position": _tmpTiltPosition.round()});
|
||||
ConnectionManager().callService(domain: entity.domain, service: "set_cover_tilt_position", entityId: entity.entityId, data: {"tilt_position": _tmpTiltPosition.round()});
|
||||
});
|
||||
}
|
||||
|
||||
@ -136,17 +136,17 @@ class _CoverControlWidgetState extends State<CoverControlWidget> {
|
||||
class CoverTiltControlsWidget extends StatelessWidget {
|
||||
void _open(CoverEntity entity) {
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "open_cover_tilt", entity.entityId, null);
|
||||
domain: entity.domain, service: "open_cover_tilt", entityId: entity.entityId);
|
||||
}
|
||||
|
||||
void _close(CoverEntity entity) {
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "close_cover_tilt", entity.entityId, null);
|
||||
domain: entity.domain, service: "close_cover_tilt", entityId: entity.entityId);
|
||||
}
|
||||
|
||||
void _stop(CoverEntity entity) {
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "stop_cover_tilt", entity.entityId, null);
|
||||
domain: entity.domain, service: "stop_cover_tilt", entityId: entity.entityId);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -3,17 +3,26 @@ part of '../../../main.dart';
|
||||
class CoverStateWidget extends StatelessWidget {
|
||||
void _open(CoverEntity entity) {
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "open_cover", entity.entityId, null);
|
||||
domain: entity.domain,
|
||||
service: "open_cover",
|
||||
entityId: entity.entityId
|
||||
);
|
||||
}
|
||||
|
||||
void _close(CoverEntity entity) {
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "close_cover", entity.entityId, null);
|
||||
domain: entity.domain,
|
||||
service: "close_cover",
|
||||
entityId: entity.entityId
|
||||
);
|
||||
}
|
||||
|
||||
void _stop(CoverEntity entity) {
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "stop_cover", entity.entityId, null);
|
||||
domain: entity.domain,
|
||||
service: "stop_cover",
|
||||
entityId: entity.entityId
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -36,6 +36,6 @@ class DateTimeEntity extends Entity {
|
||||
}
|
||||
|
||||
void setNewState(Map newValue) {
|
||||
ConnectionManager().callService(domain, "set_datetime", entityId, newValue);
|
||||
ConnectionManager().callService(domain: domain, service: "set_datetime", entityId: entityId, data: newValue);
|
||||
}
|
||||
}
|
@ -32,15 +32,17 @@ class EntityWrapper {
|
||||
void handleTap() {
|
||||
switch (uiAction.tapAction) {
|
||||
case EntityUIAction.toggle: {
|
||||
ConnectionManager().callService("homeassistant", "toggle", entity.entityId, null);
|
||||
ConnectionManager().callService(domain: "homeassistant", service: "toggle", entityId: entity.entityId);
|
||||
break;
|
||||
}
|
||||
|
||||
case EntityUIAction.callService: {
|
||||
if (uiAction.tapService != null) {
|
||||
ConnectionManager().callService(uiAction.tapService.split(".")[0],
|
||||
uiAction.tapService.split(".")[1], null,
|
||||
uiAction.tapServiceData);
|
||||
ConnectionManager().callService(
|
||||
domain: uiAction.tapService.split(".")[0],
|
||||
service: uiAction.tapService.split(".")[1],
|
||||
data: uiAction.tapServiceData
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -74,15 +76,17 @@ class EntityWrapper {
|
||||
void handleHold() {
|
||||
switch (uiAction.holdAction) {
|
||||
case EntityUIAction.toggle: {
|
||||
ConnectionManager().callService("homeassistant", "toggle", entity.entityId, null);
|
||||
ConnectionManager().callService(domain: "homeassistant", service: "toggle", entityId: entity.entityId);
|
||||
break;
|
||||
}
|
||||
|
||||
case EntityUIAction.callService: {
|
||||
if (uiAction.holdService != null) {
|
||||
ConnectionManager().callService(uiAction.holdService.split(".")[0],
|
||||
uiAction.holdService.split(".")[1], null,
|
||||
uiAction.holdServiceData);
|
||||
ConnectionManager().callService(
|
||||
domain: uiAction.holdService.split(".")[0],
|
||||
service: uiAction.holdService.split(".")[1],
|
||||
data: uiAction.holdServiceData
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -25,8 +25,11 @@ class _FanControlsWidgetState extends State<FanControlsWidget> {
|
||||
_tmpOscillate = oscillate;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(
|
||||
"fan", "oscillate", entity.entityId,
|
||||
{"oscillating": oscillate});
|
||||
domain: "fan",
|
||||
service: "oscillate",
|
||||
entityId: entity.entityId,
|
||||
data: {"oscillating": oscillate}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -35,8 +38,11 @@ class _FanControlsWidgetState extends State<FanControlsWidget> {
|
||||
_tmpDirectionForward = forward;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(
|
||||
"fan", "set_direction", entity.entityId,
|
||||
{"direction": forward ? "forward" : "reverse"});
|
||||
domain: "fan",
|
||||
service: "set_direction",
|
||||
entityId: entity.entityId,
|
||||
data: {"direction": forward ? "forward" : "reverse"}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -45,8 +51,11 @@ class _FanControlsWidgetState extends State<FanControlsWidget> {
|
||||
_tmpSpeed = value;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(
|
||||
"fan", "set_speed", entity.entityId,
|
||||
{"speed": value});
|
||||
domain: "fan",
|
||||
service: "set_speed",
|
||||
entityId: entity.entityId,
|
||||
data: {"speed": value}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ class FlatServiceButton extends StatelessWidget {
|
||||
}) : super(key: key);
|
||||
|
||||
void _setNewState() {
|
||||
ConnectionManager().callService(serviceDomain, serviceName, entityId, null);
|
||||
ConnectionManager().callService(domain: serviceDomain, service: serviceName, entityId: entityId);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -29,8 +29,11 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
||||
_tmpBrightness = value.round();
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "turn_on", entity.entityId,
|
||||
{"brightness": _tmpBrightness});
|
||||
domain: entity.domain,
|
||||
service: "turn_on",
|
||||
entityId: entity.entityId,
|
||||
data: {"brightness": _tmpBrightness}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -39,8 +42,11 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
||||
_tmpWhiteValue = value.round();
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "turn_on", entity.entityId,
|
||||
{"white_value": _tmpWhiteValue});
|
||||
domain: entity.domain,
|
||||
service: "turn_on",
|
||||
entityId: entity.entityId,
|
||||
data: {"white_value": _tmpWhiteValue}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
@ -50,8 +56,11 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
||||
_tmpColorTemp = value.round();
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "turn_on", entity.entityId,
|
||||
{"color_temp": _tmpColorTemp});
|
||||
domain: entity.domain,
|
||||
service: "turn_on",
|
||||
entityId: entity.entityId,
|
||||
data: {"color_temp": _tmpColorTemp}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -59,10 +68,12 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
||||
setState(() {
|
||||
_tmpColor = color;
|
||||
_changedHere = true;
|
||||
Logger.d( "HS Color: [${color.hue}, ${color.saturation}]");
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "turn_on", entity.entityId,
|
||||
{"hs_color": [color.hue, color.saturation*100]});
|
||||
domain: entity.domain,
|
||||
service: "turn_on",
|
||||
entityId: entity.entityId,
|
||||
data: {"hs_color": [color.hue, color.saturation*100]}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -72,8 +83,11 @@ class _LightControlsWidgetState extends State<LightControlsWidget> {
|
||||
_changedHere = true;
|
||||
if (_tmpEffect != null) {
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "turn_on", entity.entityId,
|
||||
{"effect": "$value"});
|
||||
domain: entity.domain,
|
||||
service: "turn_on",
|
||||
entityId: entity.entityId,
|
||||
data: {"effect": "$value"}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -7,11 +7,11 @@ class LockStateWidget extends StatelessWidget {
|
||||
const LockStateWidget({Key key, this.assumedState: false}) : super(key: key);
|
||||
|
||||
void _lock(Entity entity) {
|
||||
ConnectionManager().callService("lock", "lock", entity.entityId, null);
|
||||
ConnectionManager().callService(domain: "lock", service: "lock", entityId: entity.entityId);
|
||||
}
|
||||
|
||||
void _unlock(Entity entity) {
|
||||
ConnectionManager().callService("lock", "unlock", entity.entityId, null);
|
||||
ConnectionManager().callService(domain: "lock", service: "unlock", entityId: entity.entityId);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -57,10 +57,10 @@ class _MediaPlayerSeekBarState extends State<MediaPlayerSeekBar> {
|
||||
focusColor: Colors.white,
|
||||
onPressed: () {
|
||||
ConnectionManager().callService(
|
||||
"media_player",
|
||||
"media_seek",
|
||||
"${entity.entityId}",
|
||||
{"seek_position": _savedPosition}
|
||||
domain: "media_player",
|
||||
service: "media_seek",
|
||||
entityId: entity.entityId,
|
||||
data: {"seek_position": _savedPosition}
|
||||
);
|
||||
setState(() {
|
||||
_savedPosition = 0;
|
||||
@ -104,10 +104,10 @@ class _MediaPlayerSeekBarState extends State<MediaPlayerSeekBar> {
|
||||
Timer(Duration(milliseconds: 500), () {
|
||||
if (!_seekStarted) {
|
||||
ConnectionManager().callService(
|
||||
"media_player",
|
||||
"media_seek",
|
||||
"${entity.entityId}",
|
||||
{"seek_position": val}
|
||||
domain: "media_player",
|
||||
service: "media_seek",
|
||||
entityId: entity.entityId,
|
||||
data: {"seek_position": val}
|
||||
);
|
||||
setState(() {
|
||||
_changedHere = true;
|
||||
|
@ -122,13 +122,17 @@ class MediaPlayerPlaybackControls extends StatelessWidget {
|
||||
if (entity.state == EntityState.off) {
|
||||
Logger.d("${entity.entityId} turn_on");
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "turn_on", entity.entityId,
|
||||
null);
|
||||
domain: entity.domain,
|
||||
service: "turn_on",
|
||||
entityId: entity.entityId
|
||||
);
|
||||
} else {
|
||||
Logger.d("${entity.entityId} turn_off");
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "turn_off", entity.entityId,
|
||||
null);
|
||||
domain: entity.domain,
|
||||
service: "turn_off",
|
||||
entityId: entity.entityId
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,8 +140,10 @@ class MediaPlayerPlaybackControls extends StatelessWidget {
|
||||
void _callAction(MediaPlayerEntity entity, String action) {
|
||||
Logger.d("${entity.entityId} $action");
|
||||
ConnectionManager().callService(
|
||||
entity.domain, "$action", entity.entityId,
|
||||
null);
|
||||
domain: entity.domain,
|
||||
service: "$action",
|
||||
entityId: entity.entityId
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -264,27 +270,50 @@ class _MediaPlayerControlsState extends State<MediaPlayerControls> {
|
||||
setState(() {
|
||||
_changedHere = true;
|
||||
_newVolumeLevel = value;
|
||||
ConnectionManager().callService("media_player", "volume_set", entityId, {"volume_level": value});
|
||||
ConnectionManager().callService(
|
||||
domain: "media_player",
|
||||
service: "volume_set",
|
||||
entityId: entityId,
|
||||
data: {"volume_level": value}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void _setVolumeMute(bool isMuted, String entityId) {
|
||||
ConnectionManager().callService("media_player", "volume_mute", entityId, {"is_volume_muted": isMuted});
|
||||
ConnectionManager().callService(
|
||||
domain: "media_player",
|
||||
service: "volume_mute",
|
||||
entityId: entityId,
|
||||
data: {"is_volume_muted": isMuted}
|
||||
);
|
||||
}
|
||||
|
||||
void _setVolumeUp(String entityId) {
|
||||
ConnectionManager().callService("media_player", "volume_up", entityId, null);
|
||||
ConnectionManager().callService(
|
||||
domain: "media_player",
|
||||
service: "volume_up",
|
||||
entityId: entityId
|
||||
);
|
||||
}
|
||||
|
||||
void _setVolumeDown(String entityId) {
|
||||
ConnectionManager().callService("media_player", "volume_down", entityId, null);
|
||||
ConnectionManager().callService(
|
||||
domain: "media_player",
|
||||
service: "volume_down",
|
||||
entityId: entityId
|
||||
);
|
||||
}
|
||||
|
||||
void _setSoundMode(String value, String entityId) {
|
||||
setState(() {
|
||||
_newSoundMode = value;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService("media_player", "select_sound_mode", entityId, {"sound_mode": "$value"});
|
||||
ConnectionManager().callService(
|
||||
domain: "media_player",
|
||||
service: "select_sound_mode",
|
||||
entityId: entityId,
|
||||
data: {"sound_mode": "$value"}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -292,7 +321,12 @@ class _MediaPlayerControlsState extends State<MediaPlayerControls> {
|
||||
setState(() {
|
||||
_newSource = source;
|
||||
_changedHere = true;
|
||||
ConnectionManager().callService("media_player", "select_source", entityId, {"source": "$source"});
|
||||
ConnectionManager().callService(
|
||||
domain: "media_player",
|
||||
service: "select_source",
|
||||
entityId: entityId,
|
||||
data: {"source": "$source"}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,12 @@ class SelectStateWidget extends StatefulWidget {
|
||||
class _SelectStateWidgetState extends State<SelectStateWidget> {
|
||||
|
||||
void setNewState(domain, entityId, newValue) {
|
||||
ConnectionManager().callService(domain, "select_option", entityId,
|
||||
{"option": "$newValue"});
|
||||
ConnectionManager().callService(
|
||||
domain: domain,
|
||||
service: "select_option",
|
||||
entityId: entityId,
|
||||
data: {"option": "$newValue"}
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -18,8 +18,12 @@ class _SliderControlsWidgetState extends State<SliderControlsWidget> {
|
||||
_newValue = newValue;
|
||||
_changedHere = true;
|
||||
});
|
||||
ConnectionManager().callService(domain, "set_value", entityId,
|
||||
{"value": "${newValue.toString()}"});
|
||||
ConnectionManager().callService(
|
||||
domain: domain,
|
||||
service: "set_value",
|
||||
entityId: entityId,
|
||||
data: {"value": "${newValue.toString()}"}
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -39,7 +39,10 @@ class _SwitchStateWidgetState extends State<SwitchStateWidget> {
|
||||
domain = entity.domain;
|
||||
}
|
||||
ConnectionManager().callService(
|
||||
domain, (newValue as bool) ? "turn_on" : "turn_off", entity.entityId, null);
|
||||
domain: domain,
|
||||
service: (newValue as bool) ? "turn_on" : "turn_off",
|
||||
entityId: entity.entityId
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -26,8 +26,12 @@ class _TextInputStateWidgetState extends State<TextInputStateWidget> {
|
||||
|
||||
void setNewState(newValue, domain, entityId) {
|
||||
if (validate(newValue, _minLength, _maxLength)) {
|
||||
ConnectionManager().callService(domain, "set_value", entityId,
|
||||
{"value": "$newValue"});
|
||||
ConnectionManager().callService(
|
||||
domain: domain,
|
||||
service: "set_value",
|
||||
entityId: entityId,
|
||||
data: {"value": "$newValue"}
|
||||
);
|
||||
} else {
|
||||
setState(() {
|
||||
_tmpValue = _entityState;
|
||||
|
@ -77,10 +77,9 @@ class VacuumControls extends StatelessWidget {
|
||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:play")),
|
||||
iconSize: iconSize,
|
||||
onPressed: () => ConnectionManager().callService(
|
||||
"vacuum",
|
||||
entity.entityId,
|
||||
"start",
|
||||
null
|
||||
domain: "vacuum",
|
||||
entityId: entity.entityId,
|
||||
service: "start"
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -91,10 +90,9 @@ class VacuumControls extends StatelessWidget {
|
||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:play-pause")),
|
||||
iconSize: iconSize,
|
||||
onPressed: () => ConnectionManager().callService(
|
||||
"vacuum",
|
||||
entity.entityId,
|
||||
"start_pause",
|
||||
null
|
||||
domain: "vacuum",
|
||||
entityId: entity.entityId,
|
||||
service: "start_pause"
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -104,10 +102,9 @@ class VacuumControls extends StatelessWidget {
|
||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:pause")),
|
||||
iconSize: iconSize,
|
||||
onPressed: () => ConnectionManager().callService(
|
||||
"vacuum",
|
||||
entity.entityId,
|
||||
"pause",
|
||||
null
|
||||
domain: "vacuum",
|
||||
entityId: entity.entityId,
|
||||
service: "pause"
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -118,10 +115,9 @@ class VacuumControls extends StatelessWidget {
|
||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:stop")),
|
||||
iconSize: iconSize,
|
||||
onPressed: () => ConnectionManager().callService(
|
||||
"vacuum",
|
||||
entity.entityId,
|
||||
"stop",
|
||||
null
|
||||
domain: "vacuum",
|
||||
entityId: entity.entityId,
|
||||
service: "stop"
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -132,10 +128,9 @@ class VacuumControls extends StatelessWidget {
|
||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:broom")),
|
||||
iconSize: iconSize,
|
||||
onPressed: () => ConnectionManager().callService(
|
||||
"vacuum",
|
||||
entity.entityId,
|
||||
"clean_spot",
|
||||
null
|
||||
domain: "vacuum",
|
||||
entityId: entity.entityId,
|
||||
service: "clean_spot"
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -146,10 +141,9 @@ class VacuumControls extends StatelessWidget {
|
||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:map-marker")),
|
||||
iconSize: iconSize,
|
||||
onPressed: () => ConnectionManager().callService(
|
||||
"vacuum",
|
||||
entity.entityId,
|
||||
"locate",
|
||||
null
|
||||
domain: "vacuum",
|
||||
entityId: entity.entityId,
|
||||
service: "locate"
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -160,10 +154,9 @@ class VacuumControls extends StatelessWidget {
|
||||
icon: Icon(MaterialDesignIcons.getIconDataFromIconName("mdi:home-map-marker")),
|
||||
iconSize: iconSize,
|
||||
onPressed: () => ConnectionManager().callService(
|
||||
"vacuum",
|
||||
entity.entityId,
|
||||
"return_to_base",
|
||||
null
|
||||
domain: "vacuum",
|
||||
entityId: entity.entityId,
|
||||
service: "return_to_base"
|
||||
),
|
||||
)
|
||||
);
|
||||
@ -201,10 +194,10 @@ class VacuumControls extends StatelessWidget {
|
||||
options: entity.fanSpeedList,
|
||||
value: entity.fanSpeed,
|
||||
onChange: (val) => ConnectionManager().callService(
|
||||
"vacuum",
|
||||
entity.entityId,
|
||||
"set_fan_speed",
|
||||
{"fan_speed": val}
|
||||
domain: "vacuum",
|
||||
entityId: entity.entityId,
|
||||
service: "set_fan_speed",
|
||||
data: {"fan_speed": val}
|
||||
)
|
||||
),
|
||||
);
|
||||
|
@ -348,16 +348,16 @@ class ConnectionManager {
|
||||
_currentMessageId += 1;
|
||||
}
|
||||
|
||||
Future callService(String domain, String service, String entityId, Map additionalServiceData) {
|
||||
Future callService({@required String domain, @required String service, String entityId, Map data}) {
|
||||
eventBus.fire(NotifyServiceCallEvent(domain, service, entityId));
|
||||
Logger.d("Service call: $domain.$service, $entityId, $additionalServiceData");
|
||||
Logger.d("Service call: $domain.$service, $entityId, $data");
|
||||
Completer completer = Completer();
|
||||
Map serviceData = {};
|
||||
if (entityId != null) {
|
||||
serviceData["entity_id"] = entityId;
|
||||
}
|
||||
if (additionalServiceData != null && additionalServiceData.isNotEmpty) {
|
||||
serviceData.addAll(additionalServiceData);
|
||||
if (data != null && data.isNotEmpty) {
|
||||
serviceData.addAll(data);
|
||||
}
|
||||
if (serviceData.isNotEmpty)
|
||||
sendHTTPPost(
|
||||
|
@ -45,7 +45,7 @@ class MobileAppIntegrationManager {
|
||||
positiveText: "Restart now",
|
||||
negativeText: "Later",
|
||||
onPositive: () {
|
||||
ConnectionManager().callService("homeassistant","restart", null, null);
|
||||
ConnectionManager().callService(domain: "homeassistant", service: "restart");
|
||||
},
|
||||
));
|
||||
});
|
||||
|
@ -56,7 +56,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
positiveText: "Sure. Make it so",
|
||||
negativeText: "What?? No!",
|
||||
onPositive: () {
|
||||
ConnectionManager().callService("homeassistant", "restart", null, null);
|
||||
ConnectionManager().callService(domain: "homeassistant", service: "restart");
|
||||
},
|
||||
));
|
||||
}
|
||||
@ -68,7 +68,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
positiveText: "Sure. Make it so",
|
||||
negativeText: "What?? No!",
|
||||
onPositive: () {
|
||||
ConnectionManager().callService("homeassistant","stop", null, null);
|
||||
ConnectionManager().callService(domain: "homeassistant", service: "stop");
|
||||
},
|
||||
));
|
||||
}
|
||||
|
@ -89,10 +89,10 @@ class _PlayMediaPageState extends State<PlayMediaPage> {
|
||||
}
|
||||
Navigator.pop(context);
|
||||
ConnectionManager().callService(
|
||||
serviceDomain,
|
||||
"play_media",
|
||||
entity.entityId,
|
||||
{
|
||||
domain: serviceDomain,
|
||||
service: "play_media",
|
||||
entityId: entity.entityId,
|
||||
data: {
|
||||
"media_content_id": _mediaUrl,
|
||||
"media_content_type": _contentType
|
||||
}
|
||||
@ -100,10 +100,9 @@ class _PlayMediaPageState extends State<PlayMediaPage> {
|
||||
HomeAssistant().sendToPlayerId = entity.entityId;
|
||||
if (HomeAssistant().sendFromPlayerId != null && HomeAssistant().sendFromPlayerId != HomeAssistant().sendToPlayerId) {
|
||||
ConnectionManager().callService(
|
||||
HomeAssistant().sendFromPlayerId.split(".")[0],
|
||||
"turn_off",
|
||||
HomeAssistant().sendFromPlayerId,
|
||||
null
|
||||
domain: HomeAssistant().sendFromPlayerId.split(".")[0],
|
||||
service: "turn_off",
|
||||
entityId: HomeAssistant().sendFromPlayerId
|
||||
);
|
||||
HomeAssistant().sendFromPlayerId = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user