From 9f4f38dbefc452f6b32ba08525447a85c18a7f3d Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 24 Aug 2021 10:22:06 +0200 Subject: [PATCH] Use switch instead of toggle entity (#55111) --- .../components/thinkingcleaner/switch.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/thinkingcleaner/switch.py b/homeassistant/components/thinkingcleaner/switch.py index eb9f37cede6..75cfc51a511 100644 --- a/homeassistant/components/thinkingcleaner/switch.py +++ b/homeassistant/components/thinkingcleaner/switch.py @@ -8,10 +8,13 @@ from pythinkingcleaner import Discovery, ThinkingCleaner import voluptuous as vol from homeassistant import util -from homeassistant.components.switch import PLATFORM_SCHEMA +from homeassistant.components.switch import ( + PLATFORM_SCHEMA, + SwitchEntity, + SwitchEntityDescription, +) from homeassistant.const import CONF_HOST, STATE_OFF, STATE_ON import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100) @@ -19,16 +22,16 @@ MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100) MIN_TIME_TO_WAIT = timedelta(seconds=5) MIN_TIME_TO_LOCK_UPDATE = 5 -SWITCH_TYPES: tuple[ToggleEntityDescription, ...] = ( - ToggleEntityDescription( +SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = ( + SwitchEntityDescription( key="clean", name="Clean", ), - ToggleEntityDescription( + SwitchEntityDescription( key="dock", name="Dock", ), - ToggleEntityDescription( + SwitchEntityDescription( key="find", name="Find", ), @@ -61,10 +64,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities) -class ThinkingCleanerSwitch(ToggleEntity): +class ThinkingCleanerSwitch(SwitchEntity): """ThinkingCleaner Switch (dock, clean, find me).""" - def __init__(self, tc_object, update_devices, description: ToggleEntityDescription): + def __init__(self, tc_object, update_devices, description: SwitchEntityDescription): """Initialize the ThinkingCleaner.""" self.entity_description = description