Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
54dbdd6
Merge pull request #1 from home-assistant/dev
austinmroczek Apr 14, 2019
90483d2
Merge branch 'dev' of https://github.com/home-assistant/home-assistan…
austinmroczek Apr 18, 2019
51aa773
Bump skybellpy to 0.4.0
austinmroczek Apr 18, 2019
e18b4d2
Bump skybellpy to 0.4.0 in requirements_all.txt
austinmroczek Apr 22, 2019
d74156a
Added extra states for STATE_ALARM_TRIGGERED to allow users to know if
austinmroczek Apr 26, 2019
ad1cdb3
Merge branch 'dev' of https://github.com/austinmroczek/home-assistant…
austinmroczek Apr 26, 2019
5c5c052
Merge pull request #2 from home-assistant/dev
austinmroczek Apr 26, 2019
abcc85a
Fix const import
austinmroczek Apr 28, 2019
d303091
Fix const import
austinmroczek Apr 28, 2019
73f38eb
Fix const imports
austinmroczek Apr 28, 2019
5bec7e4
Bump total-connect-client to 0.26.
austinmroczek May 5, 2019
4862ff5
Catch details of alarm trigger in state attributes.
austinmroczek May 25, 2019
5068345
Merge branch 'dev' of
austinmroczek May 25, 2019
e7a13d4
Change state_attributes() to device_state_attributes()
austinmroczek May 30, 2019
53f20fb
Merge remote-tracking branch 'upstream/dev' into dev
austinmroczek Jun 7, 2019
4bee662
Merge branch 'dev' of https://github.com/austinmroczek/home-assistant…
austinmroczek Jun 7, 2019
6a50e80
Move totalconnect component toward being a multi-platform integration…
austinmroczek Jun 8, 2019
37c34cf
Merge pull request #4 from home-assistant/dev
austinmroczek Jun 29, 2019
ad4c4c9
add missing total-connect alarm state mappings
austinmroczek Jun 29, 2019
e589317
Made recommended changes of MartinHjelmare at
austinmroczek Jun 30, 2019
aa22440
Update __init__.py
austinmroczek Jul 2, 2019
5cbfc98
Updates per MartinHjelmare comments
austinmroczek Jul 13, 2019
eb440cc
flake8/pydocstyle fixes
austinmroczek Jul 13, 2019
69425d7
Merge branch 'dev' of https://github.com/austinmroczek/home-assistant…
austinmroczek Jul 13, 2019
117ed1b
removed . at end of log message
austinmroczek Jul 13, 2019
14d3e2e
added blank line between logging and voluptuous
austinmroczek Jul 13, 2019
cd2b563
more fixes
austinmroczek Jul 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ omit =
homeassistant/components/tomato/device_tracker.py
homeassistant/components/toon/*
homeassistant/components/torque/sensor.py
homeassistant/components/totalconnect/alarm_control_panel.py
homeassistant/components/totalconnect/*
homeassistant/components/touchline/climate.py
homeassistant/components/tplink/device_tracker.py
homeassistant/components/tplink/light.py
Expand Down
53 changes: 53 additions & 0 deletions homeassistant/components/totalconnect/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
"""The totalconnect component."""
import logging

import voluptuous as vol
Comment thread
austinmroczek marked this conversation as resolved.
from total_connect_client import TotalConnectClient

import homeassistant.helpers.config_validation as cv
from homeassistant.helpers import discovery
from homeassistant.const import (CONF_PASSWORD, CONF_USERNAME)


_LOGGER = logging.getLogger(__name__)

DOMAIN = 'totalconnect'

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
}),
}, extra=vol.ALLOW_EXTRA)

TOTALCONNECT_PLATFORMS = ['alarm_control_panel']


def setup(hass, config):
"""Set up TotalConnect component."""
conf = config[DOMAIN]

username = conf[CONF_USERNAME]
password = conf[CONF_PASSWORD]

client = TotalConnectClient.TotalConnectClient(username, password)

if client.token is False:
_LOGGER.error("TotalConnect authentication failed")
return False
Comment thread
austinmroczek marked this conversation as resolved.

hass.data[DOMAIN] = TotalConnectSystem(username, password, client)

for platform in TOTALCONNECT_PLATFORMS:
discovery.load_platform(hass, platform, DOMAIN, {}, config)

return True


class TotalConnectSystem:
"""TotalConnect System class."""

def __init__(self, username, password, client):
"""Initialize the TotalConnect system."""
self._username = username
self._password = password
self.client = client
85 changes: 47 additions & 38 deletions homeassistant/components/totalconnect/alarm_control_panel.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,43 @@
"""Interfaces with TotalConnect alarm control panels."""
import logging

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_PASSWORD, CONF_USERNAME, STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, STATE_ALARM_DISARMED,
STATE_ALARM_ARMING, STATE_ALARM_DISARMING, STATE_ALARM_TRIGGERED,
CONF_NAME, STATE_ALARM_ARMED_CUSTOM_BYPASS)
STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT,
STATE_ALARM_DISARMED, STATE_ALARM_ARMING, STATE_ALARM_DISARMING,
STATE_ALARM_TRIGGERED, STATE_ALARM_ARMED_CUSTOM_BYPASS)

from . import DOMAIN as TOTALCONNECT_DOMAIN

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = 'Total Connect'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_PASSWORD): cv.string,
vol.Required(CONF_USERNAME): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
})
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up an alarm control panel for a TotalConnect device."""
if discovery_info is None:
return

alarms = []
Comment thread
austinmroczek marked this conversation as resolved.

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up a TotalConnect control panel."""
name = config.get(CONF_NAME)
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
client = hass.data[TOTALCONNECT_DOMAIN].client

total_connect = TotalConnect(name, username, password)
add_entities([total_connect], True)
for location in client.locations:
location_id = location.get('LocationID')
name = location.get('LocationName')
alarms.append(TotalConnectAlarm(name, location_id, client))
add_entities(alarms)


class TotalConnect(alarm.AlarmControlPanel):
class TotalConnectAlarm(alarm.AlarmControlPanel):
"""Represent an TotalConnect status."""

def __init__(self, name, username, password):
def __init__(self, name, location_id, client):
"""Initialize the TotalConnect status."""
from total_connect_client import TotalConnectClient

_LOGGER.debug("Setting up TotalConnect...")
self._name = name
self._username = username
self._password = password
self._location_id = location_id
self._client = client
self._state = None
self._device_state_attributes = {}
self._client = TotalConnectClient.TotalConnectClient(
username, password)

@property
def name(self):
Expand All @@ -66,17 +56,36 @@ def device_state_attributes(self):

def update(self):
"""Return the state of the device."""
status = self._client.get_armed_status()
attr = {'triggered_source': None, 'triggered_zone': None}
status = self._client.get_armed_status(self._name)
attr = {
'location_name': self._name,
'location_id': self._location_id,
'ac_loss': self._client.ac_loss,
'low_battery': self._client.low_battery,
'triggered_source': None,
'triggered_zone': None
}

if status == self._client.DISARMED:
state = STATE_ALARM_DISARMED
elif status == self._client.DISARMED_BYPASS:
state = STATE_ALARM_DISARMED
elif status == self._client.ARMED_STAY:
state = STATE_ALARM_ARMED_HOME
elif status == self._client.ARMED_AWAY:
state = STATE_ALARM_ARMED_AWAY
elif status == self._client.ARMED_STAY_INSTANT:
state = STATE_ALARM_ARMED_HOME
elif status == self._client.ARMED_STAY_INSTANT_BYPASS:
state = STATE_ALARM_ARMED_HOME
elif status == self._client.ARMED_STAY_NIGHT:
state = STATE_ALARM_ARMED_NIGHT
elif status == self._client.ARMED_AWAY:
state = STATE_ALARM_ARMED_AWAY
elif status == self._client.ARMED_AWAY_BYPASS:
state = STATE_ALARM_ARMED_AWAY
elif status == self._client.ARMED_AWAY_INSTANT:
state = STATE_ALARM_ARMED_AWAY
elif status == self._client.ARMED_AWAY_INSTANT_BYPASS:
state = STATE_ALARM_ARMED_AWAY
elif status == self._client.ARMED_CUSTOM_BYPASS:
state = STATE_ALARM_ARMED_CUSTOM_BYPASS
elif status == self._client.ARMING:
Expand All @@ -102,16 +111,16 @@ def update(self):

def alarm_disarm(self, code=None):
"""Send disarm command."""
self._client.disarm()
self._client.disarm(self._name)

def alarm_arm_home(self, code=None):
"""Send arm home command."""
self._client.arm_stay()
self._client.arm_stay(self._name)

def alarm_arm_away(self, code=None):
"""Send arm away command."""
self._client.arm_away()
self._client.arm_away(self._name)

def alarm_arm_night(self, code=None):
"""Send arm night command."""
self._client.arm_stay_night()
self._client.arm_stay_night(self._name)
2 changes: 1 addition & 1 deletion homeassistant/components/totalconnect/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Totalconnect",
"documentation": "https://www.home-assistant.io/components/totalconnect",
"requirements": [
"total_connect_client==0.27"
"total_connect_client==0.28"
],
"dependencies": [],
"codeowners": []
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ todoist-python==7.0.17
toonapilib==3.2.4

# homeassistant.components.totalconnect
total_connect_client==0.27
total_connect_client==0.28

# homeassistant.components.tplink_lte
tp-connected==0.0.4
Expand Down