mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Migrate google assistant to has entity name (#96593)
* Migrate google assistant to has entity name * Fix tests * Add device name * Update homeassistant/components/google_assistant/button.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
7ec506907c
commit
28540b0cb2
@ -34,14 +34,19 @@ async def async_setup_entry(
|
|||||||
class SyncButton(ButtonEntity):
|
class SyncButton(ButtonEntity):
|
||||||
"""Representation of a synchronization button."""
|
"""Representation of a synchronization button."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
_attr_translation_key = "sync_devices"
|
||||||
|
|
||||||
def __init__(self, project_id: str, google_config: GoogleConfig) -> None:
|
def __init__(self, project_id: str, google_config: GoogleConfig) -> None:
|
||||||
"""Initialize button."""
|
"""Initialize button."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._google_config = google_config
|
self._google_config = google_config
|
||||||
self._attr_entity_category = EntityCategory.DIAGNOSTIC
|
self._attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
self._attr_unique_id = f"{project_id}_sync"
|
self._attr_unique_id = f"{project_id}_sync"
|
||||||
self._attr_name = "Synchronize Devices"
|
self._attr_device_info = DeviceInfo(
|
||||||
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, project_id)})
|
identifiers={(DOMAIN, project_id)},
|
||||||
|
name="Google Assistant",
|
||||||
|
)
|
||||||
|
|
||||||
async def async_press(self) -> None:
|
async def async_press(self) -> None:
|
||||||
"""Press the button."""
|
"""Press the button."""
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"entity": {
|
||||||
|
"button": {
|
||||||
|
"sync_devices": {
|
||||||
|
"name": "Synchronize devices"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"services": {
|
"services": {
|
||||||
"request_sync": {
|
"request_sync": {
|
||||||
"name": "Request sync",
|
"name": "Request sync",
|
||||||
|
@ -24,7 +24,7 @@ async def test_sync_button(hass: HomeAssistant, hass_owner_user: MockUser) -> No
|
|||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state = hass.states.get("button.synchronize_devices")
|
state = hass.states.get("button.google_assistant_synchronize_devices")
|
||||||
assert state
|
assert state
|
||||||
|
|
||||||
config_entry = hass.config_entries.async_entries("google_assistant")[0]
|
config_entry = hass.config_entries.async_entries("google_assistant")[0]
|
||||||
@ -36,7 +36,7 @@ async def test_sync_button(hass: HomeAssistant, hass_owner_user: MockUser) -> No
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"button",
|
"button",
|
||||||
"press",
|
"press",
|
||||||
{"entity_id": "button.synchronize_devices"},
|
{"entity_id": "button.google_assistant_synchronize_devices"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
@ -48,7 +48,7 @@ async def test_sync_button(hass: HomeAssistant, hass_owner_user: MockUser) -> No
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"button",
|
"button",
|
||||||
"press",
|
"press",
|
||||||
{"entity_id": "button.synchronize_devices"},
|
{"entity_id": "button.google_assistant_synchronize_devices"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user