mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Add configuration_url and entity_category to Fritz (#58004)
This commit is contained in:
parent
1904019b5f
commit
1a978662ec
@ -11,6 +11,7 @@ from homeassistant.components.binary_sensor import (
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
@ -25,16 +26,19 @@ SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||
key="is_connected",
|
||||
name="Connection",
|
||||
device_class=DEVICE_CLASS_CONNECTIVITY,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
BinarySensorEntityDescription(
|
||||
key="is_linked",
|
||||
name="Link",
|
||||
device_class=DEVICE_CLASS_PLUG,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
BinarySensorEntityDescription(
|
||||
key="firmware_update",
|
||||
name="Firmware Update",
|
||||
device_class=DEVICE_CLASS_UPDATE,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -487,4 +487,5 @@ class FritzBoxBaseEntity:
|
||||
"manufacturer": "AVM",
|
||||
"model": self._fritzbox_tools.model,
|
||||
"sw_version": self._fritzbox_tools.current_firmware,
|
||||
"configuration_url": f"http://{self._fritzbox_tools.host}",
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ from homeassistant.const import (
|
||||
DATA_RATE_KILOBITS_PER_SECOND,
|
||||
DATA_RATE_KILOBYTES_PER_SECOND,
|
||||
DEVICE_CLASS_TIMESTAMP,
|
||||
ENTITY_CATEGORY_CONFIG,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
SIGNAL_STRENGTH_DECIBELS,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -165,12 +167,14 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
|
||||
key="device_uptime",
|
||||
name="Device Uptime",
|
||||
device_class=DEVICE_CLASS_TIMESTAMP,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
value_fn=_retrieve_device_uptime_state,
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
key="connection_uptime",
|
||||
name="Connection Uptime",
|
||||
device_class=DEVICE_CLASS_TIMESTAMP,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
value_fn=_retrieve_connection_uptime_state,
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
@ -194,6 +198,7 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
|
||||
name="Max Connection Upload Throughput",
|
||||
native_unit_of_measurement=DATA_RATE_KILOBITS_PER_SECOND,
|
||||
icon="mdi:upload",
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
value_fn=_retrieve_max_kb_s_sent_state,
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
@ -201,6 +206,7 @@ SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
|
||||
name="Max Connection Download Throughput",
|
||||
native_unit_of_measurement=DATA_RATE_KILOBITS_PER_SECOND,
|
||||
icon="mdi:download",
|
||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||
value_fn=_retrieve_max_kb_s_received_state,
|
||||
),
|
||||
FritzSensorEntityDescription(
|
||||
|
@ -18,6 +18,7 @@ import xmltodict
|
||||
from homeassistant.components.network import async_get_source_ip
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENTITY_CATEGORY_CONFIG
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity
|
||||
@ -441,6 +442,7 @@ class FritzBoxPortSwitch(FritzBoxBaseSwitch, SwitchEntity):
|
||||
self.connection_type = connection_type
|
||||
self.port_mapping = port_mapping # dict in the format as it comes from fritzconnection. eg: {'NewRemoteHost': '0.0.0.0', 'NewExternalPort': 22, 'NewProtocol': 'TCP', 'NewInternalPort': 22, 'NewInternalClient': '192.168.178.31', 'NewEnabled': True, 'NewPortMappingDescription': 'Beast SSH ', 'NewLeaseDuration': 0}
|
||||
self._idx = idx # needed for update routine
|
||||
self._attr_entity_category = ENTITY_CATEGORY_CONFIG
|
||||
|
||||
if port_mapping is None:
|
||||
return
|
||||
@ -519,6 +521,7 @@ class FritzBoxDeflectionSwitch(FritzBoxBaseSwitch, SwitchEntity):
|
||||
self.dict_of_deflection = dict_of_deflection
|
||||
self._attributes = {}
|
||||
self.id = int(self.dict_of_deflection["DeflectionId"])
|
||||
self._attr_entity_category = ENTITY_CATEGORY_CONFIG
|
||||
|
||||
switch_info = SwitchInfo(
|
||||
description=f"Call deflection {self.id}",
|
||||
@ -588,6 +591,7 @@ class FritzBoxProfileSwitch(FritzDeviceBase, SwitchEntity):
|
||||
self._attr_is_on: bool = False
|
||||
self._name = f"{device.hostname} Internet Access"
|
||||
self._attr_unique_id = f"{self._mac}_internet_access"
|
||||
self._attr_entity_category = ENTITY_CATEGORY_CONFIG
|
||||
|
||||
async def async_process_update(self) -> None:
|
||||
"""Update device."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user