Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config flow and device registry to fritzbox integration #31240

Merged
merged 56 commits into from Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2f85e9d
add config flow
escoand Jan 28, 2020
0dec687
fix pylint
escoand Jan 28, 2020
6414aee
update lib
escoand Jan 28, 2020
3a9c02f
Update config_flow.py
escoand Jan 29, 2020
469213e
remote devices layer in config
escoand Jan 31, 2020
7a5788f
Merge branch 'fritzbox_config_flow' of github.com:escoand/home-assist…
escoand Jan 31, 2020
890504d
add default host
escoand Jan 31, 2020
60e97cc
avoid double setups of entities
escoand Feb 1, 2020
fb67cd9
remove async_setup_platform
escoand Feb 2, 2020
8744184
store entities in hass.data
escoand Feb 3, 2020
999d28a
pass fritz connection together with config_entry
escoand Feb 3, 2020
af95de9
fritz connections try no4 (or is it even more)
escoand Feb 3, 2020
0800e08
fix comments
escoand Feb 4, 2020
cb1ac6e
add unloading
escoand Feb 4, 2020
fbe1fbb
fixed comments
escoand Feb 7, 2020
8bf9283
Update config_flow.py
escoand Feb 13, 2020
76d7112
Update const.py
escoand Feb 17, 2020
8786b38
Update config_flow.py
escoand Feb 17, 2020
64ba364
Update __init__.py
escoand Feb 17, 2020
60278ab
Update config_flow.py
escoand Feb 17, 2020
428ceba
Update __init__.py
escoand Feb 17, 2020
cabe57f
Update __init__.py
escoand Feb 17, 2020
16853b6
Update config_flow.py
escoand Feb 17, 2020
9a1a6cd
Update __init__.py
escoand Feb 17, 2020
a62a725
Update __init__.py
escoand Feb 18, 2020
431f230
Update __init__.py
escoand Feb 18, 2020
48d24e6
Update config_flow.py
escoand Feb 19, 2020
e5304e2
Merge branch 'dev' of github.com:home-assistant/home-assistant into f…
escoand Feb 27, 2020
1447914
add init tests
escoand Feb 27, 2020
47a8206
Merge branch 'fritzbox_config_flow' of github.com:escoand/home-assist…
escoand Feb 27, 2020
8ddf348
test unloading
escoand Mar 12, 2020
995632f
add switch tests
escoand Mar 12, 2020
2cbea8c
add sensor tests
escoand Mar 12, 2020
18fca2a
Merge branch 'dev' into fritzbox_config_flow
escoand Mar 12, 2020
26fb29c
add climate tests
escoand Apr 7, 2020
f15511e
test target temperature
escoand Apr 7, 2020
c39a81a
Merge remote-tracking branch 'upstream/dev' into fritzbox_config_flow
escoand Apr 7, 2020
5187bac
mock config to package
escoand Apr 14, 2020
c8cc9ee
comments
escoand Apr 14, 2020
9f8790d
Merge remote-tracking branch 'upstream/dev' into fritzbox_config_flow
escoand Apr 14, 2020
e8a8341
test binary sensor state
escoand Apr 14, 2020
d09df47
add config flow tests
escoand Apr 15, 2020
149a1f9
comments
escoand Apr 15, 2020
4e58bd8
add missing tests
escoand Apr 16, 2020
7351aa7
minor
escoand Apr 16, 2020
bedd85d
Merge remote-tracking branch 'upstream/dev' into fritzbox_config_flow
escoand Apr 16, 2020
fb76e58
remove string title
escoand Apr 16, 2020
ee282d3
deprecate yaml
escoand Apr 16, 2020
c77410f
don't change yaml
escoand Apr 18, 2020
158c0cb
get devices async
escoand Apr 18, 2020
ec297cf
minor
escoand Apr 18, 2020
d94b588
add devices again
escoand Apr 19, 2020
7dd5027
comments fixed
escoand Apr 19, 2020
ac7a8dc
unique_id fixes
escoand Apr 19, 2020
5a797a0
fix patches
escoand Apr 19, 2020
4b848ff
Fix schema
MartinHjelmare Apr 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions homeassistant/components/fritzbox/binary_sensor.py
@@ -1,10 +1,12 @@
"""Support for Fritzbox binary sensors."""
import requests

from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.binary_sensor import DOMAIN, BinarySensorDevice

from .const import DOMAIN as FRITZBOX_DOMAIN, LOGGER

entities = set()
escoand marked this conversation as resolved.
Show resolved Hide resolved


async def async_setup_platform(
escoand marked this conversation as resolved.
Show resolved Hide resolved
hass, config, add_entities, discovery_info=None
Expand All @@ -21,8 +23,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for fritz in fritz_list:
device_list = fritz.get_devices()
for device in device_list:
if device.has_alarm:
if device.has_alarm and device.ain not in entities:
escoand marked this conversation as resolved.
Show resolved Hide resolved
devices.append(FritzboxBinarySensor(device, fritz))
entities.add(device.ain)

async_add_entities(devices, True)

Expand All @@ -40,7 +43,7 @@ def device_info(self):
"""Return device specific attributes."""
return {
"name": self.name,
"identifiers": {(FRITZBOX_DOMAIN, self.unique_id)},
"identifiers": {(FRITZBOX_DOMAIN, self._device.ain)},
"manufacturer": self._device.manufacturer,
"model": self._device.productname,
"sw_version": self._device.fw_version,
Expand All @@ -49,7 +52,7 @@ def device_info(self):
@property
def unique_id(self):
"""Return the unique ID of the device."""
return self._device.ain
return f"{self._device.ain}-{DOMAIN}"
escoand marked this conversation as resolved.
Show resolved Hide resolved

@property
def name(self):
Expand Down
10 changes: 7 additions & 3 deletions homeassistant/components/fritzbox/climate.py
Expand Up @@ -4,6 +4,7 @@
from homeassistant.components.climate import ClimateDevice
from homeassistant.components.climate.const import (
ATTR_HVAC_MODE,
DOMAIN,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
PRESET_COMFORT,
Expand Down Expand Up @@ -44,6 +45,8 @@
ON_REPORT_SET_TEMPERATURE = 30.0
OFF_REPORT_SET_TEMPERATURE = 0.0

entities = set()


async def async_setup_platform(
hass, config, add_entities, discovery_info=None
Expand All @@ -60,8 +63,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for fritz in fritz_list:
device_list = fritz.get_devices()
for device in device_list:
if device.has_thermostat:
if device.has_thermostat and device.ain not in entities:
devices.append(FritzboxThermostat(device, fritz))
entities.add(device.ain)

async_add_entities(devices)

Expand All @@ -83,7 +87,7 @@ def device_info(self):
"""Return device specific attributes."""
return {
"name": self.name,
"identifiers": {(FRITZBOX_DOMAIN, self.unique_id)},
"identifiers": {(FRITZBOX_DOMAIN, self._device.ain)},
"manufacturer": self._device.manufacturer,
"model": self._device.productname,
"sw_version": self._device.fw_version,
Expand All @@ -92,7 +96,7 @@ def device_info(self):
@property
def unique_id(self):
"""Return the unique ID of the device."""
return self._device.ain
return f"{self._device.ain}-{DOMAIN}"

@property
def supported_features(self):
Expand Down
10 changes: 7 additions & 3 deletions homeassistant/components/fritzbox/sensor.py
@@ -1,6 +1,7 @@
"""Support for AVM Fritz!Box smarthome temperature sensor only devices."""
import requests

from homeassistant.components.sensor import DOMAIN
from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers.entity import Entity

Expand All @@ -11,6 +12,8 @@
LOGGER,
)

entities = set()


async def async_setup_platform(
hass, config, add_entities, discovery_info=None
Expand All @@ -21,7 +24,6 @@ async def async_setup_platform(

async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Fritzbox smarthome sensor from config_entry."""
LOGGER.debug("Initializing fritzbox temperature sensors")
devices = []
fritz_list = hass.data[FRITZBOX_DOMAIN]

Expand All @@ -32,8 +34,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
device.has_temperature_sensor
and not device.has_switch
and not device.has_thermostat
and device.ain not in entities
):
devices.append(FritzBoxTempSensor(device, fritz))
entities.add(device.ain)

async_add_entities(devices)

Expand All @@ -51,7 +55,7 @@ def device_info(self):
"""Return device specific attributes."""
return {
"name": self.name,
"identifiers": {(FRITZBOX_DOMAIN, self.unique_id)},
"identifiers": {(FRITZBOX_DOMAIN, self._device.ain)},
"manufacturer": self._device.manufacturer,
"model": self._device.productname,
"sw_version": self._device.fw_version,
Expand All @@ -60,7 +64,7 @@ def device_info(self):
@property
def unique_id(self):
"""Return the unique ID of the device."""
return self._device.ain
return f"{self._device.ain}-{DOMAIN}"

@property
def name(self):
Expand Down
11 changes: 7 additions & 4 deletions homeassistant/components/fritzbox/switch.py
@@ -1,7 +1,7 @@
"""Support for AVM Fritz!Box smarthome switch devices."""
import requests

from homeassistant.components.switch import SwitchDevice
from homeassistant.components.switch import DOMAIN, SwitchDevice
from homeassistant.const import ATTR_TEMPERATURE, ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS

from .const import (
Expand All @@ -17,6 +17,8 @@

ATTR_TEMPERATURE_UNIT = "temperature_unit"

entities = set()


async def async_setup_platform(
hass, config, add_entities, discovery_info=None
Expand All @@ -33,8 +35,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for fritz in fritz_list:
device_list = fritz.get_devices()
for device in device_list:
if device.has_switch:
if device.has_switch and device.ain not in entities:
devices.append(FritzboxSwitch(device, fritz))
entities.add(device.ain)

async_add_entities(devices)

Expand All @@ -52,7 +55,7 @@ def device_info(self):
"""Return device specific attributes."""
return {
"name": self.name,
"identifiers": {(FRITZBOX_DOMAIN, self.unique_id)},
"identifiers": {(FRITZBOX_DOMAIN, self._device.ain)},
"manufacturer": self._device.manufacturer,
"model": self._device.productname,
"sw_version": self._device.fw_version,
Expand All @@ -61,7 +64,7 @@ def device_info(self):
@property
def unique_id(self):
"""Return the unique ID of the device."""
return self._device.ain
return f"{self._device.ain}-{DOMAIN}"

@property
def available(self):
Expand Down