|
25 | 25 | SERVICE_PLAY_QUEUE_ITEM, |
26 | 26 | SERVICE_REMOVE_QUEUE_ITEM, |
27 | 27 | SERVICE_SEND_COMMAND, |
| 28 | + SERVICE_UNFAVORITE_CURRENT_ITEM, |
28 | 29 | ) |
29 | 30 | from .schemas import ( |
30 | 31 | MOVE_QUEUE_ITEM_DOWN_SERVICE_SCHEMA, |
|
34 | 35 | QUEUE_ITEMS_SERVICE_SCHEMA, |
35 | 36 | REMOVE_QUEUE_ITEM_SERVICE_SCHEMA, |
36 | 37 | SEND_COMMAND_SERVICE_SCHEMA, |
| 38 | + UNFAVORITE_CURRENT_ITEM_SERVICE_SCHEMA, |
37 | 39 | ) |
38 | 40 |
|
39 | 41 | if TYPE_CHECKING: |
@@ -94,6 +96,13 @@ def register_actions(hass) -> None: |
94 | 96 | schema=SEND_COMMAND_SERVICE_SCHEMA, |
95 | 97 | supports_response=SupportsResponse.OPTIONAL, |
96 | 98 | ) |
| 99 | + hass.services.async_register( |
| 100 | + DOMAIN, |
| 101 | + SERVICE_UNFAVORITE_CURRENT_ITEM, |
| 102 | + unfavorite_current_item, |
| 103 | + schema=UNFAVORITE_CURRENT_ITEM_SERVICE_SCHEMA, |
| 104 | + supports_response=SupportsResponse.NONE, |
| 105 | + ) |
97 | 106 |
|
98 | 107 |
|
99 | 108 | def _get_mass_entity_config_entry_id(hass, entity_id): |
@@ -204,3 +213,10 @@ async def send_command(call: ServiceCall): |
204 | 213 | entry = hass.config_entries.async_get_entry(entry_id) |
205 | 214 | actions = entry.runtime_data.actions |
206 | 215 | return await actions.send_command(call) |
| 216 | + |
| 217 | +async def unfavorite_current_item(call: ServiceCall): |
| 218 | + """Service wrapper to unfavorite currently playing item.""" |
| 219 | + entity_id = call.data[ATTR_PLAYER_ENTITY] |
| 220 | + hass = call.hass |
| 221 | + actions = get_entity_actions_controller(hass, entity_id) |
| 222 | + await actions.unfavorite_item(call) |
0 commit comments