2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Fibaro binary sensors."""
|
2022-01-03 12:10:41 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2022-11-12 09:43:11 +00:00
|
|
|
from collections.abc import Mapping
|
2022-11-29 19:31:25 +00:00
|
|
|
from typing import Any, cast
|
2022-06-20 13:46:28 +00:00
|
|
|
|
2023-02-11 21:13:12 +00:00
|
|
|
from pyfibaro.fibaro_device import DeviceModel
|
|
|
|
|
2020-09-12 02:24:23 +00:00
|
|
|
from homeassistant.components.binary_sensor import (
|
2022-03-26 19:50:50 +00:00
|
|
|
ENTITY_ID_FORMAT,
|
2021-12-10 13:50:21 +00:00
|
|
|
BinarySensorDeviceClass,
|
2020-09-12 02:24:23 +00:00
|
|
|
BinarySensorEntity,
|
|
|
|
)
|
2022-03-26 19:50:50 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
2022-04-26 18:08:41 +00:00
|
|
|
from homeassistant.const import Platform
|
2022-01-03 12:10:41 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
2019-03-21 05:56:46 +00:00
|
|
|
|
|
|
|
from . import FIBARO_DEVICES, FibaroDevice
|
2022-03-26 19:50:50 +00:00
|
|
|
from .const import DOMAIN
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
|
|
|
SENSOR_TYPES = {
|
2022-04-27 00:12:59 +00:00
|
|
|
"com.fibaro.floodSensor": ["Flood", "mdi:water", BinarySensorDeviceClass.MOISTURE],
|
2021-12-10 13:50:21 +00:00
|
|
|
"com.fibaro.motionSensor": ["Motion", "mdi:run", BinarySensorDeviceClass.MOTION],
|
|
|
|
"com.fibaro.doorSensor": ["Door", "mdi:window-open", BinarySensorDeviceClass.DOOR],
|
|
|
|
"com.fibaro.windowSensor": [
|
|
|
|
"Window",
|
|
|
|
"mdi:window-open",
|
|
|
|
BinarySensorDeviceClass.WINDOW,
|
|
|
|
],
|
|
|
|
"com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", BinarySensorDeviceClass.SMOKE],
|
|
|
|
"com.fibaro.FGMS001": ["Motion", "mdi:run", BinarySensorDeviceClass.MOTION],
|
2022-04-27 00:12:59 +00:00
|
|
|
"com.fibaro.heatDetector": ["Heat", "mdi:fire", BinarySensorDeviceClass.HEAT],
|
2022-11-12 09:43:11 +00:00
|
|
|
"com.fibaro.accelerometer": [
|
|
|
|
"Moving",
|
|
|
|
"mdi:axis-arrow",
|
|
|
|
BinarySensorDeviceClass.MOVING,
|
|
|
|
],
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-26 19:50:50 +00:00
|
|
|
async def async_setup_entry(
|
2022-01-03 12:10:41 +00:00
|
|
|
hass: HomeAssistant,
|
2022-03-26 19:50:50 +00:00
|
|
|
entry: ConfigEntry,
|
|
|
|
async_add_entities: AddEntitiesCallback,
|
2022-01-03 12:10:41 +00:00
|
|
|
) -> None:
|
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
|
|
|
"""Perform the setup for Fibaro controller devices."""
|
2022-03-26 19:50:50 +00:00
|
|
|
async_add_entities(
|
2019-07-31 19:25:30 +00:00
|
|
|
[
|
|
|
|
FibaroBinarySensor(device)
|
2022-03-26 19:50:50 +00:00
|
|
|
for device in hass.data[DOMAIN][entry.entry_id][FIBARO_DEVICES][
|
2022-04-26 18:08:41 +00:00
|
|
|
Platform.BINARY_SENSOR
|
2022-03-26 19:50:50 +00:00
|
|
|
]
|
2019-07-31 19:25:30 +00:00
|
|
|
],
|
|
|
|
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
|
|
|
|
|
|
|
|
2020-04-23 19:57:07 +00:00
|
|
|
class FibaroBinarySensor(FibaroDevice, BinarySensorEntity):
|
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
|
|
|
"""Representation of a Fibaro Binary Sensor."""
|
|
|
|
|
2023-02-11 21:13:12 +00:00
|
|
|
def __init__(self, fibaro_device: DeviceModel) -> None:
|
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 binary_sensor."""
|
2019-01-11 23:29:54 +00:00
|
|
|
super().__init__(fibaro_device)
|
2022-03-26 19:50:50 +00:00
|
|
|
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
2022-11-12 09:43:11 +00:00
|
|
|
self._own_extra_state_attributes: Mapping[str, Any] = {}
|
|
|
|
self._fibaro_sensor_type = None
|
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
|
|
|
if fibaro_device.type in SENSOR_TYPES:
|
2022-11-12 09:43:11 +00:00
|
|
|
self._fibaro_sensor_type = fibaro_device.type
|
2023-02-11 21:13:12 +00:00
|
|
|
elif fibaro_device.base_type in SENSOR_TYPES:
|
|
|
|
self._fibaro_sensor_type = fibaro_device.base_type
|
2022-11-12 09:43:11 +00:00
|
|
|
if self._fibaro_sensor_type:
|
2022-11-29 19:31:25 +00:00
|
|
|
self._attr_device_class = cast(
|
|
|
|
BinarySensorDeviceClass, SENSOR_TYPES[self._fibaro_sensor_type][2]
|
|
|
|
)
|
2022-11-12 09:43:11 +00:00
|
|
|
self._attr_icon = SENSOR_TYPES[self._fibaro_sensor_type][1]
|
|
|
|
|
|
|
|
@property
|
|
|
|
def extra_state_attributes(self) -> Mapping[str, Any] | None:
|
|
|
|
"""Return the extra state attributes of the device."""
|
|
|
|
return super().extra_state_attributes | self._own_extra_state_attributes
|
Initial support for Fibaro HomeCenter hubs (#17891)
* Fibaro HC connection, initial commit
Very first steps working, connects, fetches devices, represents sensors, binary_sensors and lights towards HA.
* Cover, switch, bugfixes
Initial support for covers
Initial support for switches
Bugfixes
* Some cleanup and improved lights
pylint based cleanup
light switches handled properly
light features reported correctly
* Added status updates and actions
Lights, Blinds, Switches are mostly working now
* Code cleanup, fiblary3 req
Fiblary3 is now in pypi, set it as req
Cleanup based on pylint
* Included in .coveragerc and added how to use guide
Included the fibaro component in coveragerc
Added usage instructions to file header
* PyLint inspired fixes
Fixed pylint warnings
* PyLint inspired fixes
PyLint inspired fixes
* updated to fiblary3 0.1.5
* Minor fixes to finally pass pull req
Fixed fiblary3 to work with python 3.5
Updated fiblary3 to 0.1.6
(added energy and batteryLevel dummies)
* module import and flake8 fixes
Finally (hopefully) figured out what lint is complaining about
* Fixed color support for lights, simplified callback
Fixed color support for lights
Simplified callback for updates
Uses updated fiblary3 for color light handling
* Lean and mean refactor
While waiting for a brave reviewer, I've been making the code smaller and easier to understand.
* Minor fixes to please HoundCI
* Removed unused component
Scenes are not implemented yet
* Nicer comments.
* DEVICE_CLASS, ignore plugins, improved mapping
Added support for device class and icons in sensors and binary_sensors
Improved mapping of sensors and added heuristic matching
Added support for hidden devices
Fixed conversion to float in sensors
* Fixed dimming
Fibaro apparently does not need, nor like the extra turnOn commands for dimmers
* flake8
* Cleanup, Light fixes, switch power
Cleanup of the component to separate init from connect, handle connection error better
Improved light handling, especially for RGBW strips and working around Fibaro quirks
Added energy and power reporting to switches
* Missing comment added
Missing comment added to please flake8
* Removed everything but bin.sensors
Stripdown, hoping for a review
* better aligned comments
OMG
* Fixes based on code review
Fixes based on code review
* Implemented stopping
Implemented stopping of StateHandler thread
Cleanup for clarity
* Minor fix
Removed unnecessary list copying
* Nicer wording on shutdown
* Minor changes based on code review
* minor fixes based on code review
* removed extra line break
2018-11-14 19:58:32 +00:00
|
|
|
|
2022-06-20 13:46:28 +00:00
|
|
|
def update(self) -> None:
|
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 latest data and update the state."""
|
2022-11-12 09:43:11 +00:00
|
|
|
if self._fibaro_sensor_type == "com.fibaro.accelerometer":
|
|
|
|
# Accelerator sensors have values for the three axis x, y and z
|
|
|
|
moving_values = self._get_moving_values()
|
|
|
|
self._attr_is_on = self._is_moving(moving_values)
|
|
|
|
self._own_extra_state_attributes = self._get_xyz_moving(moving_values)
|
|
|
|
else:
|
|
|
|
self._attr_is_on = self.current_binary_state
|
|
|
|
|
|
|
|
def _get_xyz_moving(self, moving_values: Mapping[str, Any]) -> Mapping[str, Any]:
|
|
|
|
"""Return x y z values of the accelerator sensor value."""
|
|
|
|
attrs = {}
|
|
|
|
for axis_name in ("x", "y", "z"):
|
|
|
|
attrs[axis_name] = float(moving_values[axis_name])
|
|
|
|
return attrs
|
|
|
|
|
|
|
|
def _is_moving(self, moving_values: Mapping[str, Any]) -> bool:
|
|
|
|
"""Return that a moving is detected when one axis reports a value."""
|
|
|
|
for axis_name in ("x", "y", "z"):
|
|
|
|
if float(moving_values[axis_name]) != 0:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def _get_moving_values(self) -> Mapping[str, Any]:
|
|
|
|
"""Get the moving values of the accelerator sensor in a dict."""
|
2023-02-11 21:13:12 +00:00
|
|
|
return self.fibaro_device.value.dict_value()
|