core/homeassistant/components/fritz/sensor.py

351 lines
12 KiB
Python
Raw Normal View History

"""AVM FRITZ!Box binary sensors."""
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from datetime import datetime, timedelta
import logging
from typing import Any, Literal
from fritzconnection.core.exceptions import (
FritzActionError,
FritzActionFailedError,
FritzConnectionException,
2021-09-04 20:56:59 +00:00
FritzInternalError,
FritzServiceError,
)
from fritzconnection.lib.fritzstatus import FritzStatus
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DATA_GIGABYTES,
2021-07-21 17:12:32 +00:00
DATA_RATE_KILOBITS_PER_SECOND,
DATA_RATE_KILOBYTES_PER_SECOND,
DEVICE_CLASS_TIMESTAMP,
ENTITY_CATEGORY_DIAGNOSTIC,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
SIGNAL_STRENGTH_DECIBELS,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.dt import utcnow
from .common import FritzBoxBaseEntity, FritzBoxTools
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
from .const import DOMAIN, DSL_CONNECTION, UPTIME_DEVIATION
_LOGGER = logging.getLogger(__name__)
def _uptime_calculation(seconds_uptime: float, last_value: datetime | None) -> datetime:
"""Calculate uptime with deviation."""
delta_uptime = utcnow() - timedelta(seconds=seconds_uptime)
if (
not last_value
or abs((delta_uptime - last_value).total_seconds()) > UPTIME_DEVIATION
):
return delta_uptime
return last_value
def _retrieve_device_uptime_state(
status: FritzStatus, last_value: datetime
) -> datetime:
"""Return uptime from device."""
return _uptime_calculation(status.device_uptime, last_value)
def _retrieve_connection_uptime_state(
status: FritzStatus, last_value: datetime | None
) -> datetime:
"""Return uptime from connection."""
return _uptime_calculation(status.connection_uptime, last_value)
def _retrieve_external_ip_state(status: FritzStatus, last_value: str) -> str:
"""Return external ip from device."""
return status.external_ip # type: ignore[no-any-return]
def _retrieve_kb_s_sent_state(status: FritzStatus, last_value: str) -> float:
"""Return upload transmission rate."""
2021-08-04 19:53:07 +00:00
return round(status.transmission_rate[0] / 1000, 1) # type: ignore[no-any-return]
def _retrieve_kb_s_received_state(status: FritzStatus, last_value: str) -> float:
"""Return download transmission rate."""
2021-08-04 19:53:07 +00:00
return round(status.transmission_rate[1] / 1000, 1) # type: ignore[no-any-return]
def _retrieve_max_kb_s_sent_state(status: FritzStatus, last_value: str) -> float:
"""Return upload max transmission rate."""
2021-08-04 19:53:07 +00:00
return round(status.max_bit_rate[0] / 1000, 1) # type: ignore[no-any-return]
def _retrieve_max_kb_s_received_state(status: FritzStatus, last_value: str) -> float:
"""Return download max transmission rate."""
2021-08-04 19:53:07 +00:00
return round(status.max_bit_rate[1] / 1000, 1) # type: ignore[no-any-return]
def _retrieve_gb_sent_state(status: FritzStatus, last_value: str) -> float:
"""Return upload total data."""
2021-08-06 02:24:41 +00:00
return round(status.bytes_sent / 1000 / 1000 / 1000, 1) # type: ignore[no-any-return]
def _retrieve_gb_received_state(status: FritzStatus, last_value: str) -> float:
"""Return download total data."""
2021-08-06 02:24:41 +00:00
return round(status.bytes_received / 1000 / 1000 / 1000, 1) # type: ignore[no-any-return]
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
def _retrieve_link_kb_s_sent_state(status: FritzStatus, last_value: str) -> float:
"""Return upload link rate."""
return round(status.max_linked_bit_rate[0] / 1000, 1) # type: ignore[no-any-return]
def _retrieve_link_kb_s_received_state(status: FritzStatus, last_value: str) -> float:
"""Return download link rate."""
return round(status.max_linked_bit_rate[1] / 1000, 1) # type: ignore[no-any-return]
def _retrieve_link_noise_margin_sent_state(
status: FritzStatus, last_value: str
) -> float:
"""Return upload noise margin."""
return status.noise_margin[0] / 10 # type: ignore[no-any-return]
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
def _retrieve_link_noise_margin_received_state(
status: FritzStatus, last_value: str
) -> float:
"""Return download noise margin."""
return status.noise_margin[1] / 10 # type: ignore[no-any-return]
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
def _retrieve_link_attenuation_sent_state(
status: FritzStatus, last_value: str
) -> float:
"""Return upload line attenuation."""
return status.attenuation[0] / 10 # type: ignore[no-any-return]
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
def _retrieve_link_attenuation_received_state(
status: FritzStatus, last_value: str
) -> float:
"""Return download line attenuation."""
return status.attenuation[1] / 10 # type: ignore[no-any-return]
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
@dataclass
class FritzRequireKeysMixin:
"""Fritz sensor data class."""
value_fn: Callable[[FritzStatus, Any], Any]
@dataclass
class FritzSensorEntityDescription(SensorEntityDescription, FritzRequireKeysMixin):
"""Describes Fritz sensor entity."""
connection_type: Literal["dsl"] | None = None
SENSOR_TYPES: tuple[FritzSensorEntityDescription, ...] = (
FritzSensorEntityDescription(
key="external_ip",
name="External IP",
icon="mdi:earth",
value_fn=_retrieve_external_ip_state,
),
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(
key="kb_s_sent",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Upload Throughput",
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
icon="mdi:upload",
value_fn=_retrieve_kb_s_sent_state,
),
FritzSensorEntityDescription(
key="kb_s_received",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Download Throughput",
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
icon="mdi:download",
value_fn=_retrieve_kb_s_received_state,
),
FritzSensorEntityDescription(
key="max_kb_s_sent",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Max Connection Upload Throughput",
native_unit_of_measurement=DATA_RATE_KILOBITS_PER_SECOND,
icon="mdi:upload",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
value_fn=_retrieve_max_kb_s_sent_state,
),
FritzSensorEntityDescription(
key="max_kb_s_received",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Max Connection Download Throughput",
native_unit_of_measurement=DATA_RATE_KILOBITS_PER_SECOND,
icon="mdi:download",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
value_fn=_retrieve_max_kb_s_received_state,
),
FritzSensorEntityDescription(
key="gb_sent",
name="GB sent",
state_class=STATE_CLASS_TOTAL_INCREASING,
native_unit_of_measurement=DATA_GIGABYTES,
icon="mdi:upload",
value_fn=_retrieve_gb_sent_state,
),
FritzSensorEntityDescription(
key="gb_received",
name="GB received",
state_class=STATE_CLASS_TOTAL_INCREASING,
native_unit_of_measurement=DATA_GIGABYTES,
icon="mdi:download",
value_fn=_retrieve_gb_received_state,
),
FritzSensorEntityDescription(
key="link_kb_s_sent",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Link Upload Throughput",
native_unit_of_measurement=DATA_RATE_KILOBITS_PER_SECOND,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
icon="mdi:upload",
value_fn=_retrieve_link_kb_s_sent_state,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
connection_type=DSL_CONNECTION,
),
FritzSensorEntityDescription(
key="link_kb_s_received",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Link Download Throughput",
native_unit_of_measurement=DATA_RATE_KILOBITS_PER_SECOND,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
icon="mdi:download",
value_fn=_retrieve_link_kb_s_received_state,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
connection_type=DSL_CONNECTION,
),
FritzSensorEntityDescription(
key="link_noise_margin_sent",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Link Upload Noise Margin",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
icon="mdi:upload",
value_fn=_retrieve_link_noise_margin_sent_state,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
connection_type=DSL_CONNECTION,
),
FritzSensorEntityDescription(
key="link_noise_margin_received",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Link Download Noise Margin",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
icon="mdi:download",
value_fn=_retrieve_link_noise_margin_received_state,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
connection_type=DSL_CONNECTION,
),
FritzSensorEntityDescription(
key="link_attenuation_sent",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Link Upload Power Attenuation",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
icon="mdi:upload",
value_fn=_retrieve_link_attenuation_sent_state,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
connection_type=DSL_CONNECTION,
),
FritzSensorEntityDescription(
key="link_attenuation_received",
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
name="Link Download Power Attenuation",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
icon="mdi:download",
value_fn=_retrieve_link_attenuation_received_state,
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
connection_type=DSL_CONNECTION,
),
)
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up entry."""
_LOGGER.debug("Setting up FRITZ!Box sensors")
fritzbox_tools: FritzBoxTools = hass.data[DOMAIN][entry.entry_id]
if (
not fritzbox_tools.connection
or "WANIPConn1" not in fritzbox_tools.connection.services
):
# Only routers are supported at the moment
return
dsl: bool = False
try:
dslinterface = await hass.async_add_executor_job(
fritzbox_tools.connection.call_action,
"WANDSLInterfaceConfig:1",
"GetInfo",
)
dsl = dslinterface["NewEnable"]
2021-09-04 20:56:59 +00:00
except (
FritzInternalError,
FritzActionError,
FritzActionFailedError,
FritzServiceError,
):
pass
Add more Fritz sensors for DSL connections (#53198) * Update sensor.py Added information about the upstream line accorrding to fritzconnection library (available since V1.5.0) . New information available are line sync speed,, noise margin and power attenuation. Tested with ADSL and VDSL lines on fritzbox 7590, 7490 and 7390. Not tested on cable internet / fiber. According to upstrem library should also work / fail gracefully. * Update sensor.py Fixed errors from automated tests Sorry it took so long * Update homeassistant/components/fritz/sensor.py Thank you this sounds even better Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * Update homeassistant/components/fritz/sensor.py Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> * black & mypy fixes * Rebase, fix multiplier, add conditional create Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com>
2021-08-08 09:23:28 +00:00
entities = [
FritzBoxSensor(fritzbox_tools, entry.title, description)
for description in SENSOR_TYPES
if dsl or description.connection_type != DSL_CONNECTION
]
async_add_entities(entities, True)
class FritzBoxSensor(FritzBoxBaseEntity, SensorEntity):
"""Define FRITZ!Box connectivity class."""
entity_description: FritzSensorEntityDescription
def __init__(
self,
fritzbox_tools: FritzBoxTools,
device_friendly_name: str,
description: FritzSensorEntityDescription,
) -> None:
"""Init FRITZ!Box connectivity class."""
self.entity_description = description
self._last_device_value: str | None = None
self._attr_available = True
self._attr_name = f"{device_friendly_name} {description.name}"
self._attr_unique_id = f"{fritzbox_tools.unique_id}-{description.key}"
super().__init__(fritzbox_tools, device_friendly_name)
def update(self) -> None:
"""Update data."""
_LOGGER.debug("Updating FRITZ!Box sensors")
try:
status: FritzStatus = self._fritzbox_tools.fritz_status
self._attr_available = True
except FritzConnectionException:
_LOGGER.error("Error getting the state from the FRITZ!Box", exc_info=True)
self._attr_available = False
return
self._attr_native_value = (
self._last_device_value
) = self.entity_description.value_fn(status, self._last_device_value)