Remove deprecated integration dte_energy_bridge (#132276)
* Remove deprecated integration dte_energy_bridge * Update quality scale script and ran hassfestpull/132430/head
parent
841773bb68
commit
3e98df707d
|
@ -1 +0,0 @@
|
|||
"""The dte_energy_bridge component."""
|
|
@ -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"
|
||||
}
|
|
@ -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
|
|
@ -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."
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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",
|
||||
|
|
|
@ -310,7 +310,6 @@ INTEGRATIONS_WITHOUT_QUALITY_SCALE_FILE = [
|
|||
"drop_connect",
|
||||
"dsmr",
|
||||
"dsmr_reader",
|
||||
"dte_energy_bridge",
|
||||
"dublin_bus_transport",
|
||||
"duckdns",
|
||||
"duke_energy",
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
"""Tests for the dte_energy_bridge component."""
|
|
@ -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"
|
Loading…
Reference in New Issue