Remove "sonos" prefix for Sonos switch entity_ids (#70698)

pull/70383/head^2
jjlawren 2022-04-25 21:01:54 -05:00 committed by GitHub
parent 083e40a00d
commit 5bcc83f6f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 19 deletions

View File

@ -150,9 +150,6 @@ class SonosSwitchEntity(SonosPollingEntity, SwitchEntity):
"""Initialize the switch."""
super().__init__(speaker)
self.feature_type = feature_type
self.entity_id = ENTITY_ID_FORMAT.format(
f"sonos_{speaker.zone_name}_{FRIENDLY_NAMES[feature_type]}"
)
self.needs_coordinator = feature_type in COORDINATOR_FEATURES
self._attr_entity_category = EntityCategory.CONFIG
self._attr_name = f"{speaker.zone_name} {FRIENDLY_NAMES[feature_type]}"

View File

@ -28,12 +28,12 @@ async def test_entity_registry(hass, async_autosetup_sonos):
assert "media_player.zone_a" in entity_registry.entities
assert "switch.sonos_alarm_14" in entity_registry.entities
assert "switch.sonos_zone_a_status_light" in entity_registry.entities
assert "switch.sonos_zone_a_night_sound" in entity_registry.entities
assert "switch.sonos_zone_a_speech_enhancement" in entity_registry.entities
assert "switch.sonos_zone_a_subwoofer_enabled" in entity_registry.entities
assert "switch.sonos_zone_a_surround_enabled" in entity_registry.entities
assert "switch.sonos_zone_a_touch_controls" in entity_registry.entities
assert "switch.zone_a_status_light" in entity_registry.entities
assert "switch.zone_a_night_sound" in entity_registry.entities
assert "switch.zone_a_speech_enhancement" in entity_registry.entities
assert "switch.zone_a_subwoofer_enabled" in entity_registry.entities
assert "switch.zone_a_surround_enabled" in entity_registry.entities
assert "switch.zone_a_touch_controls" in entity_registry.entities
async def test_switch_attributes(hass, async_autosetup_sonos, soco):
@ -51,32 +51,30 @@ async def test_switch_attributes(hass, async_autosetup_sonos, soco):
assert alarm_state.attributes.get(ATTR_PLAY_MODE) == "SHUFFLE_NOREPEAT"
assert not alarm_state.attributes.get(ATTR_INCLUDE_LINKED_ZONES)
night_sound = entity_registry.entities["switch.sonos_zone_a_night_sound"]
night_sound = entity_registry.entities["switch.zone_a_night_sound"]
night_sound_state = hass.states.get(night_sound.entity_id)
assert night_sound_state.state == STATE_ON
speech_enhancement = entity_registry.entities[
"switch.sonos_zone_a_speech_enhancement"
]
speech_enhancement = entity_registry.entities["switch.zone_a_speech_enhancement"]
speech_enhancement_state = hass.states.get(speech_enhancement.entity_id)
assert speech_enhancement_state.state == STATE_ON
crossfade = entity_registry.entities["switch.sonos_zone_a_crossfade"]
crossfade = entity_registry.entities["switch.zone_a_crossfade"]
crossfade_state = hass.states.get(crossfade.entity_id)
assert crossfade_state.state == STATE_ON
# Ensure switches are disabled
status_light = entity_registry.entities["switch.sonos_zone_a_status_light"]
status_light = entity_registry.entities["switch.zone_a_status_light"]
assert hass.states.get(status_light.entity_id) is None
touch_controls = entity_registry.entities["switch.sonos_zone_a_touch_controls"]
touch_controls = entity_registry.entities["switch.zone_a_touch_controls"]
assert hass.states.get(touch_controls.entity_id) is None
sub_switch = entity_registry.entities["switch.sonos_zone_a_subwoofer_enabled"]
sub_switch = entity_registry.entities["switch.zone_a_subwoofer_enabled"]
sub_switch_state = hass.states.get(sub_switch.entity_id)
assert sub_switch_state.state == STATE_OFF
surround_switch = entity_registry.entities["switch.sonos_zone_a_surround_enabled"]
surround_switch = entity_registry.entities["switch.zone_a_surround_enabled"]
surround_switch_state = hass.states.get(surround_switch.entity_id)
assert surround_switch_state.state == STATE_ON
@ -106,7 +104,7 @@ async def test_switch_attributes(hass, async_autosetup_sonos, soco):
status_light_state = hass.states.get(status_light.entity_id)
assert status_light_state.state == STATE_ON
touch_controls = entity_registry.entities["switch.sonos_zone_a_touch_controls"]
touch_controls = entity_registry.entities["switch.zone_a_touch_controls"]
touch_controls_state = hass.states.get(touch_controls.entity_id)
assert touch_controls_state.state == STATE_ON