-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Homematic Support #2366
Closed
Closed
Homematic Support #2366
Changes from all commits
Commits
Show all changes
224 commits
Select commit
Hold shift + click to select a range
d5d37dc
Added Homematic implementation
c099874
Added rest I just forgot
danielperna84 766b8a1
Fixes to pass tox-tests
danielperna84 25b7221
Added homematic
danielperna84 f4c8612
Updated requirements_all.txt
danielperna84 e7f4273
Changes for lint-tests
danielperna84 e4602ef
Removed pyling.d
danielperna84 280798d
Added Homematic implementation
26e29af
Added rest I just forgot
danielperna84 4cefd2d
Fixes to pass tox-tests
danielperna84 d3b33ea
Added homematic
danielperna84 f80f854
Updated requirements_all.txt
danielperna84 85d1307
Changes for lint-tests
danielperna84 d40fb29
Removed pyling.d
danielperna84 fec72b7
Merge branch 'Homematic' of https://github.com/danielperna84/home-ass…
danielperna84 da271e8
Fixes to pass lint-tests
danielperna84 d08518a
Re-added configuration examples in docstrings
danielperna84 a7a2ac3
Added wallbuttons, lots of remotes, better documentation
danielperna84 3ba0786
Better device-detection. More documentation.
danielperna84 e12742d
Added note about needed homematic-component to documentation.
danielperna84 975d734
Fixed lint errors
danielperna84 c18edfb
fix REQUIREMENTS handling
pvizeli d94fcb5
fix old style Server handling error
pvizeli 05f15a3
fix E129 linter
pvizeli b7d043d
fix pylint bad-continuation
pvizeli 451cdba
Merge pull request #2 from pvizeli/Homematic
danielperna84 cd69956
Removed pyhomematic requirement from lights-component
danielperna84 0f4311a
Switched to new pyhomematic 0.1.3 as requirement
danielperna84 34fb6ed
Added pyhomematic
danielperna84 30e6475
restruct HA-Homematic part 1
pvizeli 6a1d3fb
add attribute support
pvizeli 5a8f5c9
first draft for new homematic
pvizeli 27def92
add support for device discovery
pvizeli 2811957
improve creating names with multible channel/params
pvizeli 6138781
update device support for autodiscovery
pvizeli 482c578
add controll mode support for attribute
pvizeli df206a9
load data over hm metadata to data struct
pvizeli ddb957c
cleanup switch device
pvizeli 5186fc8
moded for new homematic support
pvizeli 2d1dc41
switch is now full implemented
pvizeli 9ebf845
first version of sensor for new release
pvizeli cd21f24
add error handling for better useability
pvizeli 6e8c510
add light support
pvizeli f736fed
support binary sensor
pvizeli dd4f945
support binary with multible sensors for state
pvizeli a403f48
add rollershuter support & add channels to other :)
pvizeli 9843bd6
add support for thermostat
pvizeli 9e932d6
fix a bug
pvizeli e92dca0
fix bug with autodiscovery & callback
pvizeli f5ea6e1
div. bugfix
pvizeli af1a798
fix flake8 errors
pvizeli 245c2d2
fix linter error
pvizeli f32417f
fix linter bug
pvizeli 8bda632
fix next range of pylinter
pvizeli 8a7713f
try this one...
pvizeli 5c78e73
hmm
pvizeli e94588b
fix linter
pvizeli 87b70b0
fix a lot of other linter message
pvizeli 857925d
last one...
pvizeli e448d39
better code style
pvizeli 30148d6
update pyhomatic version & fix bugs
pvizeli 784adf1
false ELEMENT to channel binding
pvizeli 6e6bb92
bugfix and loging info
pvizeli 7adfc4c
fix data load bug
pvizeli 1b7a441
fix event register
pvizeli 9e54500
STATE overwrite all datapoints. big fail
pvizeli bd44c37
fix _init_data_struct super() bug
pvizeli d598cc1
fix event subscription calc
pvizeli f73413e
fix check param
pvizeli d98efd3
change state over pyhomematic events
pvizeli 0a2b715
error handling
pvizeli 01b36b4
test
pvizeli 1aa15be
fix thread bug in HA
pvizeli a0b78bc
multible bugfixes
pvizeli fd65938
fix rolershutterdevice
pvizeli 78b1ac4
make _subscribe_homematic_events more stable
pvizeli 5b98c79
I hope this fix the light/switch bug
pvizeli 57e0534
fix possible dimmer troubles
pvizeli a46bfc3
possible errors
pvizeli 1641d18
fix linter error
pvizeli 318651d
disable linter check
pvizeli 4100ec3
add unit_of_measurement to sensor
pvizeli c93c3ee
attribute cast
pvizeli 4e9b285
Merge pull request #4 from pvizeli/Homematic
danielperna84 e5999ef
Merge remote-tracking branch 'refs/remotes/danielperna84/Homematic' i…
pvizeli 69f10c6
fix bug with HA Events only / remove party mode on thermostat
pvizeli 3064c6d
uups
pvizeli 0594471
fix linter error
pvizeli d5e2e49
fix bugs
pvizeli e869021
fix false class in binary sensor
pvizeli 4cc3543
fix state bug
pvizeli 0c93b28
this way is better...
pvizeli 46d912d
reset event in callback
pvizeli 904c86f
add debug log
pvizeli 002cb16
more debug strings
pvizeli 05796a5
add exeption handling
pvizeli 4a913b9
last debug strings
pvizeli 44d88af
fix error
pvizeli cef4341
fix debug
pvizeli cfe72fe
bugfix with name creation
pvizeli 95a3d17
catch the error
pvizeli f17a280
Merge pull request #1 from pvizeli/Homematic_auto
pvizeli 048849e
fix linter
pvizeli 997e93f
add gong sensor support
pvizeli 8d16b91
Merge pull request #8 from pvizeli/Homematic
danielperna84 3550d7d
fix autodetect
pvizeli 96d8497
it works
pvizeli e938849
Merge pull request #9 from pvizeli/Homematic
danielperna84 a6cea9b
hack for don't break the CCU :8ball:
pvizeli 80d1bb0
change from 3 second to 1 second
pvizeli 95ead30
Merge pull request #10 from pvizeli/Homematic
danielperna84 4575155
Fixed some typos, grammar, edited documentation and comments
danielperna84 11466df
Fixed some typos, grammar, edited documentation and comments, small b…
danielperna84 b4b4baf
Updated requirements_all.txt
danielperna84 eab8bb7
Added Homematic implementation
4239fe0
Added rest I just forgot
danielperna84 381572d
Fixes to pass tox-tests
danielperna84 ae39ffd
Added homematic
danielperna84 bd8175a
Updated requirements_all.txt
danielperna84 a28681b
Changes for lint-tests
danielperna84 5066454
Added Homematic implementation
9f70722
Added rest I just forgot
danielperna84 ab9b187
Fixes to pass tox-tests
danielperna84 f69789f
Updated requirements_all.txt
danielperna84 fa32a46
Changes for lint-tests
danielperna84 bf83a21
Removed pyling.d
danielperna84 38fe492
Fixes to pass lint-tests
danielperna84 124cc80
Re-added configuration examples in docstrings
danielperna84 5d5c19b
Added wallbuttons, lots of remotes, better documentation
danielperna84 4cc529f
Better device-detection. More documentation.
danielperna84 c793935
Added note about needed homematic-component to documentation.
danielperna84 b4cf5cf
Fixed lint errors
danielperna84 d8507f2
fix REQUIREMENTS handling
pvizeli b30d9c3
fix old style Server handling error
pvizeli 81eeed7
fix E129 linter
pvizeli 617fbd9
fix pylint bad-continuation
pvizeli d99fb2c
Removed pyhomematic requirement from lights-component
danielperna84 7d97d06
Switched to new pyhomematic 0.1.3 as requirement
danielperna84 1d0fc5e
restruct HA-Homematic part 1
pvizeli a323c5a
add attribute support
pvizeli d430459
first draft for new homematic
pvizeli 70f370e
add support for device discovery
pvizeli 00e268c
improve creating names with multible channel/params
pvizeli c91c440
update device support for autodiscovery
pvizeli fcf143f
add controll mode support for attribute
pvizeli a21b8c7
load data over hm metadata to data struct
pvizeli 3afc97c
cleanup switch device
pvizeli a99fccd
moded for new homematic support
pvizeli 7a1e742
switch is now full implemented
pvizeli 3e61cd5
first version of sensor for new release
pvizeli 1b2917b
add error handling for better useability
pvizeli 3f39ec7
add light support
pvizeli f9a5387
support binary sensor
pvizeli cd9edc4
support binary with multible sensors for state
pvizeli 5f1a5ea
add rollershuter support & add channels to other :)
pvizeli 5dcc469
add support for thermostat
pvizeli 981c3bd
fix a bug
pvizeli 19f4ec0
fix bug with autodiscovery & callback
pvizeli b4f7fe6
div. bugfix
pvizeli 309e02a
fix flake8 errors
pvizeli 244d24a
fix linter error
pvizeli 92dcd73
fix linter bug
pvizeli c1c2445
fix next range of pylinter
pvizeli 24a3215
try this one...
pvizeli c0a7c18
hmm
pvizeli 63866e9
fix linter
pvizeli 1bfedcc
fix a lot of other linter message
pvizeli f6da911
last one...
pvizeli 759ede8
better code style
pvizeli 4be52e0
update pyhomatic version & fix bugs
pvizeli ba67442
false ELEMENT to channel binding
pvizeli dc88155
bugfix and loging info
pvizeli a14bd37
fix data load bug
pvizeli e5bcc2d
fix event register
pvizeli cf50918
STATE overwrite all datapoints. big fail
pvizeli 262fb62
fix _init_data_struct super() bug
pvizeli ef6333f
fix event subscription calc
pvizeli a8a3bf0
fix check param
pvizeli 5055562
change state over pyhomematic events
pvizeli cf76eec
error handling
pvizeli 3230224
test
pvizeli 7b42a2e
fix thread bug in HA
pvizeli ae154de
multible bugfixes
pvizeli e314ac5
fix rolershutterdevice
pvizeli 8d83757
make _subscribe_homematic_events more stable
pvizeli aba6804
I hope this fix the light/switch bug
pvizeli 3529034
fix possible dimmer troubles
pvizeli 25b3389
possible errors
pvizeli d55caa5
fix linter error
pvizeli 7eaddf7
disable linter check
pvizeli 45fb6d1
add unit_of_measurement to sensor
pvizeli 5c2a4ad
attribute cast
pvizeli 710fa48
fix bug with HA Events only / remove party mode on thermostat
pvizeli 449da02
uups
pvizeli 99351f6
fix linter error
pvizeli a9da779
fix bugs
pvizeli e9a7319
fix false class in binary sensor
pvizeli e3942b7
fix state bug
pvizeli 90f1d51
this way is better...
pvizeli 6862251
reset event in callback
pvizeli a52e113
add debug log
pvizeli 3011bac
more debug strings
pvizeli a66f358
add exeption handling
pvizeli 9272829
last debug strings
pvizeli b3c0be4
fix error
pvizeli 2d9f67e
fix debug
pvizeli 3364e73
bugfix with name creation
pvizeli 0bb67e6
catch the error
pvizeli 3208a65
fix linter
pvizeli 41f2d01
add gong sensor support
pvizeli c90358a
fix autodetect
pvizeli 92cb024
it works
pvizeli 3f6dc6a
hack for don't break the CCU :8ball:
pvizeli a9df146
change from 3 second to 1 second
pvizeli 89294ec
Fixed some typos, grammar, edited documentation and comments
danielperna84 7862d3e
Fixed some typos, grammar, edited documentation and comments, small b…
danielperna84 95926d5
Updated requirements_all.txt
danielperna84 5582a67
Again requirements
danielperna84 e4f6666
Merge remote-tracking branch 'refs/remotes/danielperna84/Homematic' i…
pvizeli afb0f37
fix docstring & remove unwanted code in autedetect
pvizeli dc94f73
cleanup
pvizeli a9918b8
Merge pull request #11 from pvizeli/Homematic
danielperna84 fe0adda
update requirements
pvizeli 8fbe15e
Merge pull request #12 from pvizeli/Homematic
danielperna84 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
""" | ||
The homematic binary sensor platform. | ||
|
||
For more details about this platform, please refer to the documentation at | ||
https://home-assistant.io/components/binary_sensor.homematic/ | ||
|
||
Important: For this platform to work the homematic component has to be | ||
properly configured. | ||
|
||
Configuration (single channel, simple device): | ||
|
||
binary_sensor: | ||
- platform: homematic | ||
address: "<Homematic address for device>" # e.g. "JEQ0XXXXXXX" | ||
name: "<User defined name>" (optional) | ||
|
||
|
||
Configuration (multiple channels, like motion detector with buttons): | ||
|
||
binary_sensor: | ||
- platform: homematic | ||
address: "<Homematic address for device>" # e.g. "JEQ0XXXXXXX" | ||
param: <MOTION|PRESS_SHORT...> (device-dependent) (optional) | ||
button: n (integer of channel to map, device-dependent) (optional) | ||
name: "<User defined name>" (optional) | ||
binary_sensor: | ||
- platform: homematic | ||
... | ||
""" | ||
|
||
import logging | ||
from homeassistant.const import STATE_UNKNOWN | ||
from homeassistant.components.binary_sensor import BinarySensorDevice | ||
import homeassistant.components.homematic as homematic | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
DEPENDENCIES = ['homematic'] | ||
|
||
SENSOR_TYPES_CLASS = { | ||
"Remote": None, | ||
"ShutterContact": "opening", | ||
"Smoke": "smoke", | ||
"SmokeV2": "smoke", | ||
"Motion": "motion", | ||
"MotionV2": "motion", | ||
"RemoteMotion": None | ||
} | ||
|
||
SUPPORT_HM_EVENT_AS_BINMOD = [ | ||
"PRESS_LONG", | ||
"PRESS_SHORT" | ||
] | ||
|
||
|
||
def setup_platform(hass, config, add_callback_devices, discovery_info=None): | ||
"""Setup the platform.""" | ||
return homematic.setup_hmdevice_entity_helper(HMBinarySensor, | ||
config, | ||
add_callback_devices) | ||
|
||
|
||
class HMBinarySensor(homematic.HMDevice, BinarySensorDevice): | ||
"""Represents diverse binary Homematic units in Home Assistant.""" | ||
|
||
@property | ||
def is_on(self): | ||
"""Return True if switch is on.""" | ||
if not self.available: | ||
return False | ||
# no binary is defined, check all! | ||
if self._state is None: | ||
available_bin = self._create_binary_list_from_hm() | ||
for binary in available_bin: | ||
try: | ||
if binary in self._data and self._data[binary] == 1: | ||
return True | ||
except (ValueError, TypeError): | ||
_LOGGER.warning("%s datatype error!", self._name) | ||
return False | ||
|
||
# single binary | ||
return bool(self._hm_get_state()) | ||
|
||
@property | ||
def sensor_class(self): | ||
"""Return the class of this sensor, from SENSOR_CLASSES.""" | ||
if not self.available: | ||
return None | ||
|
||
# If state is MOTION (RemoteMotion works only) | ||
if self._state in "MOTION": | ||
return "motion" | ||
return SENSOR_TYPES_CLASS.get(self._hmdevice.__class__.__name__, None) | ||
|
||
def _check_hm_to_ha_object(self): | ||
"""Check if possible to use the HM Object as this HA type.""" | ||
from pyhomematic.devicetypes.sensors import HMBinarySensor\ | ||
as pyHMBinarySensor | ||
|
||
# Check compatibility from HMDevice | ||
if not super()._check_hm_to_ha_object(): | ||
return False | ||
|
||
# check if the homematic device correct for this HA device | ||
if not isinstance(self._hmdevice, pyHMBinarySensor): | ||
_LOGGER.critical("This %s can't be use as binary!", self._name) | ||
return False | ||
|
||
# load possible binary sensor | ||
available_bin = self._create_binary_list_from_hm() | ||
|
||
# if exists user value? | ||
if self._state and self._state not in available_bin: | ||
_LOGGER.critical("This %s have no binary with %s!", self._name, | ||
self._state) | ||
return False | ||
|
||
# only check and give a warining to User | ||
if self._state is None and len(available_bin) > 1: | ||
_LOGGER.warning("%s have multible binary params. It use all " + | ||
"binary nodes as one. Possible param values: %s", | ||
self._name, str(available_bin)) | ||
|
||
return True | ||
|
||
def _init_data_struct(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"""Generate a data struct (self._data) from hm metadata.""" | ||
super()._init_data_struct() | ||
|
||
# load possible binary sensor | ||
available_bin = self._create_binary_list_from_hm() | ||
|
||
# object have 1 binary | ||
if self._state is None and len(available_bin) == 1: | ||
for value in available_bin: | ||
self._state = value | ||
|
||
# no binary is definit, use all binary for state | ||
if self._state is None and len(available_bin) > 1: | ||
for node in available_bin: | ||
self._data.update({node: STATE_UNKNOWN}) | ||
|
||
# add state to data struct | ||
if self._state: | ||
_LOGGER.debug("%s init datastruct with main node '%s'", self._name, | ||
self._state) | ||
self._data.update({self._state: STATE_UNKNOWN}) | ||
|
||
def _create_binary_list_from_hm(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"""Generate a own metadata for binary_sensors.""" | ||
bin_data = {} | ||
if not self._hmdevice: | ||
return bin_data | ||
|
||
# copy all data from BINARYNODE | ||
bin_data.update(self._hmdevice.BINARYNODE) | ||
|
||
# copy all hm event they are supportet by this object | ||
for event, channel in self._hmdevice.EVENTNODE.items(): | ||
if event in SUPPORT_HM_EVENT_AS_BINMOD: | ||
bin_data.update({event: channel}) | ||
|
||
return bin_data |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
farcy v1.1