Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Initial support for Fibaro HomeCenter hubs #17891

Merged
merged 30 commits into from Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
81f3cd1
Fibaro HC connection, initial commit
pbalogh77 Oct 23, 2018
764f7ee
Cover, switch, bugfixes
pbalogh77 Oct 23, 2018
488f2ab
Some cleanup and improved lights
pbalogh77 Oct 23, 2018
6006e42
Added status updates and actions
pbalogh77 Oct 27, 2018
135efe3
Code cleanup, fiblary3 req
pbalogh77 Oct 27, 2018
cf0bd41
Included in .coveragerc and added how to use guide
pbalogh77 Oct 27, 2018
c5d262d
PyLint inspired fixes
pbalogh77 Oct 28, 2018
8d67c03
PyLint inspired fixes
pbalogh77 Oct 28, 2018
fd8222c
updated to fiblary3 0.1.5
pbalogh77 Oct 28, 2018
e39ca5d
Minor fixes to finally pass pull req
pbalogh77 Oct 29, 2018
a1a25ac
module import and flake8 fixes
pbalogh77 Oct 29, 2018
b3daaff
Fixed color support for lights, simplified callback
pbalogh77 Nov 2, 2018
004a35b
Lean and mean refactor
pbalogh77 Nov 3, 2018
f0daffb
Minor fixes to please HoundCI
pbalogh77 Nov 3, 2018
e3adfc5
Removed unused component
pbalogh77 Nov 3, 2018
24fdf13
Nicer comments.
pbalogh77 Nov 4, 2018
873b991
DEVICE_CLASS, ignore plugins, improved mapping
pbalogh77 Nov 4, 2018
dbc4f7a
Fixed dimming
pbalogh77 Nov 4, 2018
720cfe4
flake8
pbalogh77 Nov 5, 2018
f09bd58
Cleanup, Light fixes, switch power
pbalogh77 Nov 7, 2018
294bb17
Missing comment added
pbalogh77 Nov 8, 2018
b680c55
Removed everything but bin.sensors
pbalogh77 Nov 8, 2018
4e4c0bc
better aligned comments
pbalogh77 Nov 8, 2018
a801e2a
Fixes based on code review
pbalogh77 Nov 10, 2018
0d57aaf
Implemented stopping
pbalogh77 Nov 12, 2018
93e6533
Minor fix
pbalogh77 Nov 12, 2018
085bc31
Nicer wording on shutdown
pbalogh77 Nov 12, 2018
888527f
Minor changes based on code review
pbalogh77 Nov 13, 2018
47b0970
minor fixes based on code review
pbalogh77 Nov 14, 2018
3f70c44
removed extra line break
pbalogh77 Nov 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .coveragerc
Expand Up @@ -120,6 +120,9 @@ omit =
homeassistant/components/eufy.py
homeassistant/components/*/eufy.py

homeassistant/components/fibaro.py
homeassistant/components/*/fibaro.py

homeassistant/components/gc100.py
homeassistant/components/*/gc100.py

Expand Down
74 changes: 74 additions & 0 deletions homeassistant/components/binary_sensor/fibaro.py
@@ -0,0 +1,74 @@
"""
Support for Fibaro binary sensors.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.fibaro/
"""
import logging

from homeassistant.components.binary_sensor import (
BinarySensorDevice, ENTITY_ID_FORMAT)
from homeassistant.components.fibaro import (
FIBARO_CONTROLLER, FIBARO_DEVICES, FibaroDevice)

DEPENDENCIES = ['fibaro']

_LOGGER = logging.getLogger(__name__)

SENSOR_TYPES = {
'com.fibaro.doorSensor': ['Door', 'mdi:window-open', 'door'],
'com.fibaro.windowSensor': ['Window', 'mdi:window-open', 'window'],
'com.fibaro.smokeSensor': ['Smoke', 'mdi:smoking', 'smoke'],
'com.fibaro.FGMS001': ['Motion', 'mdi:run', 'motion'],
'com.fibaro.heatDetector': ['Heat', 'mdi:fire', 'heat'],
}


def setup_platform(hass, config, add_entities, discovery_info=None):
"""Perform the setup for Fibaro controller devices."""
if discovery_info is None:
return

add_entities(
pbalogh77 marked this conversation as resolved.
Show resolved Hide resolved
[FibaroBinarySensor(device, hass.data[FIBARO_CONTROLLER])
for device in hass.data[FIBARO_DEVICES]['binary_sensor']], True)


class FibaroBinarySensor(FibaroDevice, BinarySensorDevice):
"""Representation of a Fibaro Binary Sensor."""

def __init__(self, fibaro_device, controller):
"""Initialize the binary_sensor."""
self._state = None
super().__init__(fibaro_device, controller)
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
stype = None
if fibaro_device.type in SENSOR_TYPES:
stype = fibaro_device.type
elif fibaro_device.baseType in SENSOR_TYPES:
stype = fibaro_device.baseType
if stype:
self._device_class = SENSOR_TYPES[stype][2]
self._icon = SENSOR_TYPES[stype][1]
else:
self._device_class = None
self._icon = None

@property
def icon(self):
"""Icon to use in the frontend, if any."""
return self._icon

@property
def device_class(self):
"""Return the device class of the sensor."""
return self._device_class

@property
def is_on(self):
"""Return true if sensor is on."""
return self._state

def update(self):
"""Get the latest data and update the state."""
self._state = self.current_binary_state