2019-02-13 20:21:14 +00:00
|
|
|
"""Support for the Fibaro devices."""
|
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 logging
|
|
|
|
from collections import defaultdict
|
2018-12-06 08:28:06 +00:00
|
|
|
from typing import Optional
|
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
|
|
|
|
|
2018-12-14 12:35:12 +00:00
|
|
|
from homeassistant.const import (
|
2019-01-11 23:29:54 +00:00
|
|
|
ATTR_ARMED, ATTR_BATTERY_LEVEL, CONF_DEVICE_CLASS, CONF_EXCLUDE,
|
|
|
|
CONF_ICON, CONF_PASSWORD, CONF_URL, CONF_USERNAME,
|
2018-12-14 12:35:12 +00:00
|
|
|
CONF_WHITE_VALUE, EVENT_HOMEASSISTANT_STOP)
|
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 import discovery
|
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
|
2018-12-14 12:35:12 +00:00
|
|
|
from homeassistant.util import convert, 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
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
2019-02-13 20:21:14 +00:00
|
|
|
|
|
|
|
ATTR_CURRENT_ENERGY_KWH = 'current_energy_kwh'
|
|
|
|
ATTR_CURRENT_POWER_W = 'current_power_w'
|
|
|
|
|
|
|
|
CONF_COLOR = 'color'
|
|
|
|
CONF_DEVICE_CONFIG = 'device_config'
|
|
|
|
CONF_DIMMING = 'dimming'
|
|
|
|
CONF_GATEWAYS = 'gateways'
|
|
|
|
CONF_PLUGINS = 'plugins'
|
|
|
|
CONF_RESET_COLOR = 'reset_color'
|
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
|
|
|
DOMAIN = 'fibaro'
|
2019-01-11 23:29:54 +00:00
|
|
|
FIBARO_CONTROLLERS = 'fibaro_controllers'
|
2019-02-13 20:21:14 +00:00
|
|
|
FIBARO_DEVICES = 'fibaro_devices'
|
2019-04-09 04:24:57 +00:00
|
|
|
FIBARO_COMPONENTS = ['binary_sensor', 'climate', 'cover', 'light',
|
|
|
|
'scene', 'sensor', 'switch']
|
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 = {
|
|
|
|
'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',
|
Fibaro ubs (#18889)
* 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
* Added Fibaro omcponents
Added cover, light, sensor and switch components
* Improved support for Fibaro UBS
Improved support for Fibaro Universal Binary Sensor, when configured to flood sensor or motion sensor.
2018-12-02 09:52:37 +00:00
|
|
|
'com.fibaro.colorController': 'light',
|
2019-04-09 04:24:57 +00:00
|
|
|
'com.fibaro.securitySensor': 'binary_sensor',
|
|
|
|
'com.fibaro.hvac': 'climate',
|
|
|
|
'com.fibaro.setpoint': 'climate',
|
|
|
|
'com.fibaro.FGT001': 'climate',
|
|
|
|
'com.fibaro.thermostatDanfoss': 'climate'
|
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
|
|
|
}
|
|
|
|
|
2018-12-14 12:35:12 +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,
|
|
|
|
})
|
|
|
|
|
|
|
|
FIBARO_ID_LIST_SCHEMA = vol.Schema([cv.string])
|
|
|
|
|
2019-01-11 23:29:54 +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)
|
|
|
|
|
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
|
|
|
CONFIG_SCHEMA = vol.Schema({
|
|
|
|
DOMAIN: vol.Schema({
|
2019-02-13 20:21:14 +00:00
|
|
|
vol.Required(CONF_GATEWAYS): vol.All(cv.ensure_list, [GATEWAY_CONFIG]),
|
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
|
|
|
})
|
|
|
|
}, extra=vol.ALLOW_EXTRA)
|
|
|
|
|
|
|
|
|
|
|
|
class FibaroController():
|
|
|
|
"""Initiate Fibaro Controller Class."""
|
|
|
|
|
2019-01-11 23:29:54 +00:00
|
|
|
def __init__(self, config):
|
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 Fibaro controller."""
|
|
|
|
from fiblary3.client.v4.client import Client as FibaroClient
|
2019-01-11 23:29:54 +00:00
|
|
|
|
2019-02-13 20:21:14 +00:00
|
|
|
self._client = FibaroClient(
|
|
|
|
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
|
2019-01-11 23:29:54 +00:00
|
|
|
self._import_plugins = config[CONF_PLUGINS]
|
2018-12-14 12:35:12 +00:00
|
|
|
self._device_config = config[CONF_DEVICE_CONFIG]
|
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
|
|
|
|
self.fibaro_devices = None # List of devices by type
|
|
|
|
self._callbacks = {} # Update value callbacks by deviceId
|
|
|
|
self._state_handler = None # Fiblary's StateHandler object
|
2019-01-11 23:29:54 +00:00
|
|
|
self._excluded_devices = config[CONF_EXCLUDE]
|
2019-02-13 20:21:14 +00:00
|
|
|
self.hub_serial = None # Unique serial number 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)
|
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:
|
|
|
|
_LOGGER.error("Can't connect to Fibaro HC. "
|
|
|
|
"Please check URL.")
|
|
|
|
return False
|
|
|
|
if login is None or login.status is False:
|
|
|
|
_LOGGER.error("Invalid login for Fibaro HC. "
|
2019-02-13 20:21:14 +00:00
|
|
|
"Please check username and password")
|
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
|
|
|
|
|
|
|
|
def enable_state_handler(self):
|
|
|
|
"""Start StateHandler thread for monitoring updates."""
|
|
|
|
from fiblary3.client.v4.client import StateHandler
|
|
|
|
self._state_handler = StateHandler(self._client, self._on_state_change)
|
|
|
|
|
|
|
|
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()
|
|
|
|
for change in state.get('changes', []):
|
2018-11-29 21:57:05 +00:00
|
|
|
try:
|
|
|
|
dev_id = change.pop('id')
|
|
|
|
if dev_id not in self._device_map.keys():
|
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():
|
|
|
|
if property_name == 'log':
|
|
|
|
if value and value != "transfer OK":
|
|
|
|
_LOGGER.debug("LOG %s: %s",
|
|
|
|
device.friendly_name, value)
|
|
|
|
continue
|
|
|
|
if property_name == 'logTemp':
|
|
|
|
continue
|
|
|
|
if property_name in device.properties:
|
|
|
|
device.properties[property_name] = \
|
|
|
|
value
|
|
|
|
_LOGGER.debug("<- %s.%s = %s", device.ha_id,
|
|
|
|
property_name, str(value))
|
|
|
|
else:
|
|
|
|
_LOGGER.warning("%s.%s not found", device.ha_id,
|
|
|
|
property_name)
|
|
|
|
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:
|
|
|
|
self._callbacks[item]()
|
|
|
|
|
|
|
|
def register(self, device_id, callback):
|
|
|
|
"""Register device with a callback for updates."""
|
|
|
|
self._callbacks[device_id] = callback
|
|
|
|
|
2019-04-09 04:24:57 +00:00
|
|
|
def get_children(self, device_id):
|
|
|
|
"""Get a list of child devices."""
|
|
|
|
return [
|
|
|
|
device for device in self._device_map.values()
|
|
|
|
if device.parentId == device_id]
|
|
|
|
|
|
|
|
def get_siblings(self, device_id):
|
|
|
|
"""Get the siblings of a device."""
|
|
|
|
return self.get_children(self._device_map[device_id].parentId)
|
|
|
|
|
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
|
2018-11-29 21:57:05 +00:00
|
|
|
if 'type' in device:
|
|
|
|
device_type = FIBARO_TYPEMAP.get(device.type)
|
2019-01-11 23:29:54 +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:
|
|
|
|
if 'setBrightness' in device.actions:
|
|
|
|
device_type = 'light'
|
|
|
|
elif 'turnOn' in device.actions:
|
|
|
|
device_type = 'switch'
|
|
|
|
elif 'open' in device.actions:
|
|
|
|
device_type = 'cover'
|
|
|
|
elif 'value' in device.properties:
|
|
|
|
if device.properties.value in ('true', 'false'):
|
|
|
|
device_type = 'binary_sensor'
|
|
|
|
else:
|
|
|
|
device_type = 'sensor'
|
|
|
|
|
|
|
|
# Switches that control lights should show up as lights
|
|
|
|
if device_type == 'switch' and \
|
2018-11-29 21:57:05 +00:00
|
|
|
device.properties.get('isLight', 'false') == '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
|
|
|
device_type = 'light'
|
|
|
|
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:
|
|
|
|
if not device.visible:
|
|
|
|
continue
|
2019-01-11 23:29:54 +00:00
|
|
|
device.fibaro_controller = self
|
2018-12-03 13:57:55 +00:00
|
|
|
if device.roomID == 0:
|
|
|
|
room_name = 'Unknown'
|
|
|
|
else:
|
|
|
|
room_name = self._room_map[device.roomID].name
|
2018-12-06 08:28:06 +00:00
|
|
|
device.room_name = room_name
|
2018-12-03 13:57:55 +00:00
|
|
|
device.friendly_name = '{} {}'.format(room_name, device.name)
|
2019-04-17 16:56:34 +00:00
|
|
|
device.ha_id = 'scene_{}_{}_{}'.format(
|
2018-12-03 13:57:55 +00:00
|
|
|
slugify(room_name), slugify(device.name), device.id)
|
2019-04-17 16:56:34 +00:00
|
|
|
device.unique_id_str = "{}.scene.{}".format(
|
2018-12-06 08:28:06 +00:00
|
|
|
self.hub_serial, device.id)
|
2018-12-03 13:57:55 +00:00
|
|
|
self._scene_map[device.id] = device
|
|
|
|
self.fibaro_devices['scene'].append(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
|
|
|
def _read_devices(self):
|
|
|
|
"""Read and process the device list."""
|
|
|
|
devices = self._client.devices.list()
|
|
|
|
self._device_map = {}
|
|
|
|
self.fibaro_devices = defaultdict(list)
|
2019-04-09 04:24:57 +00:00
|
|
|
last_climate_parent = None
|
2018-11-29 21:57:05 +00:00
|
|
|
for device in devices:
|
|
|
|
try:
|
2019-01-11 23:29:54 +00:00
|
|
|
device.fibaro_controller = self
|
2018-11-29 21:57:05 +00:00
|
|
|
if device.roomID == 0:
|
|
|
|
room_name = 'Unknown'
|
|
|
|
else:
|
|
|
|
room_name = self._room_map[device.roomID].name
|
2018-12-06 08:28:06 +00:00
|
|
|
device.room_name = room_name
|
2018-11-29 21:57:05 +00:00
|
|
|
device.friendly_name = room_name + ' ' + device.name
|
|
|
|
device.ha_id = '{}_{}_{}'.format(
|
|
|
|
slugify(room_name), slugify(device.name), device.id)
|
|
|
|
if device.enabled and \
|
|
|
|
('isPlugin' not in device or
|
2018-12-14 12:35:12 +00:00
|
|
|
(not device.isPlugin or self._import_plugins)) and \
|
|
|
|
device.ha_id not in self._excluded_devices:
|
2018-11-29 21:57:05 +00:00
|
|
|
device.mapped_type = self._map_device_to_type(device)
|
2018-12-14 12:35:12 +00:00
|
|
|
device.device_config = \
|
|
|
|
self._device_config.get(device.ha_id, {})
|
2018-11-29 21:57:05 +00:00
|
|
|
else:
|
|
|
|
device.mapped_type = None
|
2019-04-09 04:24:57 +00:00
|
|
|
dtype = device.mapped_type
|
|
|
|
if dtype:
|
2018-12-06 08:28:06 +00:00
|
|
|
device.unique_id_str = "{}.{}".format(
|
|
|
|
self.hub_serial, device.id)
|
2018-11-29 21:57:05 +00:00
|
|
|
self._device_map[device.id] = device
|
2019-04-09 04:24:57 +00:00
|
|
|
if dtype != 'climate':
|
|
|
|
self.fibaro_devices[dtype].append(device)
|
|
|
|
else:
|
|
|
|
# if a sibling of this 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 and \
|
|
|
|
device.visible:
|
|
|
|
self.fibaro_devices[dtype].append(device)
|
|
|
|
last_climate_parent = device.parentId
|
|
|
|
_LOGGER.debug("%s (%s, %s) -> %s %s",
|
2019-01-11 23:29:54 +00:00
|
|
|
device.ha_id, device.type,
|
2019-04-09 04:24:57 +00:00
|
|
|
device.baseType, dtype,
|
|
|
|
str(device))
|
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
|
|
|
|
|
|
|
|
2019-01-11 23:29:54 +00:00
|
|
|
def setup(hass, base_config):
|
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 up the Fibaro Component."""
|
2019-01-11 23:29:54 +00:00
|
|
|
gateways = base_config[DOMAIN][CONF_GATEWAYS]
|
|
|
|
hass.data[FIBARO_CONTROLLERS] = {}
|
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 stop_fibaro(event):
|
|
|
|
"""Stop Fibaro Thread."""
|
|
|
|
_LOGGER.info("Shutting down Fibaro connection")
|
2019-01-11 23:29:54 +00:00
|
|
|
for controller in hass.data[FIBARO_CONTROLLERS].values():
|
|
|
|
controller.disable_state_handler()
|
|
|
|
|
|
|
|
hass.data[FIBARO_DEVICES] = {}
|
|
|
|
for component in FIBARO_COMPONENTS:
|
|
|
|
hass.data[FIBARO_DEVICES][component] = []
|
|
|
|
|
|
|
|
for gateway in gateways:
|
|
|
|
controller = FibaroController(gateway)
|
|
|
|
if controller.connect():
|
|
|
|
hass.data[FIBARO_CONTROLLERS][controller.hub_serial] = controller
|
|
|
|
for component in FIBARO_COMPONENTS:
|
|
|
|
hass.data[FIBARO_DEVICES][component].extend(
|
|
|
|
controller.fibaro_devices[component])
|
|
|
|
|
|
|
|
if hass.data[FIBARO_CONTROLLERS]:
|
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 component in FIBARO_COMPONENTS:
|
2019-01-11 23:29:54 +00:00
|
|
|
discovery.load_platform(hass, component, DOMAIN, {},
|
|
|
|
base_config)
|
|
|
|
for controller in hass.data[FIBARO_CONTROLLERS].values():
|
|
|
|
controller.enable_state_handler()
|
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
|
|
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_fibaro)
|
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
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._name = fibaro_device.friendly_name
|
|
|
|
self.ha_id = fibaro_device.ha_id
|
|
|
|
|
|
|
|
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."""
|
|
|
|
if 'value' in self.fibaro_device.properties:
|
|
|
|
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."""
|
|
|
|
if 'value2' in self.fibaro_device.properties:
|
|
|
|
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."""
|
|
|
|
_LOGGER.warning("Not sure how to setValue: %s "
|
|
|
|
"(available actions: %s)", str(self.ha_id),
|
|
|
|
str(self.fibaro_device.actions))
|
|
|
|
|
|
|
|
def set_level(self, level):
|
|
|
|
"""Set the level of Fibaro device."""
|
|
|
|
self.action("setValue", level)
|
|
|
|
if 'value' in self.fibaro_device.properties:
|
|
|
|
self.fibaro_device.properties.value = level
|
|
|
|
if 'brightness' in self.fibaro_device.properties:
|
|
|
|
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)
|
|
|
|
if 'value2' in self.fibaro_device.properties:
|
|
|
|
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)))
|
|
|
|
color_str = "{},{},{},{}".format(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
|
2018-12-04 10:38:21 +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)
|
|
|
|
_LOGGER.debug("-> %s.%s%s called", str(self.ha_id),
|
|
|
|
str(cmd), str(args))
|
|
|
|
else:
|
|
|
|
self.dont_know_message(cmd)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def hidden(self) -> bool:
|
|
|
|
"""Return True if the entity should be hidden from UIs."""
|
|
|
|
return self.fibaro_device.visible is False
|
|
|
|
|
|
|
|
@property
|
|
|
|
def current_power_w(self):
|
|
|
|
"""Return the current power usage in W."""
|
|
|
|
if 'power' in self.fibaro_device.properties:
|
|
|
|
power = self.fibaro_device.properties.power
|
|
|
|
if power:
|
|
|
|
return convert(power, float, 0.0)
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
@property
|
|
|
|
def current_binary_state(self):
|
|
|
|
"""Return the current binary state."""
|
|
|
|
if self.fibaro_device.properties.value == 'false':
|
|
|
|
return False
|
|
|
|
if self.fibaro_device.properties.value == 'true' or \
|
|
|
|
int(self.fibaro_device.properties.value) > 0:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
@property
|
2018-12-06 08:28:06 +00:00
|
|
|
def unique_id(self) -> str:
|
|
|
|
"""Return a unique ID."""
|
|
|
|
return self.fibaro_device.unique_id_str
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self) -> Optional[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
|
|
|
"""Return the name of the device."""
|
|
|
|
return self._name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def should_poll(self):
|
|
|
|
"""Get polling requirement from fibaro device."""
|
|
|
|
return False
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
"""Call to update state."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@property
|
|
|
|
def device_state_attributes(self):
|
|
|
|
"""Return the state attributes of the device."""
|
|
|
|
attr = {}
|
|
|
|
|
|
|
|
try:
|
|
|
|
if 'battery' in self.fibaro_device.interfaces:
|
|
|
|
attr[ATTR_BATTERY_LEVEL] = \
|
|
|
|
int(self.fibaro_device.properties.batteryLevel)
|
|
|
|
if 'fibaroAlarmArm' in self.fibaro_device.interfaces:
|
|
|
|
attr[ATTR_ARMED] = bool(self.fibaro_device.properties.armed)
|
|
|
|
if 'power' in self.fibaro_device.interfaces:
|
|
|
|
attr[ATTR_CURRENT_POWER_W] = convert(
|
|
|
|
self.fibaro_device.properties.power, float, 0.0)
|
|
|
|
if 'energy' in self.fibaro_device.interfaces:
|
|
|
|
attr[ATTR_CURRENT_ENERGY_KWH] = convert(
|
|
|
|
self.fibaro_device.properties.energy, float, 0.0)
|
|
|
|
except (ValueError, KeyError):
|
|
|
|
pass
|
|
|
|
|
2018-12-06 08:28:06 +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
|
|
|
return attr
|