-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
Add totalconnect zones as binary sensors #28712
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
Merged
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
54dbdd6
Merge pull request #1 from home-assistant/dev
austinmroczek 90483d2
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
austinmroczek 51aa773
Bump skybellpy to 0.4.0
austinmroczek e18b4d2
Bump skybellpy to 0.4.0 in requirements_all.txt
austinmroczek d74156a
Added extra states for STATE_ALARM_TRIGGERED to allow users to know if
austinmroczek ad1cdb3
Merge branch 'dev' of https://github.com/austinmroczek/home-assistant…
austinmroczek 5c5c052
Merge pull request #2 from home-assistant/dev
austinmroczek abcc85a
Fix const import
austinmroczek d303091
Fix const import
austinmroczek 73f38eb
Fix const imports
austinmroczek 5bec7e4
Bump total-connect-client to 0.26.
austinmroczek 4862ff5
Catch details of alarm trigger in state attributes.
austinmroczek 5068345
Merge branch 'dev' of
austinmroczek e7a13d4
Change state_attributes() to device_state_attributes()
austinmroczek 53f20fb
Merge remote-tracking branch 'upstream/dev' into dev
austinmroczek 4bee662
Merge branch 'dev' of https://github.com/austinmroczek/home-assistant…
austinmroczek 6a50e80
Move totalconnect component toward being a multi-platform integration…
austinmroczek 37c34cf
Merge pull request #4 from home-assistant/dev
austinmroczek ad4c4c9
add missing total-connect alarm state mappings
austinmroczek e589317
Made recommended changes of MartinHjelmare at
austinmroczek aa22440
Update __init__.py
austinmroczek 5cbfc98
Updates per MartinHjelmare comments
austinmroczek eb440cc
flake8/pydocstyle fixes
austinmroczek 69425d7
Merge branch 'dev' of https://github.com/austinmroczek/home-assistant…
austinmroczek 117ed1b
removed . at end of log message
austinmroczek 14d3e2e
added blank line between logging and voluptuous
austinmroczek cd2b563
more fixes
austinmroczek 2295b7c
Merge remote-tracking branch 'upstream/dev' into dev
austinmroczek db6336b
Adding totalconnect zones as HA binary_sensors
austinmroczek e9a0e69
fix manifest.json
austinmroczek 1bc164d
flake8/pydocstyle fixes. Added codeowner.
austinmroczek 932e5b0
Update formatting per @springstan guidance.
austinmroczek bf7be02
Fixed pylint
austinmroczek f855154
Merge remote-tracking branch 'upstream/dev' into dev
austinmroczek fcadf80
Add zone ID to log message for easier troubleshooting
austinmroczek a68576e
Account for bypassed zones in update()
austinmroczek a15b4de
More status handling fixes.
austinmroczek ea1510f
Fixed flake8 error
austinmroczek 7f7ec1c
Another attempt at black/isort fixes.
austinmroczek 4de1bcf
Bump total-connect-client to 0.50. Simplify code using new functions in
austinmroczek b66ba1f
Fix manifest file
austinmroczek 4027382
Another manifest fix
austinmroczek 656e88d
one more manifest fix
austinmroczek eca1045
more manifest changes.
austinmroczek 750fc0b
sync up
austinmroczek fd927a3
Merge remote-tracking branch 'upstream/dev' into dev
austinmroczek 10f1642
Merge branch 'dev' of https://github.com/austinmroczek/home-assistant…
austinmroczek 25f530b
fix indent
austinmroczek d9700f8
one more pylint fix
austinmroczek 81f4cef
Hopefully the last pylint fix
austinmroczek 6f0e779
make variable names understandable
austinmroczek c654941
create and fill dict in one step
austinmroczek 1c32671
Fix name and attributes
austinmroczek 35d3085
rename to logical variable in alarm_control_panel
austinmroczek c9b208d
Remove location_name from alarm_control_panel attributes since it is
austinmroczek 10b555e
Multiple fixes to improve code per @springstan suggestions
austinmroczek 19b0c63
Update homeassistant/components/totalconnect/binary_sensor.py
austinmroczek 471b01a
Multiple changes per @MartinHjelmare review
austinmroczek ef06453
simplify alarm adding
austinmroczek 0c1234e
Fix binary_sensor.py is_on
austinmroczek 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,90 @@ | ||
| """Interfaces with TotalConnect sensors.""" | ||
| import logging | ||
|
|
||
| from homeassistant.components.binary_sensor import ( | ||
| DEVICE_CLASS_DOOR, | ||
| DEVICE_CLASS_GAS, | ||
| DEVICE_CLASS_SMOKE, | ||
| BinarySensorDevice, | ||
| ) | ||
|
|
||
| from . import DOMAIN as TOTALCONNECT_DOMAIN | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def setup_platform(hass, config, add_entities, discovery_info=None): | ||
| """Set up a sensor for a TotalConnect device.""" | ||
| if discovery_info is None: | ||
| return | ||
|
|
||
| sensors = [] | ||
|
|
||
| client_locations = hass.data[TOTALCONNECT_DOMAIN].client.locations | ||
|
|
||
| for location_id, location in client_locations.items(): | ||
| for zone_id, zone in location.zones.items(): | ||
| sensors.append(TotalConnectBinarySensor(zone_id, location_id, zone)) | ||
| add_entities(sensors, True) | ||
|
|
||
|
|
||
| class TotalConnectBinarySensor(BinarySensorDevice): | ||
| """Represent an TotalConnect zone.""" | ||
|
|
||
| def __init__(self, zone_id, location_id, zone): | ||
| """Initialize the TotalConnect status.""" | ||
| self._zone_id = zone_id | ||
| self._location_id = location_id | ||
| self._zone = zone | ||
| self._name = self._zone.description | ||
|
austinmroczek marked this conversation as resolved.
|
||
| self._unique_id = f"{location_id} {zone_id}" | ||
| self._is_on = None | ||
| self._is_tampered = None | ||
| self._is_low_battery = None | ||
|
|
||
| @property | ||
| def unique_id(self): | ||
| """Return the unique id.""" | ||
| return self._unique_id | ||
|
|
||
| @property | ||
| def name(self): | ||
| """Return the name of the device.""" | ||
| return self._name | ||
|
|
||
| def update(self): | ||
| """Return the state of the device.""" | ||
| self._is_tampered = self._zone.is_tampered() | ||
| self._is_low_battery = self._zone.is_low_battery() | ||
|
|
||
| if self._zone.is_faulted() or self._zone.is_triggered(): | ||
| self._is_on = True | ||
| else: | ||
| self._is_on = False | ||
|
|
||
| @property | ||
| def is_on(self): | ||
| """Return true if the binary sensor is on.""" | ||
| return self._is_on | ||
|
|
||
| @property | ||
| def device_class(self): | ||
| """Return the class of this device, from component DEVICE_CLASSES.""" | ||
| if self._zone.is_type_security(): | ||
|
austinmroczek marked this conversation as resolved.
|
||
| return DEVICE_CLASS_DOOR | ||
| if self._zone.is_type_fire(): | ||
| return DEVICE_CLASS_SMOKE | ||
| if self._zone.is_type_carbon_monoxide(): | ||
| return DEVICE_CLASS_GAS | ||
| return None | ||
|
springstan marked this conversation as resolved.
|
||
|
|
||
| @property | ||
| def device_state_attributes(self): | ||
| """Return the state attributes.""" | ||
| attributes = { | ||
| "zone_id": self._zone_id, | ||
| "location_id": self._location_id, | ||
| "low_battery": self._is_low_battery, | ||
| "tampered": self._is_tampered, | ||
| } | ||
| return attributes | ||
This file contains hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.