Entity Component to no longer generate automatic groups (#23789)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-01-07 17:30:53 +01:00
1 parent 13e6479b6e
commit 9aa02e35a7
41 files changed
+149 -377

No files matched your search

+2 -7
View File
@@ -4,7 +4,6 @@ import logging
import voluptuous as vol
from homeassistant.components import group
from homeassistant.const import (
SERVICE_TOGGLE,
SERVICE_TURN_OFF,
@@ -24,9 +23,6 @@ from homeassistant.loader import bind_hass
DOMAIN = "switch"
SCAN_INTERVAL = timedelta(seconds=30)
GROUP_NAME_ALL_SWITCHES = "all switches"
ENTITY_ID_ALL_SWITCHES = group.ENTITY_ID_FORMAT.format("all_switches")
ENTITY_ID_FORMAT = DOMAIN + ".{}"
ATTR_TODAY_ENERGY_KWH = "today_energy_kwh"
@@ -50,19 +46,18 @@ _LOGGER = logging.getLogger(__name__)
@bind_hass
def is_on(hass, entity_id=None):
def is_on(hass, entity_id):
"""Return if the switch is on based on the statemachine.
Async friendly.
"""
entity_id = entity_id or ENTITY_ID_ALL_SWITCHES
return hass.states.is_state(entity_id, STATE_ON)
async def async_setup(hass, config):
"""Track states and offer events for switches."""
component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, GROUP_NAME_ALL_SWITCHES
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)