diff --git a/homeassistant/components/wyoming/switch.py b/homeassistant/components/wyoming/switch.py index 7366a52efab6d..c012c60bc5aaa 100644 --- a/homeassistant/components/wyoming/switch.py +++ b/homeassistant/components/wyoming/switch.py @@ -51,6 +51,7 @@ async def async_added_to_hass(self) -> None: # Default to off self._attr_is_on = (state is not None) and (state.state == STATE_ON) + self._device.is_muted = self._attr_is_on async def async_turn_on(self, **kwargs: Any) -> None: """Turn on.""" diff --git a/tests/components/wyoming/test_satellite.py b/tests/components/wyoming/test_satellite.py index 900f272d69a09..4d39607158e92 100644 --- a/tests/components/wyoming/test_satellite.py +++ b/tests/components/wyoming/test_satellite.py @@ -23,10 +23,9 @@ from wyoming.wake import Detect, Detection from homeassistant.components import assist_pipeline, wyoming -from homeassistant.components.wyoming.data import WyomingService from homeassistant.components.wyoming.devices import SatelliteDevice -from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant +from homeassistant.const import STATE_ON +from homeassistant.core import HomeAssistant, State from homeassistant.helpers import intent as intent_helper from homeassistant.setup import async_setup_component @@ -444,17 +443,8 @@ async def test_satellite_muted(hass: HomeAssistant) -> None: """Test callback for a satellite that has been muted.""" on_muted_event = asyncio.Event() - original_make_satellite = wyoming._make_satellite original_on_muted = wyoming.satellite.WyomingSatellite.on_muted - def make_muted_satellite( - hass: HomeAssistant, config_entry: ConfigEntry, service: WyomingService - ): - satellite = original_make_satellite(hass, config_entry, service) - satellite.device.set_is_muted(True) - - return satellite - async def on_muted(self): # Trigger original function self._muted_changed_event.set() @@ -472,7 +462,10 @@ async def on_muted(self): "homeassistant.components.wyoming.data.load_wyoming_info", return_value=SATELLITE_INFO, ), - patch("homeassistant.components.wyoming._make_satellite", make_muted_satellite), + patch( + "homeassistant.components.wyoming.switch.WyomingSatelliteMuteSwitch.async_get_last_state", + return_value=State("switch.test_mute", STATE_ON), + ), patch( "homeassistant.components.wyoming.satellite.WyomingSatellite.on_muted", on_muted, diff --git a/tests/components/wyoming/test_switch.py b/tests/components/wyoming/test_switch.py index 160712bf3de7f..284aba2bd0540 100644 --- a/tests/components/wyoming/test_switch.py +++ b/tests/components/wyoming/test_switch.py @@ -40,3 +40,4 @@ async def test_muted( state = hass.states.get(muted_id) assert state is not None assert state.state == STATE_ON + assert satellite_device.is_muted