2019-02-13 20:21:14 +00:00
|
|
|
"""Support for the Fibaro devices."""
|
2021-03-17 22:49:01 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
from collections import defaultdict
|
2019-11-25 13:12:01 +00:00
|
|
|
import logging
|
2022-03-26 19:50:50 +00:00
|
|
|
from typing import Any
|
2019-11-25 13:12:01 +00:00
|
|
|
|
2022-04-26 16:52:12 +00:00
|
|
|
from fiblary3.client.v4.client import (
|
|
|
|
Client as FibaroClientV4,
|
|
|
|
StateHandler as StateHandlerV4,
|
|
|
|
)
|
|
|
|
from fiblary3.client.v5.client import (
|
|
|
|
Client as FibaroClientV5,
|
|
|
|
StateHandler as StateHandlerV5,
|
|
|
|
)
|
2022-03-26 19:50:50 +00:00
|
|
|
from fiblary3.common.exceptions import HTTPException
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
import voluptuous as vol
|
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
2018-12-14 12:35:12 +00:00
|
|
|
from homeassistant.const import (
|
2019-07-31 19:25:30 +00:00
|
|
|
ATTR_ARMED,
|
|
|
|
ATTR_BATTERY_LEVEL,
|
|
|
|
CONF_DEVICE_CLASS,
|
|
|
|
CONF_EXCLUDE,
|
|
|
|
CONF_ICON,
|
|
|
|
CONF_PASSWORD,
|
|
|
|
CONF_URL,
|
|
|
|
CONF_USERNAME,
|
|
|
|
CONF_WHITE_VALUE,
|
2021-12-28 20:13:20 +00:00
|
|
|
Platform,
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2022-01-01 21:38:11 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2022-03-26 19:50:50 +00:00
|
|
|
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
2018-12-14 12:35:12 +00:00
|
|
|
import homeassistant.helpers.config_validation as cv
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
from homeassistant.helpers.entity import Entity
|
2022-01-01 21:38:11 +00:00
|
|
|
from homeassistant.helpers.typing import ConfigType
|
2022-03-29 04:56:04 +00:00
|
|
|
from homeassistant.util import slugify
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
from .const import CONF_IMPORT_PLUGINS, DOMAIN
|
|
|
|
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
2019-02-13 20:21:14 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
CONF_COLOR = "color"
|
|
|
|
CONF_DEVICE_CONFIG = "device_config"
|
|
|
|
CONF_DIMMING = "dimming"
|
|
|
|
CONF_GATEWAYS = "gateways"
|
|
|
|
CONF_PLUGINS = "plugins"
|
|
|
|
CONF_RESET_COLOR = "reset_color"
|
2022-03-26 19:50:50 +00:00
|
|
|
FIBARO_CONTROLLER = "fibaro_controller"
|
2019-07-31 19:25:30 +00:00
|
|
|
FIBARO_DEVICES = "fibaro_devices"
|
2021-03-02 20:43:59 +00:00
|
|
|
PLATFORMS = [
|
2021-12-28 20:13:20 +00:00
|
|
|
Platform.BINARY_SENSOR,
|
|
|
|
Platform.CLIMATE,
|
|
|
|
Platform.COVER,
|
|
|
|
Platform.LIGHT,
|
|
|
|
Platform.SCENE,
|
|
|
|
Platform.SENSOR,
|
|
|
|
Platform.LOCK,
|
|
|
|
Platform.SWITCH,
|
2019-07-31 19:25:30 +00:00
|
|
|
]
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
FIBARO_TYPEMAP = {
|
2019-07-31 19:25:30 +00:00
|
|
|
"com.fibaro.multilevelSensor": "sensor",
|
|
|
|
"com.fibaro.binarySwitch": "switch",
|
|
|
|
"com.fibaro.multilevelSwitch": "switch",
|
|
|
|
"com.fibaro.FGD212": "light",
|
|
|
|
"com.fibaro.FGR": "cover",
|
|
|
|
"com.fibaro.doorSensor": "binary_sensor",
|
|
|
|
"com.fibaro.doorWindowSensor": "binary_sensor",
|
|
|
|
"com.fibaro.FGMS001": "binary_sensor",
|
|
|
|
"com.fibaro.heatDetector": "binary_sensor",
|
|
|
|
"com.fibaro.lifeDangerSensor": "binary_sensor",
|
|
|
|
"com.fibaro.smokeSensor": "binary_sensor",
|
|
|
|
"com.fibaro.remoteSwitch": "switch",
|
|
|
|
"com.fibaro.sensor": "sensor",
|
|
|
|
"com.fibaro.colorController": "light",
|
|
|
|
"com.fibaro.securitySensor": "binary_sensor",
|
|
|
|
"com.fibaro.hvac": "climate",
|
|
|
|
"com.fibaro.setpoint": "climate",
|
|
|
|
"com.fibaro.FGT001": "climate",
|
|
|
|
"com.fibaro.thermostatDanfoss": "climate",
|
2020-08-29 02:16:02 +00:00
|
|
|
"com.fibaro.doorLock": "lock",
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
}
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema(
|
|
|
|
{
|
|
|
|
vol.Optional(CONF_DIMMING): cv.boolean,
|
|
|
|
vol.Optional(CONF_COLOR): cv.boolean,
|
|
|
|
vol.Optional(CONF_WHITE_VALUE): cv.boolean,
|
|
|
|
vol.Optional(CONF_RESET_COLOR): cv.boolean,
|
|
|
|
vol.Optional(CONF_DEVICE_CLASS): cv.string,
|
|
|
|
vol.Optional(CONF_ICON): cv.string,
|
|
|
|
}
|
|
|
|
)
|
2018-12-14 12:35:12 +00:00
|
|
|
|
|
|
|
FIBARO_ID_LIST_SCHEMA = vol.Schema([cv.string])
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
GATEWAY_CONFIG = vol.Schema(
|
|
|
|
{
|
|
|
|
vol.Required(CONF_PASSWORD): cv.string,
|
|
|
|
vol.Required(CONF_USERNAME): cv.string,
|
|
|
|
vol.Required(CONF_URL): cv.url,
|
|
|
|
vol.Optional(CONF_PLUGINS, default=False): cv.boolean,
|
|
|
|
vol.Optional(CONF_EXCLUDE, default=[]): FIBARO_ID_LIST_SCHEMA,
|
|
|
|
vol.Optional(CONF_DEVICE_CONFIG, default={}): vol.Schema(
|
|
|
|
{cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}
|
|
|
|
),
|
|
|
|
},
|
|
|
|
extra=vol.ALLOW_EXTRA,
|
|
|
|
)
|
|
|
|
|
|
|
|
CONFIG_SCHEMA = vol.Schema(
|
2022-03-26 19:50:50 +00:00
|
|
|
vol.All(
|
|
|
|
cv.deprecated(DOMAIN),
|
|
|
|
{
|
|
|
|
DOMAIN: vol.Schema(
|
|
|
|
{vol.Required(CONF_GATEWAYS): vol.All(cv.ensure_list, [GATEWAY_CONFIG])}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
2019-07-31 19:25:30 +00:00
|
|
|
extra=vol.ALLOW_EXTRA,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class FibaroController:
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
"""Initiate Fibaro Controller Class."""
|
|
|
|
|
2022-04-26 16:52:12 +00:00
|
|
|
def __init__(
|
|
|
|
self, config: dict[str, Any], serial_number: str | None = None
|
|
|
|
) -> None:
|
|
|
|
"""Initialize the Fibaro controller.
|
|
|
|
|
|
|
|
Version 4 is used for home center 2 (SN starts with HC2) and
|
|
|
|
home center lite (SN starts with HCL).
|
|
|
|
|
|
|
|
Version 5 is used for home center 3 (SN starts with HC3),
|
|
|
|
home center 3 lite (SN starts with HC3L) and yubii home (SN starts with YH).
|
|
|
|
|
|
|
|
Here the serial number is optional and we choose then the V4 client. You
|
|
|
|
should do that only when you use the FibaroController for login test as only
|
|
|
|
the login and info API's are equal throughout the different versions.
|
|
|
|
"""
|
|
|
|
if (
|
|
|
|
serial_number is None
|
|
|
|
or serial_number.upper().startswith("HC2")
|
|
|
|
or serial_number.upper().startswith("HCL")
|
|
|
|
):
|
|
|
|
self._client = FibaroClientV4(
|
|
|
|
config[CONF_URL], config[CONF_USERNAME], config[CONF_PASSWORD]
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
self._client = FibaroClientV5(
|
|
|
|
config[CONF_URL], config[CONF_USERNAME], config[CONF_PASSWORD]
|
|
|
|
)
|
|
|
|
|
2018-12-03 13:57:55 +00:00
|
|
|
self._scene_map = None
|
2018-12-14 12:35:12 +00:00
|
|
|
# Whether to import devices from plugins
|
2022-03-26 19:50:50 +00:00
|
|
|
self._import_plugins = config[CONF_IMPORT_PLUGINS]
|
2019-02-13 20:21:14 +00:00
|
|
|
self._room_map = None # Mapping roomId to room object
|
|
|
|
self._device_map = None # Mapping deviceId to device object
|
2022-04-26 16:52:12 +00:00
|
|
|
self.fibaro_devices: dict[str, list] = defaultdict(
|
|
|
|
list
|
|
|
|
) # List of devices by type
|
|
|
|
self._callbacks: dict[Any, Any] = {} # Update value callbacks by deviceId
|
2019-02-13 20:21:14 +00:00
|
|
|
self._state_handler = None # Fiblary's StateHandler object
|
2019-07-31 19:25:30 +00:00
|
|
|
self.hub_serial = None # Unique serial number of the hub
|
2022-03-26 19:50:50 +00:00
|
|
|
self.name = None # The friendly name of the hub
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
def connect(self):
|
|
|
|
"""Start the communication with the Fibaro controller."""
|
|
|
|
try:
|
|
|
|
login = self._client.login.get()
|
2018-12-06 08:28:06 +00:00
|
|
|
info = self._client.info.get()
|
|
|
|
self.hub_serial = slugify(info.serialNumber)
|
2022-03-26 19:50:50 +00:00
|
|
|
self.name = slugify(info.hcName)
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
except AssertionError:
|
2020-07-05 21:04:19 +00:00
|
|
|
_LOGGER.error("Can't connect to Fibaro HC. Please check URL")
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
return False
|
|
|
|
if login is None or login.status is False:
|
2019-07-31 19:25:30 +00:00
|
|
|
_LOGGER.error(
|
2020-01-02 19:17:10 +00:00
|
|
|
"Invalid login for Fibaro HC. Please check username and password"
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
self._room_map = {room.id: room for room in self._client.rooms.list()}
|
|
|
|
self._read_devices()
|
2018-12-03 13:57:55 +00:00
|
|
|
self._read_scenes()
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
return True
|
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
def connect_with_error_handling(self) -> None:
|
|
|
|
"""Translate connect errors to easily differentiate auth and connect failures.
|
|
|
|
|
|
|
|
When there is a better error handling in the used library this can be improved.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
connected = self.connect()
|
|
|
|
if not connected:
|
|
|
|
raise FibaroConnectFailed("Connect status is false")
|
|
|
|
except HTTPException as http_ex:
|
|
|
|
if http_ex.details == "Forbidden":
|
|
|
|
raise FibaroAuthFailed from http_ex
|
|
|
|
|
|
|
|
raise FibaroConnectFailed from http_ex
|
|
|
|
except Exception as ex:
|
|
|
|
raise FibaroConnectFailed from ex
|
|
|
|
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
def enable_state_handler(self):
|
|
|
|
"""Start StateHandler thread for monitoring updates."""
|
2022-04-26 16:52:12 +00:00
|
|
|
if isinstance(self._client, FibaroClientV4):
|
|
|
|
self._state_handler = StateHandlerV4(self._client, self._on_state_change)
|
|
|
|
else:
|
|
|
|
self._state_handler = StateHandlerV5(self._client, self._on_state_change)
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
def disable_state_handler(self):
|
|
|
|
"""Stop StateHandler thread used for monitoring updates."""
|
|
|
|
self._state_handler.stop()
|
|
|
|
self._state_handler = None
|
|
|
|
|
|
|
|
def _on_state_change(self, state):
|
|
|
|
"""Handle change report received from the HomeCenter."""
|
|
|
|
callback_set = set()
|
2019-07-31 19:25:30 +00:00
|
|
|
for change in state.get("changes", []):
|
2018-11-29 21:57:05 +00:00
|
|
|
try:
|
2019-07-31 19:25:30 +00:00
|
|
|
dev_id = change.pop("id")
|
2020-10-28 19:43:48 +00:00
|
|
|
if dev_id not in self._device_map:
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
continue
|
2018-11-29 21:57:05 +00:00
|
|
|
device = self._device_map[dev_id]
|
|
|
|
for property_name, value in change.items():
|
2019-07-31 19:25:30 +00:00
|
|
|
if property_name == "log":
|
2018-11-29 21:57:05 +00:00
|
|
|
if value and value != "transfer OK":
|
2019-07-31 19:25:30 +00:00
|
|
|
_LOGGER.debug("LOG %s: %s", device.friendly_name, value)
|
2018-11-29 21:57:05 +00:00
|
|
|
continue
|
2019-07-31 19:25:30 +00:00
|
|
|
if property_name == "logTemp":
|
2018-11-29 21:57:05 +00:00
|
|
|
continue
|
|
|
|
if property_name in device.properties:
|
2019-07-31 19:25:30 +00:00
|
|
|
device.properties[property_name] = value
|
|
|
|
_LOGGER.debug(
|
|
|
|
"<- %s.%s = %s", device.ha_id, property_name, str(value)
|
|
|
|
)
|
2018-11-29 21:57:05 +00:00
|
|
|
else:
|
2019-07-31 19:25:30 +00:00
|
|
|
_LOGGER.warning("%s.%s not found", device.ha_id, property_name)
|
2018-11-29 21:57:05 +00:00
|
|
|
if dev_id in self._callbacks:
|
|
|
|
callback_set.add(dev_id)
|
|
|
|
except (ValueError, KeyError):
|
|
|
|
pass
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
for item in callback_set:
|
2022-01-19 18:32:44 +00:00
|
|
|
for callback in self._callbacks[item]:
|
|
|
|
callback()
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
def register(self, device_id, callback):
|
|
|
|
"""Register device with a callback for updates."""
|
2022-01-19 18:32:44 +00:00
|
|
|
self._callbacks.setdefault(device_id, [])
|
|
|
|
self._callbacks[device_id].append(callback)
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
2019-04-09 04:24:57 +00:00
|
|
|
def get_children(self, device_id):
|
|
|
|
"""Get a list of child devices."""
|
|
|
|
return [
|
2019-07-31 19:25:30 +00:00
|
|
|
device
|
|
|
|
for device in self._device_map.values()
|
|
|
|
if device.parentId == device_id
|
|
|
|
]
|
2019-04-09 04:24:57 +00:00
|
|
|
|
2020-09-07 02:03:03 +00:00
|
|
|
def get_children2(self, device_id, endpoint_id):
|
|
|
|
"""Get a list of child devices for the same endpoint."""
|
|
|
|
return [
|
|
|
|
device
|
|
|
|
for device in self._device_map.values()
|
|
|
|
if device.parentId == device_id
|
|
|
|
and (
|
|
|
|
"endPointId" not in device.properties
|
|
|
|
or device.properties.endPointId == endpoint_id
|
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
def get_siblings(self, device):
|
2019-04-09 04:24:57 +00:00
|
|
|
"""Get the siblings of a device."""
|
2020-09-07 02:03:03 +00:00
|
|
|
if "endPointId" in device.properties:
|
|
|
|
return self.get_children2(
|
|
|
|
self._device_map[device.id].parentId,
|
|
|
|
self._device_map[device.id].properties.endPointId,
|
|
|
|
)
|
|
|
|
return self.get_children(self._device_map[device.id].parentId)
|
2019-04-09 04:24:57 +00:00
|
|
|
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
@staticmethod
|
|
|
|
def _map_device_to_type(device):
|
|
|
|
"""Map device to HA device type."""
|
|
|
|
# Use our lookup table to identify device type
|
2019-01-11 23:29:54 +00:00
|
|
|
device_type = None
|
2019-07-31 19:25:30 +00:00
|
|
|
if "type" in device:
|
2018-11-29 21:57:05 +00:00
|
|
|
device_type = FIBARO_TYPEMAP.get(device.type)
|
2019-07-31 19:25:30 +00:00
|
|
|
if device_type is None and "baseType" in device:
|
2018-11-29 21:57:05 +00:00
|
|
|
device_type = FIBARO_TYPEMAP.get(device.baseType)
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
# We can also identify device type by its capabilities
|
|
|
|
if device_type is None:
|
2019-07-31 19:25:30 +00:00
|
|
|
if "setBrightness" in device.actions:
|
|
|
|
device_type = "light"
|
|
|
|
elif "turnOn" in device.actions:
|
|
|
|
device_type = "switch"
|
|
|
|
elif "open" in device.actions:
|
|
|
|
device_type = "cover"
|
2020-08-29 02:16:02 +00:00
|
|
|
elif "secure" in device.actions:
|
|
|
|
device_type = "lock"
|
2019-07-31 19:25:30 +00:00
|
|
|
elif "value" in device.properties:
|
|
|
|
if device.properties.value in ("true", "false"):
|
|
|
|
device_type = "binary_sensor"
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
else:
|
2019-07-31 19:25:30 +00:00
|
|
|
device_type = "sensor"
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
# Switches that control lights should show up as lights
|
2020-07-14 20:47:05 +00:00
|
|
|
if device_type == "switch" and device.properties.get("isLight", False):
|
2019-07-31 19:25:30 +00:00
|
|
|
device_type = "light"
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
return device_type
|
|
|
|
|
2018-12-03 13:57:55 +00:00
|
|
|
def _read_scenes(self):
|
|
|
|
scenes = self._client.scenes.list()
|
|
|
|
self._scene_map = {}
|
|
|
|
for device in scenes:
|
2020-08-17 06:19:34 +00:00
|
|
|
if "name" not in device or "id" not in device:
|
2018-12-03 13:57:55 +00:00
|
|
|
continue
|
2019-01-11 23:29:54 +00:00
|
|
|
device.fibaro_controller = self
|
2020-08-17 06:19:34 +00:00
|
|
|
if "roomID" not in device or device.roomID == 0:
|
2019-07-31 19:25:30 +00:00
|
|
|
room_name = "Unknown"
|
2018-12-03 13:57:55 +00:00
|
|
|
else:
|
|
|
|
room_name = self._room_map[device.roomID].name
|
2018-12-06 08:28:06 +00:00
|
|
|
device.room_name = room_name
|
2019-09-03 15:10:56 +00:00
|
|
|
device.friendly_name = f"{room_name} {device.name}"
|
2020-02-25 01:54:20 +00:00
|
|
|
device.ha_id = (
|
|
|
|
f"scene_{slugify(room_name)}_{slugify(device.name)}_{device.id}"
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2019-09-03 15:10:56 +00:00
|
|
|
device.unique_id_str = f"{self.hub_serial}.scene.{device.id}"
|
2018-12-03 13:57:55 +00:00
|
|
|
self._scene_map[device.id] = device
|
2019-07-31 19:25:30 +00:00
|
|
|
self.fibaro_devices["scene"].append(device)
|
2020-08-17 06:19:34 +00:00
|
|
|
_LOGGER.debug("%s scene -> %s", device.ha_id, device)
|
2018-12-03 13:57:55 +00:00
|
|
|
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
def _read_devices(self):
|
|
|
|
"""Read and process the device list."""
|
|
|
|
devices = self._client.devices.list()
|
|
|
|
self._device_map = {}
|
2019-04-09 04:24:57 +00:00
|
|
|
last_climate_parent = None
|
2020-09-07 02:03:03 +00:00
|
|
|
last_endpoint = None
|
2018-11-29 21:57:05 +00:00
|
|
|
for device in devices:
|
|
|
|
try:
|
2020-08-17 06:19:34 +00:00
|
|
|
if "name" not in device or "id" not in device:
|
|
|
|
continue
|
2019-01-11 23:29:54 +00:00
|
|
|
device.fibaro_controller = self
|
2020-08-17 06:19:34 +00:00
|
|
|
if "roomID" not in device or device.roomID == 0:
|
2019-07-31 19:25:30 +00:00
|
|
|
room_name = "Unknown"
|
2018-11-29 21:57:05 +00:00
|
|
|
else:
|
|
|
|
room_name = self._room_map[device.roomID].name
|
2018-12-06 08:28:06 +00:00
|
|
|
device.room_name = room_name
|
2020-01-03 13:47:06 +00:00
|
|
|
device.friendly_name = f"{room_name} {device.name}"
|
2020-02-25 01:54:20 +00:00
|
|
|
device.ha_id = (
|
|
|
|
f"{slugify(room_name)}_{slugify(device.name)}_{device.id}"
|
2019-07-31 19:25:30 +00:00
|
|
|
)
|
2022-03-26 19:50:50 +00:00
|
|
|
if device.enabled and (
|
|
|
|
"isPlugin" not in device
|
|
|
|
or (not device.isPlugin or self._import_plugins)
|
2019-07-31 19:25:30 +00:00
|
|
|
):
|
2018-11-29 21:57:05 +00:00
|
|
|
device.mapped_type = self._map_device_to_type(device)
|
|
|
|
else:
|
|
|
|
device.mapped_type = None
|
2021-10-17 18:05:11 +00:00
|
|
|
if (dtype := device.mapped_type) is None:
|
2020-09-07 02:03:03 +00:00
|
|
|
continue
|
|
|
|
device.unique_id_str = f"{self.hub_serial}.{device.id}"
|
|
|
|
self._device_map[device.id] = device
|
2019-07-31 19:25:30 +00:00
|
|
|
_LOGGER.debug(
|
|
|
|
"%s (%s, %s) -> %s %s",
|
|
|
|
device.ha_id,
|
|
|
|
device.type,
|
|
|
|
device.baseType,
|
|
|
|
dtype,
|
|
|
|
str(device),
|
|
|
|
)
|
2020-09-07 02:03:03 +00:00
|
|
|
if dtype != "climate":
|
|
|
|
self.fibaro_devices[dtype].append(device)
|
|
|
|
continue
|
|
|
|
# We group climate devices into groups with the same
|
|
|
|
# endPointID belonging to the same parent device.
|
|
|
|
if "endPointId" in device.properties:
|
|
|
|
_LOGGER.debug(
|
|
|
|
"climate device: %s, endPointId: %s",
|
|
|
|
device.ha_id,
|
|
|
|
device.properties.endPointId,
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
_LOGGER.debug("climate device: %s, no endPointId", device.ha_id)
|
|
|
|
# If a sibling of this device has been added, skip this one
|
|
|
|
# otherwise add the first visible device in the group
|
|
|
|
# which is a hack, but solves a problem with FGT having
|
|
|
|
# hidden compatibility devices before the real device
|
|
|
|
if last_climate_parent != device.parentId or (
|
|
|
|
"endPointId" in device.properties
|
|
|
|
and last_endpoint != device.properties.endPointId
|
|
|
|
):
|
|
|
|
_LOGGER.debug("Handle separately")
|
|
|
|
self.fibaro_devices[dtype].append(device)
|
|
|
|
last_climate_parent = device.parentId
|
|
|
|
if "endPointId" in device.properties:
|
|
|
|
last_endpoint = device.properties.endPointId
|
|
|
|
else:
|
|
|
|
last_endpoint = 0
|
|
|
|
else:
|
|
|
|
_LOGGER.debug("not handling separately")
|
2018-11-29 21:57:05 +00:00
|
|
|
except (KeyError, ValueError):
|
|
|
|
pass
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
async def async_setup(hass: HomeAssistant, base_config: ConfigType) -> bool:
|
|
|
|
"""Migrate configuration from configuration.yaml."""
|
|
|
|
if DOMAIN not in base_config:
|
|
|
|
return True
|
2019-01-11 23:29:54 +00:00
|
|
|
gateways = base_config[DOMAIN][CONF_GATEWAYS]
|
2022-03-26 19:50:50 +00:00
|
|
|
if gateways is None:
|
|
|
|
return True
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
# check if already configured
|
|
|
|
if hass.config_entries.async_entries(DOMAIN):
|
|
|
|
return True
|
|
|
|
|
|
|
|
for gateway in gateways:
|
|
|
|
# prepare new config based on configuration.yaml
|
|
|
|
conf = {
|
|
|
|
CONF_URL: gateway[CONF_URL],
|
|
|
|
CONF_USERNAME: gateway[CONF_USERNAME],
|
|
|
|
CONF_PASSWORD: gateway[CONF_PASSWORD],
|
|
|
|
CONF_IMPORT_PLUGINS: gateway[CONF_PLUGINS],
|
|
|
|
}
|
|
|
|
|
|
|
|
# import into config flow based configuration
|
|
|
|
hass.async_create_task(
|
|
|
|
hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=conf
|
|
|
|
)
|
|
|
|
)
|
2019-01-11 23:29:54 +00:00
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
2022-04-26 16:52:12 +00:00
|
|
|
def _init_controller(data: dict[str, Any], serial_number: str) -> FibaroController:
|
2022-03-26 19:50:50 +00:00
|
|
|
"""Validate the user input allows us to connect to fibaro."""
|
2022-04-26 16:52:12 +00:00
|
|
|
controller = FibaroController(data, serial_number)
|
2022-03-26 19:50:50 +00:00
|
|
|
controller.connect_with_error_handling()
|
|
|
|
return controller
|
|
|
|
|
|
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2022-04-26 16:52:12 +00:00
|
|
|
"""Set up the Fibaro Component.
|
|
|
|
|
|
|
|
The unique id of the config entry is the serial number of the home center.
|
|
|
|
"""
|
2022-03-26 19:50:50 +00:00
|
|
|
try:
|
2022-04-26 16:52:12 +00:00
|
|
|
controller = await hass.async_add_executor_job(
|
|
|
|
_init_controller, entry.data, entry.unique_id
|
|
|
|
)
|
2022-03-26 19:50:50 +00:00
|
|
|
except FibaroConnectFailed as connect_ex:
|
|
|
|
raise ConfigEntryNotReady(
|
|
|
|
f"Could not connect to controller at {entry.data[CONF_URL]}"
|
|
|
|
) from connect_ex
|
|
|
|
except FibaroAuthFailed:
|
|
|
|
return False
|
|
|
|
|
|
|
|
data: dict[str, Any] = {}
|
|
|
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = data
|
|
|
|
data[FIBARO_CONTROLLER] = controller
|
|
|
|
devices = data[FIBARO_DEVICES] = {}
|
2021-03-02 20:43:59 +00:00
|
|
|
for platform in PLATFORMS:
|
2022-03-26 19:50:50 +00:00
|
|
|
devices[platform] = [*controller.fibaro_devices[platform]]
|
2019-01-11 23:29:54 +00:00
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
2019-01-11 23:29:54 +00:00
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
controller.enable_state_handler()
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
|
|
"""Unload a config entry."""
|
2022-03-28 15:23:44 +00:00
|
|
|
_LOGGER.debug("Shutting down Fibaro connection")
|
2022-03-26 19:50:50 +00:00
|
|
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
|
|
|
|
|
|
|
hass.data[DOMAIN][entry.entry_id][FIBARO_CONTROLLER].disable_state_handler()
|
|
|
|
hass.data[DOMAIN].pop(entry.entry_id)
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
return unload_ok
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FibaroDevice(Entity):
|
|
|
|
"""Representation of a Fibaro device entity."""
|
|
|
|
|
2019-01-11 23:29:54 +00:00
|
|
|
def __init__(self, fibaro_device):
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
"""Initialize the device."""
|
|
|
|
self.fibaro_device = fibaro_device
|
2019-01-11 23:29:54 +00:00
|
|
|
self.controller = fibaro_device.fibaro_controller
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
self.ha_id = fibaro_device.ha_id
|
2022-01-23 22:25:42 +00:00
|
|
|
self._attr_name = fibaro_device.friendly_name
|
|
|
|
self._attr_unique_id = fibaro_device.unique_id_str
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
async def async_added_to_hass(self):
|
|
|
|
"""Call when entity is added to hass."""
|
|
|
|
self.controller.register(self.fibaro_device.id, self._update_callback)
|
|
|
|
|
|
|
|
def _update_callback(self):
|
|
|
|
"""Update the state."""
|
|
|
|
self.schedule_update_ha_state(True)
|
|
|
|
|
2018-11-21 05:15:54 +00:00
|
|
|
@property
|
|
|
|
def level(self):
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
"""Get the level of Fibaro device."""
|
2019-07-31 19:25:30 +00:00
|
|
|
if "value" in self.fibaro_device.properties:
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
return self.fibaro_device.properties.value
|
|
|
|
return None
|
|
|
|
|
2018-11-21 05:15:54 +00:00
|
|
|
@property
|
|
|
|
def level2(self):
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
"""Get the tilt level of Fibaro device."""
|
2019-07-31 19:25:30 +00:00
|
|
|
if "value2" in self.fibaro_device.properties:
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
return self.fibaro_device.properties.value2
|
|
|
|
return None
|
|
|
|
|
|
|
|
def dont_know_message(self, action):
|
|
|
|
"""Make a warning in case we don't know how to perform an action."""
|
2019-07-31 19:25:30 +00:00
|
|
|
_LOGGER.warning(
|
2020-01-02 19:17:10 +00:00
|
|
|
"Not sure how to setValue: %s (available actions: %s)",
|
2019-07-31 19:25:30 +00:00
|
|
|
str(self.ha_id),
|
|
|
|
str(self.fibaro_device.actions),
|
|
|
|
)
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
def set_level(self, level):
|
|
|
|
"""Set the level of Fibaro device."""
|
|
|
|
self.action("setValue", level)
|
2019-07-31 19:25:30 +00:00
|
|
|
if "value" in self.fibaro_device.properties:
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
self.fibaro_device.properties.value = level
|
2019-07-31 19:25:30 +00:00
|
|
|
if "brightness" in self.fibaro_device.properties:
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
self.fibaro_device.properties.brightness = level
|
|
|
|
|
2018-11-21 05:15:54 +00:00
|
|
|
def set_level2(self, level):
|
|
|
|
"""Set the level2 of Fibaro device."""
|
|
|
|
self.action("setValue2", level)
|
2019-07-31 19:25:30 +00:00
|
|
|
if "value2" in self.fibaro_device.properties:
|
2018-11-21 05:15:54 +00:00
|
|
|
self.fibaro_device.properties.value2 = level
|
|
|
|
|
|
|
|
def call_turn_on(self):
|
|
|
|
"""Turn on the Fibaro device."""
|
|
|
|
self.action("turnOn")
|
|
|
|
|
|
|
|
def call_turn_off(self):
|
|
|
|
"""Turn off the Fibaro device."""
|
|
|
|
self.action("turnOff")
|
|
|
|
|
|
|
|
def call_set_color(self, red, green, blue, white):
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
"""Set the color of Fibaro device."""
|
2018-12-04 10:38:21 +00:00
|
|
|
red = int(max(0, min(255, red)))
|
|
|
|
green = int(max(0, min(255, green)))
|
|
|
|
blue = int(max(0, min(255, blue)))
|
|
|
|
white = int(max(0, min(255, white)))
|
2019-09-03 15:10:56 +00:00
|
|
|
color_str = f"{red},{green},{blue},{white}"
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
self.fibaro_device.properties.color = color_str
|
2019-07-31 19:25:30 +00:00
|
|
|
self.action("setColor", str(red), str(green), str(blue), str(white))
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
def action(self, cmd, *args):
|
|
|
|
"""Perform an action on the Fibaro HC."""
|
|
|
|
if cmd in self.fibaro_device.actions:
|
|
|
|
getattr(self.fibaro_device, cmd)(*args)
|
2019-07-31 19:25:30 +00:00
|
|
|
_LOGGER.debug("-> %s.%s%s called", str(self.ha_id), str(cmd), str(args))
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
else:
|
|
|
|
self.dont_know_message(cmd)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def current_binary_state(self):
|
|
|
|
"""Return the current binary state."""
|
2019-07-31 19:25:30 +00:00
|
|
|
if self.fibaro_device.properties.value == "false":
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
return False
|
2019-07-31 19:25:30 +00:00
|
|
|
if (
|
|
|
|
self.fibaro_device.properties.value == "true"
|
|
|
|
or int(self.fibaro_device.properties.value) > 0
|
|
|
|
):
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
@property
|
|
|
|
def should_poll(self):
|
|
|
|
"""Get polling requirement from fibaro device."""
|
|
|
|
return False
|
|
|
|
|
|
|
|
@property
|
2021-03-11 15:57:47 +00:00
|
|
|
def extra_state_attributes(self):
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
"""Return the state attributes of the device."""
|
2020-10-08 19:33:08 +00:00
|
|
|
attr = {"fibaro_id": self.fibaro_device.id}
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
try:
|
2019-07-31 19:25:30 +00:00
|
|
|
if "battery" in self.fibaro_device.interfaces:
|
|
|
|
attr[ATTR_BATTERY_LEVEL] = int(
|
|
|
|
self.fibaro_device.properties.batteryLevel
|
|
|
|
)
|
|
|
|
if "fibaroAlarmArm" in self.fibaro_device.interfaces:
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
attr[ATTR_ARMED] = bool(self.fibaro_device.properties.armed)
|
|
|
|
except (ValueError, KeyError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
return attr
|
2022-03-26 19:50:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FibaroConnectFailed(HomeAssistantError):
|
|
|
|
"""Error to indicate we cannot connect to fibaro home center."""
|
|
|
|
|
|
|
|
|
|
|
|
class FibaroAuthFailed(HomeAssistantError):
|
|
|
|
"""Error to indicate that authentication failed on fibaro home center."""
|