Pass None instead of empty dict when registering entity services (#123878)

pull/123902/head
Erik Montnemery 2024-08-14 14:04:29 +02:00 committed by GitHub
parent 80f5683cd6
commit ea7e88d000
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 60 additions and 60 deletions

View File

@ -59,7 +59,7 @@ async def async_setup_entry(
platform = async_get_current_platform() platform = async_get_current_platform()
for service, method in CAMERA_SERVICES.items(): for service, method in CAMERA_SERVICES.items():
platform.async_register_entity_service(service, {}, method) platform.async_register_entity_service(service, None, method)
class AgentCamera(MjpegCamera): class AgentCamera(MjpegCamera):

View File

@ -124,9 +124,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
if not entities: if not entities:
return False return False
component.async_register_entity_service(SERVICE_TURN_OFF, {}, "async_turn_off") component.async_register_entity_service(SERVICE_TURN_OFF, None, "async_turn_off")
component.async_register_entity_service(SERVICE_TURN_ON, {}, "async_turn_on") component.async_register_entity_service(SERVICE_TURN_ON, None, "async_turn_on")
component.async_register_entity_service(SERVICE_TOGGLE, {}, "async_toggle") component.async_register_entity_service(SERVICE_TOGGLE, None, "async_toggle")
await component.async_add_entities(entities) await component.async_add_entities(entities)

View File

@ -87,7 +87,7 @@ async def async_setup_entry(
"adb_command", "adb_command",
) )
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_LEARN_SENDEVENT, {}, "learn_sendevent" SERVICE_LEARN_SENDEVENT, None, "learn_sendevent"
) )
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_DOWNLOAD, SERVICE_DOWNLOAD,

View File

@ -322,8 +322,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
}, },
trigger_service_handler, trigger_service_handler,
) )
component.async_register_entity_service(SERVICE_TOGGLE, {}, "async_toggle") component.async_register_entity_service(SERVICE_TOGGLE, None, "async_toggle")
component.async_register_entity_service(SERVICE_TURN_ON, {}, "async_turn_on") component.async_register_entity_service(SERVICE_TURN_ON, None, "async_turn_on")
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_TURN_OFF, SERVICE_TURN_OFF,
{vol.Optional(CONF_STOP_ACTIONS, default=DEFAULT_STOP_ACTIONS): cv.boolean}, {vol.Optional(CONF_STOP_ACTIONS, default=DEFAULT_STOP_ACTIONS): cv.boolean},

View File

@ -51,8 +51,8 @@ async def async_setup_entry(
async_add_entities(entities) async_add_entities(entities)
platform = entity_platform.async_get_current_platform() platform = entity_platform.async_get_current_platform()
platform.async_register_entity_service(SERVICE_RECORD, {}, "record") platform.async_register_entity_service(SERVICE_RECORD, None, "record")
platform.async_register_entity_service(SERVICE_TRIGGER, {}, "trigger_camera") platform.async_register_entity_service(SERVICE_TRIGGER, None, "trigger_camera")
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SAVE_RECENT_CLIPS, SERVICE_SAVE_RECENT_CLIPS,
{vol.Required(CONF_FILE_PATH): cv.string}, {vol.Required(CONF_FILE_PATH): cv.string},

View File

@ -52,7 +52,7 @@ async def async_setup_entry(
for service in ENTITY_SERVICES: for service in ENTITY_SERVICES:
platform.async_register_entity_service( platform.async_register_entity_service(
service, service,
{}, None,
f"async_{service}", f"async_{service}",
) )

View File

@ -54,7 +54,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_PRESS, SERVICE_PRESS,
{}, None,
"_async_press_action", "_async_press_action",
) )

View File

@ -431,13 +431,13 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, unsub_track_time_interval) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, unsub_track_time_interval)
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_ENABLE_MOTION, {}, "async_enable_motion_detection" SERVICE_ENABLE_MOTION, None, "async_enable_motion_detection"
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_DISABLE_MOTION, {}, "async_disable_motion_detection" SERVICE_DISABLE_MOTION, None, "async_disable_motion_detection"
) )
component.async_register_entity_service(SERVICE_TURN_OFF, {}, "async_turn_off") component.async_register_entity_service(SERVICE_TURN_OFF, None, "async_turn_off")
component.async_register_entity_service(SERVICE_TURN_ON, {}, "async_turn_on") component.async_register_entity_service(SERVICE_TURN_ON, None, "async_turn_on")
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_SNAPSHOT, CAMERA_SERVICE_SNAPSHOT, async_handle_snapshot_service SERVICE_SNAPSHOT, CAMERA_SERVICE_SNAPSHOT, async_handle_snapshot_service
) )

View File

@ -49,12 +49,12 @@ async def async_setup_platform(
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SEEK_FORWARD, SERVICE_SEEK_FORWARD,
{}, None,
"seek_forward", "seek_forward",
) )
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SEEK_BACKWARD, SERVICE_SEEK_BACKWARD,
{}, None,
"seek_backward", "seek_backward",
) )
platform.async_register_entity_service( platform.async_register_entity_service(

View File

@ -156,19 +156,19 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_TURN_ON, SERVICE_TURN_ON,
{}, None,
"async_turn_on", "async_turn_on",
[ClimateEntityFeature.TURN_ON], [ClimateEntityFeature.TURN_ON],
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_TURN_OFF, SERVICE_TURN_OFF,
{}, None,
"async_turn_off", "async_turn_off",
[ClimateEntityFeature.TURN_OFF], [ClimateEntityFeature.TURN_OFF],
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_TOGGLE, SERVICE_TOGGLE,
{}, None,
"async_toggle", "async_toggle",
[ClimateEntityFeature.TURN_OFF, ClimateEntityFeature.TURN_ON], [ClimateEntityFeature.TURN_OFF, ClimateEntityFeature.TURN_ON],
) )

View File

@ -122,9 +122,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection, DOMAIN, DOMAIN, STORAGE_FIELDS, STORAGE_FIELDS storage_collection, DOMAIN, DOMAIN, STORAGE_FIELDS, STORAGE_FIELDS
).async_setup(hass) ).async_setup(hass)
component.async_register_entity_service(SERVICE_INCREMENT, {}, "async_increment") component.async_register_entity_service(SERVICE_INCREMENT, None, "async_increment")
component.async_register_entity_service(SERVICE_DECREMENT, {}, "async_decrement") component.async_register_entity_service(SERVICE_DECREMENT, None, "async_decrement")
component.async_register_entity_service(SERVICE_RESET, {}, "async_reset") component.async_register_entity_service(SERVICE_RESET, None, "async_reset")
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_SET_VALUE, SERVICE_SET_VALUE,
{vol.Required(VALUE): cv.positive_int}, {vol.Required(VALUE): cv.positive_int},

View File

@ -158,11 +158,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
await component.async_setup(config) await component.async_setup(config)
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_OPEN_COVER, {}, "async_open_cover", [CoverEntityFeature.OPEN] SERVICE_OPEN_COVER, None, "async_open_cover", [CoverEntityFeature.OPEN]
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_CLOSE_COVER, {}, "async_close_cover", [CoverEntityFeature.CLOSE] SERVICE_CLOSE_COVER, None, "async_close_cover", [CoverEntityFeature.CLOSE]
) )
component.async_register_entity_service( component.async_register_entity_service(
@ -177,33 +177,33 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_STOP_COVER, {}, "async_stop_cover", [CoverEntityFeature.STOP] SERVICE_STOP_COVER, None, "async_stop_cover", [CoverEntityFeature.STOP]
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_TOGGLE, SERVICE_TOGGLE,
{}, None,
"async_toggle", "async_toggle",
[CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE], [CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE],
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_OPEN_COVER_TILT, SERVICE_OPEN_COVER_TILT,
{}, None,
"async_open_cover_tilt", "async_open_cover_tilt",
[CoverEntityFeature.OPEN_TILT], [CoverEntityFeature.OPEN_TILT],
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_CLOSE_COVER_TILT, SERVICE_CLOSE_COVER_TILT,
{}, None,
"async_close_cover_tilt", "async_close_cover_tilt",
[CoverEntityFeature.CLOSE_TILT], [CoverEntityFeature.CLOSE_TILT],
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_STOP_COVER_TILT, SERVICE_STOP_COVER_TILT,
{}, None,
"async_stop_cover_tilt", "async_stop_cover_tilt",
[CoverEntityFeature.STOP_TILT], [CoverEntityFeature.STOP_TILT],
) )
@ -221,7 +221,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_TOGGLE_COVER_TILT, SERVICE_TOGGLE_COVER_TILT,
{}, None,
"async_toggle_tilt", "async_toggle_tilt",
[CoverEntityFeature.OPEN_TILT | CoverEntityFeature.CLOSE_TILT], [CoverEntityFeature.OPEN_TILT | CoverEntityFeature.CLOSE_TILT],
) )

View File

@ -152,7 +152,7 @@ async def async_setup_entry(
) )
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_UPDATE_AUDYSSEY, SERVICE_UPDATE_AUDYSSEY,
{}, None,
f"async_{SERVICE_UPDATE_AUDYSSEY}", f"async_{SERVICE_UPDATE_AUDYSSEY}",
) )

View File

@ -65,7 +65,7 @@ async def async_setup_entry(
platform = entity_platform.async_get_current_platform() platform = entity_platform.async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_RAW_GET_POSITIONS, SERVICE_RAW_GET_POSITIONS,
{}, None,
"async_raw_get_positions", "async_raw_get_positions",
supports_response=SupportsResponse.ONLY, supports_response=SupportsResponse.ONLY,
) )

View File

@ -40,7 +40,7 @@ async def async_setup_entry(
platform = async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_IDENTIFY, SERVICE_IDENTIFY,
{}, None,
ElgatoLight.async_identify.__name__, ElgatoLight.async_identify.__name__,
) )

View File

@ -56,7 +56,7 @@ async def async_setup_entry(
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SENSOR_COUNTER_REFRESH, SERVICE_SENSOR_COUNTER_REFRESH,
{}, None,
"async_counter_refresh", "async_counter_refresh",
) )
platform.async_register_entity_service( platform.async_register_entity_service(
@ -71,7 +71,7 @@ async def async_setup_entry(
) )
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SENSOR_ZONE_TRIGGER, SERVICE_SENSOR_ZONE_TRIGGER,
{}, None,
"async_zone_trigger", "async_zone_trigger",
) )

View File

@ -112,7 +112,7 @@ async def async_setup_entry(
platform = async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_WAKE_DEVICE, {}, "perform_wake_device" SERVICE_WAKE_DEVICE, None, "perform_wake_device"
) )

View File

@ -139,11 +139,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
[FanEntityFeature.TURN_ON], [FanEntityFeature.TURN_ON],
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_TURN_OFF, {}, "async_turn_off", [FanEntityFeature.TURN_OFF] SERVICE_TURN_OFF, None, "async_turn_off", [FanEntityFeature.TURN_OFF]
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_TOGGLE, SERVICE_TOGGLE,
{}, None,
"async_toggle", "async_toggle",
[FanEntityFeature.TURN_OFF, FanEntityFeature.TURN_ON], [FanEntityFeature.TURN_OFF, FanEntityFeature.TURN_ON],
) )

View File

@ -42,13 +42,13 @@ async def async_setup_entry(
platform = entity_platform.async_get_current_platform() platform = entity_platform.async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SET_AWAY_MODE, {}, "async_set_mode_away" SERVICE_SET_AWAY_MODE, None, "async_set_mode_away"
) )
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SET_HOME_MODE, {}, "async_set_mode_home" SERVICE_SET_HOME_MODE, None, "async_set_mode_home"
) )
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_RUN_HEALTH_TEST, {}, "async_run_health_test" SERVICE_RUN_HEALTH_TEST, None, "async_run_health_test"
) )
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SET_SLEEP_MODE, SERVICE_SET_SLEEP_MODE,

View File

@ -75,7 +75,7 @@ async def async_setup_entry(
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SYNC, SERVICE_SYNC,
{}, None,
"sync", "sync",
) )
platform.async_register_entity_service( platform.async_register_entity_service(

View File

@ -83,7 +83,7 @@ async def async_setup_entry(
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_BOOST_HEATING_OFF, SERVICE_BOOST_HEATING_OFF,
{}, None,
"async_heating_boost_off", "async_heating_boost_off",
) )

View File

@ -92,9 +92,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
) )
await component.async_setup(config) await component.async_setup(config)
component.async_register_entity_service(SERVICE_TURN_ON, {}, "async_turn_on") component.async_register_entity_service(SERVICE_TURN_ON, None, "async_turn_on")
component.async_register_entity_service(SERVICE_TURN_OFF, {}, "async_turn_off") component.async_register_entity_service(SERVICE_TURN_OFF, None, "async_turn_off")
component.async_register_entity_service(SERVICE_TOGGLE, {}, "async_toggle") component.async_register_entity_service(SERVICE_TOGGLE, None, "async_toggle")
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_SET_MODE, SERVICE_SET_MODE,
{vol.Required(ATTR_MODE): cv.string}, {vol.Required(ATTR_MODE): cv.string},

View File

@ -110,7 +110,7 @@ async def async_setup_entry(
) )
async_add_entities(entities) async_add_entities(entities)
platform = entity_platform.async_get_current_platform() platform = entity_platform.async_get_current_platform()
platform.async_register_entity_service(SERVICE_RESUME, {}, "resume") platform.async_register_entity_service(SERVICE_RESUME, None, "resume")
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_START_WATERING, SCHEMA_START_WATERING, "start_watering" SERVICE_START_WATERING, SCHEMA_START_WATERING, "start_watering"
) )

View File

@ -138,11 +138,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
schema=RELOAD_SERVICE_SCHEMA, schema=RELOAD_SERVICE_SCHEMA,
) )
component.async_register_entity_service(SERVICE_TURN_ON, {}, "async_turn_on") component.async_register_entity_service(SERVICE_TURN_ON, None, "async_turn_on")
component.async_register_entity_service(SERVICE_TURN_OFF, {}, "async_turn_off") component.async_register_entity_service(SERVICE_TURN_OFF, None, "async_turn_off")
component.async_register_entity_service(SERVICE_TOGGLE, {}, "async_toggle") component.async_register_entity_service(SERVICE_TOGGLE, None, "async_toggle")
return True return True

View File

@ -123,7 +123,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
schema=RELOAD_SERVICE_SCHEMA, schema=RELOAD_SERVICE_SCHEMA,
) )
component.async_register_entity_service(SERVICE_PRESS, {}, "_async_press_action") component.async_register_entity_service(SERVICE_PRESS, None, "_async_press_action")
return True return True

View File

@ -157,9 +157,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"async_set_value", "async_set_value",
) )
component.async_register_entity_service(SERVICE_INCREMENT, {}, "async_increment") component.async_register_entity_service(SERVICE_INCREMENT, None, "async_increment")
component.async_register_entity_service(SERVICE_DECREMENT, {}, "async_decrement") component.async_register_entity_service(SERVICE_DECREMENT, None, "async_decrement")
return True return True

View File

@ -183,13 +183,13 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_SELECT_FIRST, SERVICE_SELECT_FIRST,
{}, None,
InputSelect.async_first.__name__, InputSelect.async_first.__name__,
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_SELECT_LAST, SERVICE_SELECT_LAST,
{}, None,
InputSelect.async_last.__name__, InputSelect.async_last.__name__,
) )

View File

@ -161,7 +161,7 @@ async def async_setup_platform(
}, },
"set_mode", "set_mode",
) )
platform.async_register_entity_service(SERVICE_UPDATE_DSP, {}, "update_dsp") platform.async_register_entity_service(SERVICE_UPDATE_DSP, None, "update_dsp")
def add_service(name, which, option): def add_service(name, which, option):
options = DSP_OPTION_MAPPING[which] options = DSP_OPTION_MAPPING[which]

View File

@ -39,15 +39,15 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_START_MOWING, SERVICE_START_MOWING,
{}, None,
"async_start_mowing", "async_start_mowing",
[LawnMowerEntityFeature.START_MOWING], [LawnMowerEntityFeature.START_MOWING],
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_PAUSE, {}, "async_pause", [LawnMowerEntityFeature.PAUSE] SERVICE_PAUSE, None, "async_pause", [LawnMowerEntityFeature.PAUSE]
) )
component.async_register_entity_service( component.async_register_entity_service(
SERVICE_DOCK, {}, "async_dock", [LawnMowerEntityFeature.DOCK] SERVICE_DOCK, None, "async_dock", [LawnMowerEntityFeature.DOCK]
) )
return True return True