From b784d809735e789f4851de2a149bddc06a2aa628 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Wed, 22 Nov 2017 08:39:45 +0100 Subject: [PATCH] Add transmission rate (#10740) * Add transmission rate * Rename transmission rate attributes to shorter names --- homeassistant/components/sensor/fritzbox_netmonitor.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/homeassistant/components/sensor/fritzbox_netmonitor.py b/homeassistant/components/sensor/fritzbox_netmonitor.py index 4e35bd857990da..c7486b56c25537 100644 --- a/homeassistant/components/sensor/fritzbox_netmonitor.py +++ b/homeassistant/components/sensor/fritzbox_netmonitor.py @@ -25,6 +25,8 @@ ATTR_BYTES_RECEIVED = 'bytes_received' ATTR_BYTES_SENT = 'bytes_sent' +ATTR_TRANSMISSION_RATE_UP = 'transmission_rate_up' +ATTR_TRANSMISSION_RATE_DOWN = 'transmission_rate_down' ATTR_EXTERNAL_IP = 'external_ip' ATTR_IS_CONNECTED = 'is_connected' ATTR_IS_LINKED = 'is_linked' @@ -78,6 +80,8 @@ def __init__(self, fstatus): self._is_linked = self._is_connected = self._wan_access_type = None self._external_ip = self._uptime = None self._bytes_sent = self._bytes_received = None + self._transmission_rate_up = None + self._transmission_rate_down = None self._max_byte_rate_up = self._max_byte_rate_down = None @property @@ -109,6 +113,8 @@ def state_attributes(self): ATTR_UPTIME: self._uptime, ATTR_BYTES_SENT: self._bytes_sent, ATTR_BYTES_RECEIVED: self._bytes_received, + ATTR_TRANSMISSION_RATE_UP: self._transmission_rate_up, + ATTR_TRANSMISSION_RATE_DOWN: self._transmission_rate_down, ATTR_MAX_BYTE_RATE_UP: self._max_byte_rate_up, ATTR_MAX_BYTE_RATE_DOWN: self._max_byte_rate_down, } @@ -125,6 +131,9 @@ def update(self): self._uptime = self._fstatus.uptime self._bytes_sent = self._fstatus.bytes_sent self._bytes_received = self._fstatus.bytes_received + transmission_rate = self._fstatus.transmission_rate + self._transmission_rate_up = transmission_rate[0] + self._transmission_rate_down = transmission_rate[1] self._max_byte_rate_up = self._fstatus.max_byte_rate[0] self._max_byte_rate_down = self._fstatus.max_byte_rate[1] self._state = STATE_ONLINE if self._is_connected else STATE_OFFLINE