diff --git a/homeassistant/components/dte_energy_bridge/__init__.py b/homeassistant/components/dte_energy_bridge/__init__.py deleted file mode 100644 index 2525d047bcee65..00000000000000 --- a/homeassistant/components/dte_energy_bridge/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""The dte_energy_bridge component.""" diff --git a/homeassistant/components/dte_energy_bridge/manifest.json b/homeassistant/components/dte_energy_bridge/manifest.json deleted file mode 100644 index 8285469a74536c..00000000000000 --- a/homeassistant/components/dte_energy_bridge/manifest.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "domain": "dte_energy_bridge", - "name": "DTE Energy Bridge", - "codeowners": [], - "documentation": "https://www.home-assistant.io/integrations/dte_energy_bridge", - "iot_class": "local_polling", - "quality_scale": "legacy" -} diff --git a/homeassistant/components/dte_energy_bridge/sensor.py b/homeassistant/components/dte_energy_bridge/sensor.py deleted file mode 100644 index a0b9253034effc..00000000000000 --- a/homeassistant/components/dte_energy_bridge/sensor.py +++ /dev/null @@ -1,127 +0,0 @@ -"""Support for monitoring energy usage using the DTE energy bridge.""" - -from __future__ import annotations - -from http import HTTPStatus -import logging - -import requests -import voluptuous as vol - -from homeassistant.components.sensor import ( - PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA, - SensorDeviceClass, - SensorEntity, - SensorStateClass, -) -from homeassistant.const import CONF_NAME, UnitOfPower -from homeassistant.core import HomeAssistant -import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.issue_registry import IssueSeverity, create_issue -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType - -_LOGGER = logging.getLogger(__name__) - -CONF_IP_ADDRESS = "ip" -CONF_VERSION = "version" - -DEFAULT_NAME = "Current Energy Usage" -DEFAULT_VERSION = 1 -DOMAIN = "dte_energy_bridge" - -PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend( - { - vol.Required(CONF_IP_ADDRESS): cv.string, - vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - vol.Optional(CONF_VERSION, default=DEFAULT_VERSION): vol.All( - vol.Coerce(int), vol.Any(1, 2) - ), - } -) - - -def setup_platform( - hass: HomeAssistant, - config: ConfigType, - add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Set up the DTE energy bridge sensor.""" - create_issue( - hass, - DOMAIN, - "deprecated_integration", - breaks_in_ha_version="2025.1.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key="deprecated_integration", - translation_placeholders={"domain": DOMAIN}, - ) - - name = config[CONF_NAME] - ip_address = config[CONF_IP_ADDRESS] - version = config[CONF_VERSION] - - add_entities([DteEnergyBridgeSensor(ip_address, name, version)], True) - - -class DteEnergyBridgeSensor(SensorEntity): - """Implementation of the DTE Energy Bridge sensors.""" - - _attr_device_class = SensorDeviceClass.POWER - _attr_native_unit_of_measurement = UnitOfPower.KILO_WATT - _attr_state_class = SensorStateClass.MEASUREMENT - - def __init__(self, ip_address, name, version): - """Initialize the sensor.""" - self._version = version - - if self._version == 1: - self._url = f"http://{ip_address}/instantaneousdemand" - elif self._version == 2: - self._url = f"http://{ip_address}:8888/zigbee/se/instantaneousdemand" - - self._attr_name = name - - def update(self) -> None: - """Get the energy usage data from the DTE energy bridge.""" - try: - response = requests.get(self._url, timeout=5) - except (requests.exceptions.RequestException, ValueError): - _LOGGER.warning( - "Could not update status for DTE Energy Bridge (%s)", self._attr_name - ) - return - - if response.status_code != HTTPStatus.OK: - _LOGGER.warning( - "Invalid status_code from DTE Energy Bridge: %s (%s)", - response.status_code, - self._attr_name, - ) - return - - response_split = response.text.split() - - if len(response_split) != 2: - _LOGGER.warning( - 'Invalid response from DTE Energy Bridge: "%s" (%s)', - response.text, - self._attr_name, - ) - return - - val = float(response_split[0]) - - # A workaround for a bug in the DTE energy bridge. - # The returned value can randomly be in W or kW. Checking for a - # a decimal seems to be a reliable way to determine the units. - # Limiting to version 1 because version 2 apparently always returns - # values in the format 000000.000 kW, but the scaling is Watts - # NOT kWatts - if self._version == 1 and "." in response_split[0]: - self._attr_native_value = val - else: - self._attr_native_value = val / 1000 diff --git a/homeassistant/components/dte_energy_bridge/strings.json b/homeassistant/components/dte_energy_bridge/strings.json deleted file mode 100644 index f75867b8faa3bb..00000000000000 --- a/homeassistant/components/dte_energy_bridge/strings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "issues": { - "deprecated_integration": { - "title": "The DTE Energy Bridge integration will be removed", - "description": "The DTE Energy Bridge integration will be removed as new users can't get any supported devices, and the integration will fail as soon as a current device gets internet access.\n\n Please remove all `{domain}`platform sensors from your configuration and restart Home Assistant." - } - } -} diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index d2f0a90065a009..c87218cb1b16a0 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -1374,12 +1374,6 @@ "config_flow": true, "iot_class": "local_push" }, - "dte_energy_bridge": { - "name": "DTE Energy Bridge", - "integration_type": "hub", - "config_flow": false, - "iot_class": "local_polling" - }, "dublin_bus_transport": { "name": "Dublin Bus", "integration_type": "hub", diff --git a/script/hassfest/quality_scale.py b/script/hassfest/quality_scale.py index 63ca8b0d213cb0..aa459a14724d34 100644 --- a/script/hassfest/quality_scale.py +++ b/script/hassfest/quality_scale.py @@ -312,7 +312,6 @@ class Rule: "drop_connect", "dsmr", "dsmr_reader", - "dte_energy_bridge", "dublin_bus_transport", "duckdns", "duke_energy", diff --git a/tests/components/dte_energy_bridge/__init__.py b/tests/components/dte_energy_bridge/__init__.py deleted file mode 100644 index 615944bda88762..00000000000000 --- a/tests/components/dte_energy_bridge/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests for the dte_energy_bridge component.""" diff --git a/tests/components/dte_energy_bridge/test_sensor.py b/tests/components/dte_energy_bridge/test_sensor.py deleted file mode 100644 index 41d340fae48a90..00000000000000 --- a/tests/components/dte_energy_bridge/test_sensor.py +++ /dev/null @@ -1,58 +0,0 @@ -"""The tests for the DTE Energy Bridge.""" - -import requests_mock - -from homeassistant.core import HomeAssistant -from homeassistant.setup import async_setup_component - -DTE_ENERGY_BRIDGE_CONFIG = {"platform": "dte_energy_bridge", "ip": "192.168.1.1"} - - -async def test_setup_with_config(hass: HomeAssistant) -> None: - """Test the platform setup with configuration.""" - assert await async_setup_component( - hass, "sensor", {"dte_energy_bridge": DTE_ENERGY_BRIDGE_CONFIG} - ) - await hass.async_block_till_done() - - -async def test_setup_correct_reading(hass: HomeAssistant) -> None: - """Test DTE Energy bridge returns a correct value.""" - with requests_mock.Mocker() as mock_req: - mock_req.get( - f"http://{DTE_ENERGY_BRIDGE_CONFIG['ip']}/instantaneousdemand", - text=".411 kW", - ) - assert await async_setup_component( - hass, "sensor", {"sensor": DTE_ENERGY_BRIDGE_CONFIG} - ) - await hass.async_block_till_done() - assert hass.states.get("sensor.current_energy_usage").state == "0.411" - - -async def test_setup_incorrect_units_reading(hass: HomeAssistant) -> None: - """Test DTE Energy bridge handles a value with incorrect units.""" - with requests_mock.Mocker() as mock_req: - mock_req.get( - f"http://{DTE_ENERGY_BRIDGE_CONFIG['ip']}/instantaneousdemand", - text="411 kW", - ) - assert await async_setup_component( - hass, "sensor", {"sensor": DTE_ENERGY_BRIDGE_CONFIG} - ) - await hass.async_block_till_done() - assert hass.states.get("sensor.current_energy_usage").state == "0.411" - - -async def test_setup_bad_format_reading(hass: HomeAssistant) -> None: - """Test DTE Energy bridge handles an invalid value.""" - with requests_mock.Mocker() as mock_req: - mock_req.get( - f"http://{DTE_ENERGY_BRIDGE_CONFIG['ip']}/instantaneousdemand", - text="411", - ) - assert await async_setup_component( - hass, "sensor", {"sensor": DTE_ENERGY_BRIDGE_CONFIG} - ) - await hass.async_block_till_done() - assert hass.states.get("sensor.current_energy_usage").state == "unknown"