core/homeassistant/components/totalconnect/__init__.py

83 lines
2.3 KiB
Python
Raw Normal View History

"""The totalconnect component."""
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
import asyncio
import logging
from total_connect_client import TotalConnectClient
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
2019-07-31 19:25:30 +00:00
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
import homeassistant.helpers.config_validation as cv
from .const import CONF_USERCODES, DOMAIN
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
_LOGGER = logging.getLogger(__name__)
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
PLATFORMS = ["alarm_control_panel", "binary_sensor"]
2019-07-31 19:25:30 +00:00
CONFIG_SCHEMA = vol.Schema(
vol.All(
cv.deprecated(DOMAIN),
{
DOMAIN: vol.Schema(
{
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
}
)
},
),
extra=vol.ALLOW_EXTRA,
2019-07-31 19:25:30 +00:00
)
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up upon config entry in user interface."""
conf = entry.data
username = conf[CONF_USERNAME]
password = conf[CONF_PASSWORD]
if CONF_USERCODES not in conf:
# should only happen for those who used UI before we added usercodes
raise ConfigEntryAuthFailed("No usercodes in TotalConnect configuration")
temp_codes = conf[CONF_USERCODES]
usercodes = {}
for code in temp_codes:
usercodes[int(code)] = temp_codes[code]
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
client = await hass.async_add_executor_job(
TotalConnectClient.TotalConnectClient, username, password, usercodes
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
)
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
if not client.is_valid_credentials():
raise ConfigEntryAuthFailed("TotalConnect authentication failed")
hass.data.setdefault(DOMAIN, {})
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
hass.data[DOMAIN][entry.entry_id] = client
for platform in PLATFORMS:
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform)
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
)
return True
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
async def async_unload_entry(hass, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, platform)
for platform in PLATFORMS
]
)
)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
Add Totalconnect config flow (#32126) * Bump skybellpy to 0.4.0 * Bump skybellpy to 0.4.0 in requirements_all.txt * Added extra states for STATE_ALARM_TRIGGERED to allow users to know if it is a burglar or fire or carbon monoxide so automations can take appropriate actions. Updated TotalConnect component to handle these new states. * Fix const import * Fix const import * Fix const imports * Bump total-connect-client to 0.26. * Catch details of alarm trigger in state attributes. Also bumps total_connect_client to 0.27. * Change state_attributes() to device_state_attributes() * Move totalconnect component toward being a multi-platform integration. Bump total_connect_client to 0.28. * add missing total-connect alarm state mappings * Made recommended changes of MartinHjelmare at https://github.com/home-assistant/home-assistant/pull/24427 * Update __init__.py * Updates per MartinHjelmare comments * flake8/pydocstyle fixes * removed . at end of log message * added blank line between logging and voluptuous * more fixes * Adding totalconnect zones as HA binary_sensors * fix manifest.json * flake8/pydocstyle fixes. Added codeowner. * Update formatting per @springstan guidance. * Fixed pylint * Add zone ID to log message for easier troubleshooting * Account for bypassed zones in update() * More status handling fixes. * Fixed flake8 error * Another attempt at black/isort fixes. * Bump total-connect-client to 0.50. Simplify code using new functions in total-connect-client package instead of importing constants. Run black and isort. * Fix manifest file * Another manifest fix * one more manifest fix * more manifest changes. * sync up * fix indent * one more pylint fix * Hopefully the last pylint fix * make variable names understandable * create and fill dict in one step * Fix name and attributes * rename to logical variable in alarm_control_panel * Remove location_name from alarm_control_panel attributes since it is already the name of the alarm. * Multiple fixes to improve code per @springstan suggestions * Update homeassistant/components/totalconnect/binary_sensor.py Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> * Multiple changes per @MartinHjelmare review * simplify alarm adding * Fix binary_sensor.py is_on * Move DOMAIN to .const in line with examples. * Move to async_setup * Simplify code using new features of total-connect-client 0.51 * First crack at config flow for totalconnect * bump totalconnect to 0.52 * use client.is_logged_in() to avoid total-connect-client details. * updated generated/config_flow.py * use is_logged_in() * Hopefully final touches for config flow * Add tests for config flow * Updated requirements for test * Fixes to test_config_flow * Removed leftover comments and code * fix const.py flake8 error * Simplify text per @Kane610 https://github.com/home-assistant/home-assistant/pull/32126#pullrequestreview-364652949 * Remove .get() to speed things up since the required items should always be available. * Move CONF_USERNAME and CONF_PASSWORD into .const to eliminate extra I/O to import from homeassistant.const * Fix I/O async issues * Fix flake8 and black errors * Mock the I/O in tests. * Fix isort error * Empty commit to re-start azure pipelines (per discord) * bump total-connect-client to 0.53 * Update homeassistant/components/totalconnect/__init__.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Update homeassistant/components/totalconnect/config_flow.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * Fixes per @balloob comments * Fix imports * fix isort error * Fix async_unload_entry It still referenced CONF_USERNAME instead of entry.entity_id * Added async_setup so not breaking change. Fixed imports. * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * Remove TotalConnectSystem() per @MartinHjelmare suggestion * Moved from is_logged_in() to is_valid_credentials() The second is more accurate for what we are checking for, because is_logged_in() could return False due to connection error. * Fix import in test * remove commented code and decorator * Update tests/components/totalconnect/test_config_flow.py Co-Authored-By: Martin Hjelmare <marhje52@gmail.com> * fix test_config_flow.py * bump total-connect-client to 0.54 * remove un-needed import of mock_coro * bump to total-connect-client 0.54.1 * re-add CONFIG_SCHEMA * disable pylint on line 10 to avoid pylint bug Co-authored-by: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-04-13 02:29:57 +00:00
return unload_ok