-
-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add HomematicIP Cloud smoke detector device #15621
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,7 @@ | |
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
| ATTR_WINDOW_STATE = 'window_state' | ||
| ATTR_EVENT_DELAY = 'event_delay' | ||
| ATTR_MOTION_DETECTED = 'motion_detected' | ||
| ATTR_ILLUMINATION = 'illumination' | ||
| STATE_SMOKE_OFF = 'IDLE_OFF' | ||
|
|
||
|
|
||
| async def async_setup_platform(hass, config, async_add_devices, | ||
|
|
@@ -30,15 +27,18 @@ async def async_setup_platform(hass, config, async_add_devices, | |
|
|
||
| async def async_setup_entry(hass, config_entry, async_add_devices): | ||
| """Set up the HomematicIP binary sensor from a config entry.""" | ||
| from homematicip.device import (ShutterContact, MotionDetectorIndoor) | ||
| from homematicip.aio.device import ( | ||
| AsyncShutterContact, AsyncMotionDetectorIndoor, AsyncSmokeDetector) | ||
|
|
||
| home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home | ||
| devices = [] | ||
| for device in home.devices: | ||
| if isinstance(device, ShutterContact): | ||
| if isinstance(device, AsyncShutterContact): | ||
| devices.append(HomematicipShutterContact(home, device)) | ||
| elif isinstance(device, MotionDetectorIndoor): | ||
| elif isinstance(device, AsyncMotionDetectorIndoor): | ||
| devices.append(HomematicipMotionDetector(home, device)) | ||
| elif isinstance(device, AsyncSmokeDetector): | ||
| devices.append(HomematicipSmokeDetector(home, device)) | ||
|
|
||
| if devices: | ||
| async_add_devices(devices) | ||
|
|
@@ -86,3 +86,21 @@ def is_on(self): | |
| if self._device.sabotage: | ||
| return True | ||
| return self._device.motionDetected | ||
|
|
||
|
|
||
| class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorDevice): | ||
| """MomematicIP smoke detector.""" | ||
|
|
||
| def __init__(self, home, device): | ||
|
Member
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. This isn't needed if just passing through the arguments to the parent.
Contributor
Author
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. Seems to be needed for multiple inheritance... if I remove it BinarySensorDevice is not initialised .
Member
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.
Contributor
Author
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. After clearing the build folder the symptoms are gone (I get again a "Clear" and not a False) |
||
| """Initialize the smoke detector.""" | ||
| super().__init__(home, device) | ||
|
|
||
| @property | ||
| def device_class(self): | ||
| """Return the class of this sensor.""" | ||
| return 'smoke' | ||
|
|
||
| @property | ||
| def is_on(self): | ||
| """Return true if smoke is detected.""" | ||
| return self._device.smokeDetectorAlarmType != STATE_SMOKE_OFF | ||
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.
A little typo there? MomematicIP