diff --git a/lib/entities/alarm_control_panel/widgets/alarm_control_panel_controls.widget.dart b/lib/entities/alarm_control_panel/widgets/alarm_control_panel_controls.widget.dart index 0d2bb92..ff9e707 100644 --- a/lib/entities/alarm_control_panel/widgets/alarm_control_panel_controls.widget.dart +++ b/lib/entities/alarm_control_panel/widgets/alarm_control_panel_controls.widget.dart @@ -26,10 +26,10 @@ class _AlarmControlPanelControlsWidgetWidgetState extends State { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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); }); } diff --git a/lib/entities/cover/widgets/cover_controls.widget.dart b/lib/entities/cover/widgets/cover_controls.widget.dart index 0510c47..5075158 100644 --- a/lib/entities/cover/widgets/cover_controls.widget.dart +++ b/lib/entities/cover/widgets/cover_controls.widget.dart @@ -18,7 +18,7 @@ class _CoverControlWidgetState extends State { 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 { 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 { 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 diff --git a/lib/entities/cover/widgets/cover_state.dart b/lib/entities/cover/widgets/cover_state.dart index 77bed97..b52e60f 100644 --- a/lib/entities/cover/widgets/cover_state.dart +++ b/lib/entities/cover/widgets/cover_state.dart @@ -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 diff --git a/lib/entities/date_time/date_time_entity.class.dart b/lib/entities/date_time/date_time_entity.class.dart index 2db63bd..2146d71 100644 --- a/lib/entities/date_time/date_time_entity.class.dart +++ b/lib/entities/date_time/date_time_entity.class.dart @@ -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); } } \ No newline at end of file diff --git a/lib/entities/entity_wrapper.class.dart b/lib/entities/entity_wrapper.class.dart index 016d004..026abf0 100644 --- a/lib/entities/entity_wrapper.class.dart +++ b/lib/entities/entity_wrapper.class.dart @@ -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; } diff --git a/lib/entities/fan/widgets/fan_controls.dart b/lib/entities/fan/widgets/fan_controls.dart index dae4376..aebe235 100644 --- a/lib/entities/fan/widgets/fan_controls.dart +++ b/lib/entities/fan/widgets/fan_controls.dart @@ -25,8 +25,11 @@ class _FanControlsWidgetState extends State { _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 { _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 { _tmpSpeed = value; _changedHere = true; ConnectionManager().callService( - "fan", "set_speed", entity.entityId, - {"speed": value}); + domain: "fan", + service: "set_speed", + entityId: entity.entityId, + data: {"speed": value} + ); }); } diff --git a/lib/entities/flat_service_button.widget.dart b/lib/entities/flat_service_button.widget.dart index df1adcc..097513d 100644 --- a/lib/entities/flat_service_button.widget.dart +++ b/lib/entities/flat_service_button.widget.dart @@ -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 diff --git a/lib/entities/light/widgets/light_controls.dart b/lib/entities/light/widgets/light_controls.dart index 80da7cf..13f45eb 100644 --- a/lib/entities/light/widgets/light_controls.dart +++ b/lib/entities/light/widgets/light_controls.dart @@ -29,8 +29,11 @@ class _LightControlsWidgetState extends State { _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 { _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 { _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 { 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 { _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"} + ); } }); } diff --git a/lib/entities/lock/widgets/lock_state.dart b/lib/entities/lock/widgets/lock_state.dart index fe98dbc..58287ca 100644 --- a/lib/entities/lock/widgets/lock_state.dart +++ b/lib/entities/lock/widgets/lock_state.dart @@ -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 diff --git a/lib/entities/media_player/widgets/media_player_seek_bar.widget.dart b/lib/entities/media_player/widgets/media_player_seek_bar.widget.dart index e3cf446..edfb513 100644 --- a/lib/entities/media_player/widgets/media_player_seek_bar.widget.dart +++ b/lib/entities/media_player/widgets/media_player_seek_bar.widget.dart @@ -57,10 +57,10 @@ class _MediaPlayerSeekBarState extends State { 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 { 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; diff --git a/lib/entities/media_player/widgets/media_player_widgets.dart b/lib/entities/media_player/widgets/media_player_widgets.dart index 9f0290e..fd7e79f 100644 --- a/lib/entities/media_player/widgets/media_player_widgets.dart +++ b/lib/entities/media_player/widgets/media_player_widgets.dart @@ -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 { 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 { 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"} + ); }); } diff --git a/lib/entities/select/widgets/select_state.dart b/lib/entities/select/widgets/select_state.dart index 8c6f40d..0d9b3d0 100644 --- a/lib/entities/select/widgets/select_state.dart +++ b/lib/entities/select/widgets/select_state.dart @@ -11,8 +11,12 @@ class SelectStateWidget extends StatefulWidget { class _SelectStateWidgetState extends State { 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 diff --git a/lib/entities/slider/widgets/slider_controls.dart b/lib/entities/slider/widgets/slider_controls.dart index 74faff9..19b9983 100644 --- a/lib/entities/slider/widgets/slider_controls.dart +++ b/lib/entities/slider/widgets/slider_controls.dart @@ -18,8 +18,12 @@ class _SliderControlsWidgetState extends State { _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 diff --git a/lib/entities/switch/widget/switch_state.dart b/lib/entities/switch/widget/switch_state.dart index 2002e3f..73a1d09 100644 --- a/lib/entities/switch/widget/switch_state.dart +++ b/lib/entities/switch/widget/switch_state.dart @@ -39,7 +39,10 @@ class _SwitchStateWidgetState extends State { 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 diff --git a/lib/entities/text/widgets/text_input_state.dart b/lib/entities/text/widgets/text_input_state.dart index 9463f45..f82cf15 100644 --- a/lib/entities/text/widgets/text_input_state.dart +++ b/lib/entities/text/widgets/text_input_state.dart @@ -26,8 +26,12 @@ class _TextInputStateWidgetState extends State { 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; diff --git a/lib/entities/vacuum/widgets/vacuum_controls.dart b/lib/entities/vacuum/widgets/vacuum_controls.dart index 14212e4..42764de 100644 --- a/lib/entities/vacuum/widgets/vacuum_controls.dart +++ b/lib/entities/vacuum/widgets/vacuum_controls.dart @@ -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} ) ), ); diff --git a/lib/managers/connection_manager.class.dart b/lib/managers/connection_manager.class.dart index 2012889..df72960 100644 --- a/lib/managers/connection_manager.class.dart +++ b/lib/managers/connection_manager.class.dart @@ -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( diff --git a/lib/managers/mobile_app_integration_manager.class.dart b/lib/managers/mobile_app_integration_manager.class.dart index 6b654e2..e277e2d 100644 --- a/lib/managers/mobile_app_integration_manager.class.dart +++ b/lib/managers/mobile_app_integration_manager.class.dart @@ -45,7 +45,7 @@ class MobileAppIntegrationManager { positiveText: "Restart now", negativeText: "Later", onPositive: () { - ConnectionManager().callService("homeassistant","restart", null, null); + ConnectionManager().callService(domain: "homeassistant", service: "restart"); }, )); }); diff --git a/lib/pages/integration_settings.page.dart b/lib/pages/integration_settings.page.dart index c3c3ba4..3fc73e0 100644 --- a/lib/pages/integration_settings.page.dart +++ b/lib/pages/integration_settings.page.dart @@ -56,7 +56,7 @@ class _IntegrationSettingsPageState extends State { 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 { positiveText: "Sure. Make it so", negativeText: "What?? No!", onPositive: () { - ConnectionManager().callService("homeassistant","stop", null, null); + ConnectionManager().callService(domain: "homeassistant", service: "stop"); }, )); } diff --git a/lib/pages/play_media.page.dart b/lib/pages/play_media.page.dart index b6a651b..8eddd4a 100644 --- a/lib/pages/play_media.page.dart +++ b/lib/pages/play_media.page.dart @@ -89,21 +89,20 @@ class _PlayMediaPageState extends State { } Navigator.pop(context); ConnectionManager().callService( - serviceDomain, - "play_media", - entity.entityId, - { - "media_content_id": _mediaUrl, - "media_content_type": _contentType - } + domain: serviceDomain, + service: "play_media", + entityId: entity.entityId, + data: { + "media_content_id": _mediaUrl, + "media_content_type": _contentType + } ); 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; }