diff --git a/homeassistant/components/alarm_control_panel/trigger.py b/homeassistant/components/alarm_control_panel/trigger.py index 1930290082386..d970ea9ec6bb7 100644 --- a/homeassistant/components/alarm_control_panel/trigger.py +++ b/homeassistant/components/alarm_control_panel/trigger.py @@ -14,7 +14,7 @@ def supports_feature(hass: HomeAssistant, entity_id: str, features: int) -> bool: - """Get the device class of an entity or UNDEFINED if not found.""" + """Test if an entity supports the specified features.""" try: return bool(get_supported_features(hass, entity_id) & features) except HomeAssistantError: @@ -39,7 +39,7 @@ def entity_filter(self, entities: set[str]) -> set[str]: def make_entity_state_trigger_required_features( domain: str, to_state: str, required_features: int ) -> type[EntityTargetStateTriggerBase]: - """Create an entity state trigger class.""" + """Create an entity state trigger class with required feature filtering.""" class CustomTrigger(EntityStateTriggerRequiredFeatures): """Trigger for entity state changes.""" diff --git a/homeassistant/components/light/conditions.yaml b/homeassistant/components/light/conditions.yaml index cfcb47488365e..a35a581ffc15f 100644 --- a/homeassistant/components/light/conditions.yaml +++ b/homeassistant/components/light/conditions.yaml @@ -1,18 +1,4 @@ -is_off: - target: - entity: - domain: light - fields: - behavior: - required: true - default: any - selector: - select: - translation_key: condition_behavior - options: - - all - - any -is_on: +.condition_common: &condition_common target: entity: domain: light @@ -26,3 +12,6 @@ is_on: options: - all - any + +is_off: *condition_common +is_on: *condition_common diff --git a/homeassistant/components/opower/manifest.json b/homeassistant/components/opower/manifest.json index 0e23c3c9c3d75..19a692fa6430a 100644 --- a/homeassistant/components/opower/manifest.json +++ b/homeassistant/components/opower/manifest.json @@ -9,5 +9,5 @@ "iot_class": "cloud_polling", "loggers": ["opower"], "quality_scale": "bronze", - "requirements": ["opower==0.16.2"] + "requirements": ["opower==0.16.3"] } diff --git a/homeassistant/components/sunricher_dali/manifest.json b/homeassistant/components/sunricher_dali/manifest.json index 214c822fc0140..80524a9bfb117 100644 --- a/homeassistant/components/sunricher_dali/manifest.json +++ b/homeassistant/components/sunricher_dali/manifest.json @@ -11,5 +11,5 @@ "documentation": "https://www.home-assistant.io/integrations/sunricher_dali", "iot_class": "local_push", "quality_scale": "silver", - "requirements": ["PySrDaliGateway==0.18.0"] + "requirements": ["PySrDaliGateway==0.19.3"] } diff --git a/homeassistant/components/utility_meter/__init__.py b/homeassistant/components/utility_meter/__init__.py index b08f51f2b84bf..834e148a1362e 100644 --- a/homeassistant/components/utility_meter/__init__.py +++ b/homeassistant/components/utility_meter/__init__.py @@ -9,8 +9,8 @@ from homeassistant.components.select import DOMAIN as SELECT_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_ENTITY_ID, CONF_NAME, CONF_UNIQUE_ID, Platform -from homeassistant.core import HomeAssistant, split_entity_id +from homeassistant.const import CONF_NAME, CONF_UNIQUE_ID, Platform +from homeassistant.core import HomeAssistant from homeassistant.helpers import ( config_validation as cv, discovery, @@ -20,7 +20,6 @@ async_entity_id_to_device_id, async_remove_stale_devices_links_keep_entity_device, ) -from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.helper_integration import ( async_handle_source_entity_changes, async_remove_helper_config_entry_from_source_device, @@ -44,9 +43,8 @@ DATA_UTILITY, DOMAIN, METER_TYPES, - SERVICE_RESET, - SIGNAL_RESET_METER, ) +from .services import async_setup_services _LOGGER = logging.getLogger(__name__) @@ -120,27 +118,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up an Utility Meter.""" hass.data[DATA_UTILITY] = {} - async def async_reset_meters(service_call): - """Reset all sensors of a meter.""" - meters = service_call.data["entity_id"] - - for meter in meters: - _LOGGER.debug("resetting meter %s", meter) - domain, entity = split_entity_id(meter) - # backward compatibility up to 2022.07: - if domain == DOMAIN: - async_dispatcher_send( - hass, SIGNAL_RESET_METER, f"{SELECT_DOMAIN}.{entity}" - ) - else: - async_dispatcher_send(hass, SIGNAL_RESET_METER, meter) - - hass.services.async_register( - DOMAIN, - SERVICE_RESET, - async_reset_meters, - vol.Schema({ATTR_ENTITY_ID: vol.All(cv.ensure_list, [cv.entity_id])}), - ) + async_setup_services(hass) if DOMAIN not in config: return True diff --git a/homeassistant/components/utility_meter/services.py b/homeassistant/components/utility_meter/services.py new file mode 100644 index 0000000000000..ce2755f46ce5e --- /dev/null +++ b/homeassistant/components/utility_meter/services.py @@ -0,0 +1,43 @@ +"""Support for tracking consumption over given periods of time.""" + +import logging + +import voluptuous as vol + +from homeassistant.components.select import DOMAIN as SELECT_DOMAIN +from homeassistant.const import ATTR_ENTITY_ID +from homeassistant.core import HomeAssistant, ServiceCall, callback, split_entity_id +from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.dispatcher import async_dispatcher_send + +from .const import DOMAIN, SERVICE_RESET, SIGNAL_RESET_METER + +_LOGGER = logging.getLogger(__name__) + + +async def async_reset_meters(service_call: ServiceCall) -> None: + """Reset all sensors of a meter.""" + meters = service_call.data["entity_id"] + + for meter in meters: + _LOGGER.debug("resetting meter %s", meter) + domain, entity = split_entity_id(meter) + # backward compatibility up to 2022.07: + if domain == DOMAIN: + async_dispatcher_send( + service_call.hass, SIGNAL_RESET_METER, f"{SELECT_DOMAIN}.{entity}" + ) + else: + async_dispatcher_send(service_call.hass, SIGNAL_RESET_METER, meter) + + +@callback +def async_setup_services(hass: HomeAssistant) -> None: + """Set up the services.""" + + hass.services.async_register( + DOMAIN, + SERVICE_RESET, + async_reset_meters, + vol.Schema({ATTR_ENTITY_ID: vol.All(cv.ensure_list, [cv.entity_id])}), + ) diff --git a/requirements_all.txt b/requirements_all.txt index e20c175519b06..f6af43716e04f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -80,7 +80,7 @@ PyQRCode==1.2.1 PyRMVtransport==0.3.3 # homeassistant.components.sunricher_dali -PySrDaliGateway==0.18.0 +PySrDaliGateway==0.19.3 # homeassistant.components.switchbot PySwitchbot==0.76.0 @@ -1683,7 +1683,7 @@ openwrt-luci-rpc==1.1.17 openwrt-ubus-rpc==0.0.2 # homeassistant.components.opower -opower==0.16.2 +opower==0.16.3 # homeassistant.components.oralb oralb-ble==1.0.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 1fd04b403c00b..b337ec21372f1 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -80,7 +80,7 @@ PyQRCode==1.2.1 PyRMVtransport==0.3.3 # homeassistant.components.sunricher_dali -PySrDaliGateway==0.18.0 +PySrDaliGateway==0.19.3 # homeassistant.components.switchbot PySwitchbot==0.76.0 @@ -1457,7 +1457,7 @@ openrgb-python==0.3.6 openwebifpy==4.3.1 # homeassistant.components.opower -opower==0.16.2 +opower==0.16.3 # homeassistant.components.oralb oralb-ble==1.0.2 diff --git a/tests/components/sunricher_dali/snapshots/test_button.ambr b/tests/components/sunricher_dali/snapshots/test_button.ambr index f5cf00ce896da..f1ad8c12a4232 100644 --- a/tests/components/sunricher_dali/snapshots/test_button.ambr +++ b/tests/components/sunricher_dali/snapshots/test_button.ambr @@ -20,6 +20,7 @@ 'labels': set({ }), 'name': None, + 'object_id_base': None, 'options': dict({ }), 'original_device_class': , @@ -69,6 +70,7 @@ 'labels': set({ }), 'name': None, + 'object_id_base': None, 'options': dict({ }), 'original_device_class': , @@ -118,6 +120,7 @@ 'labels': set({ }), 'name': None, + 'object_id_base': None, 'options': dict({ }), 'original_device_class': , @@ -167,6 +170,7 @@ 'labels': set({ }), 'name': None, + 'object_id_base': None, 'options': dict({ }), 'original_device_class': ,