"""Switch implementation for Wireless Sensor Tags (wirelesstag.net)."""
import voluptuous as vol

from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
from homeassistant.const import CONF_MONITORED_CONDITIONS
import homeassistant.helpers.config_validation as cv

from . import DOMAIN as WIRELESSTAG_DOMAIN, WirelessTagBaseSensor

ARM_TEMPERATURE = "temperature"
ARM_HUMIDITY = "humidity"
ARM_MOTION = "motion"
ARM_LIGHT = "light"
ARM_MOISTURE = "moisture"

# Switch types: Name, tag sensor type
SWITCH_TYPES = {
    ARM_TEMPERATURE: ["Arm Temperature", "temperature"],
    ARM_HUMIDITY: ["Arm Humidity", "humidity"],
    ARM_MOTION: ["Arm Motion", "motion"],
    ARM_LIGHT: ["Arm Light", "light"],
    ARM_MOISTURE: ["Arm Moisture", "moisture"],
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_MONITORED_CONDITIONS, default=[]): vol.All(
            cv.ensure_list, [vol.In(SWITCH_TYPES)]
        )
    }
)


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up switches for a Wireless Sensor Tags."""
    platform = hass.data.get(WIRELESSTAG_DOMAIN)

    switches = []
    tags = platform.load_tags()
    for switch_type in config.get(CONF_MONITORED_CONDITIONS):
        for tag in tags.values():
            if switch_type in tag.allowed_monitoring_types:
                switches.append(WirelessTagSwitch(platform, tag, switch_type))

    add_entities(switches, True)


class WirelessTagSwitch(WirelessTagBaseSensor, SwitchEntity):
    """A switch implementation for Wireless Sensor Tags."""

    def __init__(self, api, tag, switch_type):
        """Initialize a switch for Wireless Sensor Tag."""
        super().__init__(api, tag)
        self._switch_type = switch_type
        self.sensor_type = SWITCH_TYPES[self._switch_type][1]
        self._name = f"{self._tag.name} {SWITCH_TYPES[self._switch_type][0]}"

    def turn_on(self, **kwargs):
        """Turn on the switch."""
        self._api.arm(self)

    def turn_off(self, **kwargs):
        """Turn on the switch."""
        self._api.disarm(self)

    @property
    def is_on(self) -> bool:
        """Return True if entity is on."""
        return self._state

    def updated_state_value(self):
        """Provide formatted value."""
        return self.principal_value

    @property
    def principal_value(self):
        """Provide actual value of switch."""
        attr_name = f"is_{self.sensor_type}_sensor_armed"
        return getattr(self._tag, attr_name, False)

@@ -65,16 +65,52 @@
 et).%22%22%22%0A
+from __future__ import annotations%0A%0A
 import v
@@ -171,16 +171,22 @@
  import 
+(%0A    
 PLATFORM
@@ -193,16 +193,20 @@
 _SCHEMA,
+%0A   
  SwitchE
@@ -210,16 +210,48 @@
 chEntity
+,%0A    SwitchEntityDescription,%0A)
 %0Afrom ho
@@ -426,425 +426,566 @@
 or%0A%0A
-ARM_TEMPERATURE = %22temperature%22%0AARM_HUMIDITY = %22humidity%22%0AARM_MOTION = %22motion%22%0AARM_LIGHT = %22light%22%0AARM_MOISTURE = %22moisture%22%0A%0A#
+SWITCH_TYPES: tuple%5BSwitchEntityDescription, ...%5D = (%0A   
  Switch
- types: Name, tag sensor type%0ASWITCH_TYPES = %7B%0A    ARM_TEMPERATURE: %5B%22Arm Temperature%22, %22temperature%22%5D,%0A    ARM_HUMIDITY: %5B%22Arm Humidity%22, %22humidity%22%5D,%0A    ARM_MOTION: %5B%22Arm Motion%22, %22motion%22%5D,%0A    ARM_LIGHT: %5B%22Arm Light%22, %22light%22%5D,%0A    ARM_MOISTURE: %5B%22Arm Moisture%22, %22moisture%22%5D,%0A%7D
+EntityDescription(%0A        key=%22temperature%22,%0A        name=%22Arm Temperature%22,%0A    ),%0A    SwitchEntityDescription(%0A        key=%22humidity%22,%0A        name=%22Arm Humidity%22,%0A    ),%0A    SwitchEntityDescription(%0A        key=%22motion%22,%0A        name=%22Arm Motion%22,%0A    ),%0A    SwitchEntityDescription(%0A        key=%22light%22,%0A        name=%22Arm Light%22,%0A    ),%0A    SwitchEntityDescription(%0A        key=%22moisture%22,%0A        name=%22Arm Moisture%22,%0A    ),%0A)%0A%0ASWITCH_KEYS: list%5Bstr%5D = %5Bdesc.key for desc in SWITCH_TYPES%5D
 %0A%0APL
@@ -1143,20 +1143,19 @@
 (SWITCH_
-TYPE
+KEY
 S)%5D%0A    
@@ -1347,26 +1347,8 @@
 N)%0A%0A
-    switches = %5B%5D%0A
     
@@ -1383,38 +1383,38 @@
     
-for switch_type in
+monitored_conditions =
  config
-.get(
+%5B
 CONF
@@ -1434,18 +1434,88 @@
 NDITIONS
+%5D%0A    entities = %5B%0A        WirelessTagSwitch(platform, tag, description
 )
-:
 %0A       
@@ -1543,148 +1543,165 @@
 es()
-:
 %0A      
+  for description in SWITCH_TYPES%0A
       
+  
 if 
-switch_type in tag.allowed_m
+description.key in monitored_c
 on
+d
 it
-oring_types:%0A                switches.append(WirelessTagSwitch(platform, tag, switch_type))
+ions%0A        and description.key in tag.allowed_monitoring_types%0A    %5D
 %0A%0A  
@@ -1715,22 +1715,22 @@
 ntities(
-switch
+entiti
 es, True
@@ -1889,27 +1889,52 @@
 i, tag, 
-switch_type
+description: SwitchEntityDescription
 ):%0A     
@@ -2039,96 +2039,40 @@
 elf.
-_switch_type = switch_type%0A        self.sensor_type = SWITCH_TYPES%5Bself._switch_type%5D%5B1%5D
+entity_description = description
 %0A   
@@ -2113,42 +2113,24 @@
 e%7D %7B
-SWITCH_TYPES%5Bself._switch_type%5D%5B0%5D
+description.name
 %7D%22%0A%0A
@@ -2676,19 +2676,30 @@
 elf.
-s
 en
-sor_type
+tity_description.key
 %7D_se

Use EntityDescription - wirelesstag (#55065)