Skip to content

Commit

Permalink
0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gvigroux committed Jan 9, 2025
1 parent 2005fc4 commit c09eb12
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 29 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<a href="https://www.buymeacoffee.com/gvigroux"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=gvigroux&button_colour=5F7FFF&font_colour=ffffff&font_family=Cookie&outline_colour=000000&coffee_colour=FFDD00" /></a>

# Freebox Home Add-on for Home Assistant

This integration supports basic shutters as well as all the built-in Alarm system (alarm control panel, camera, motion detector, door opener dectector, remote control)

## Install
Copy this project into the `custom_components` folder of your home-assistant config directory.
After rebooting Home Assistant, the detection of the freebox Home (Only freebox Delta) should be automatic
Use HACS to install or copy in yout HA directory

## Grant access right
As explained during the setup, you have to go to: http://mafreebox.freebox.fr/#Fbx.os.app.settings.Accounts, open the "application" tab and add all access to the Home assistant application
1 change: 1 addition & 0 deletions custom_components/freebox_home/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
36 changes: 28 additions & 8 deletions __init__.py → custom_components/freebox_home/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,45 @@
from homeassistant.core import HomeAssistant

from .const import DOMAIN, PLATFORMS
from .router import FreeboxRouter
from .router import (FreeboxRouter, get_api)

_LOGGER = logging.getLogger(__name__)

async def async_setup(hass, config):
return True

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Freebox component."""
router = FreeboxRouter(hass, entry)
await router.setup()

async def blocking_calls(hass, api, entry):
await api.open(entry.data[CONF_HOST], entry.data[CONF_PORT])

fbx_config = await api.system.get_config()
router = FreeboxRouter(hass, entry, api, fbx_config)
await router.update_all()

hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.unique_id] = router
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

#for platform in PLATFORMS:
# hass.async_create_task(hass.config_entries.async_forward_entry_setup(entry, platform))

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Freebox component."""

api = await get_api(hass, entry.data[CONF_HOST])
router = None
try:
#await api.open(entry.data[CONF_HOST], entry.data[CONF_PORT])
router = await hass.async_add_executor_job(blocking_calls, hass, api, entry)
except HttpRequestError as err:
raise ConfigEntryNotReady from err

#fbx_config = await api.system.get_config()
#router = FreeboxRouter(hass, entry, api, fbx_config)
#await router.update_all()

#hass.data.setdefault(DOMAIN, {})
#hass.data[DOMAIN][entry.unique_id] = router

#await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

async def async_close_connection(event):
"""Close Freebox connection on HA Stop."""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions camera.py → custom_components/freebox_home/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(self, hass, router, node):
device_info = {CONF_NAME: node["label"].strip(),CONF_INPUT: node["props"]["Stream"],CONF_EXTRA_ARGUMENTS: DEFAULT_ARGUMENTS }
FFmpegCamera.__init__(self, hass, device_info)

self._supported_features = CameraEntityFeature.STREAM
#self._supported_features = CameraEntityFeature.STREAM
self.update_parameters(node)

self._command_flip = self.get_command_id(node['show_endpoints'], "slot", "flip")
Expand Down Expand Up @@ -148,7 +148,7 @@ async def async_disable_motion_detection(self):
@property
def supported_features(self):
"""Flag supported features."""
return self._supported_features
return CameraEntityFeature.STREAM #self._supported_features

async def async_update(self):
"""Get the state & name and update it."""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"after_dependencies": ["zeroconf"],
"zeroconf": ["_fbx-api._tcp.local."],
"codeowners": ["gvigroux"],
"version": "0.7.0"
"version": "0.7.1"
}
41 changes: 25 additions & 16 deletions router.py → custom_components/freebox_home/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,44 @@
class FreeboxRouter:
"""Representation of a Freebox router."""

def __init__(self, hass, entry) -> None:
def __init__(self, hass, entry, api, fbx_config) -> None:
"""Initialize a Freebox router."""
self.hass = hass
self._host = entry.data[CONF_HOST]
self._port = entry.data[CONF_PORT]
self._api: Freepybox = None
self._api = api
self.mac = None

self.nodes: Dict[str, Any] = {}
self._unsub_dispatcher = None
#self._unsub_dispatcher = None

# System
self.mac = "FbxHome_" + fbx_config["mac"]

# Devices & sensors
self._unsub_dispatcher = async_track_time_interval(self.hass, self.update_all, SCAN_INTERVAL)

async def setup(self) -> None:
"""Set up a Freebox router."""
self._api = await get_api(self.hass, self._host)

try:
await self._api.open(self._host, self._port)
#result = await self.hass.async_add_executor_job(self._api.open(self._host, self._port), "open")
except HttpRequestError:
_LOGGER.exception("Failed to connect to Freebox")
return ConfigEntryNotReady

#async def setup(self) -> None:
#"""Set up a Freebox router."""
#self._api = await get_api(self.hass, self._host)

#await self.hass.async_add_executor_job(self.blocking_code)
#try:
# #await self._api.open(self._host, self._port)
# result = await self.hass.async_add_executor_job(self._api.open,self._host, self._port)
#except HttpRequestError:
# _LOGGER.exception("Failed to connect to Freebox")
# return ConfigEntryNotReady

# System
fbx_config = await self._api.system.get_config()
self.mac = "FbxHome_" + fbx_config["mac"]
#fbx_config = await self._api.system.get_config()
#self.mac = "FbxHome_" + fbx_config["mac"]

# Devices & sensors
await self.update_all()
self._unsub_dispatcher = async_track_time_interval(self.hass, self.update_all, SCAN_INTERVAL)
#await self.update_all()
#self._unsub_dispatcher = async_track_time_interval(self.hass, self.update_all, SCAN_INTERVAL)

async def update_all(self, now: Optional[datetime] = None) -> None:
"""Update all nodes"""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<a href="https://www.buymeacoffee.com/gvigroux"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=gvigroux&button_colour=5F7FFF&font_colour=ffffff&font_family=Cookie&outline_colour=000000&coffee_colour=FFDD00" /></a>

# Freebox Home Add-on for Home Assistant

This integration supports basic shutters as well as all the built-in Alarm system (alarm control panel, camera, motion detector, door opener dectector, remote control)

## Install
Use HACS to install or copy in yout HA directory

## Grant access right
As explained during the setup, you have to go to: http://mafreebox.freebox.fr/#Fbx.os.app.settings.Accounts, open the "application" tab and add all access to the Home assistant application

0 comments on commit c09eb12

Please sign in to comment.