Skip to content
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

Support multiple Elk instances #22573

Closed
wants to merge 868 commits into from
Closed

Support multiple Elk instances #22573

wants to merge 868 commits into from

Conversation

gjbadros
Copy link
Contributor

@gjbadros gjbadros commented Mar 30, 2019

  • Allow more than one Elk M1 alarm system to be integrated into a single hass instance.

  • Introduces new "devices" schema at the top level, each of which has
    the prior configuration schema.

  • Requires new version of elkm1, 0.7.14, that gwww and I just updated (thanks Glen!)

  • Changes to the docs are in a separate PR on that repo.

Breaking Change:

Description:

Related issue (if applicable): fixes #

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#9078

Example entry for configuration.yaml (if applicable):

elkm1:
     - host: elk://192.168.0.2:2101/
     ....
     - host: elk://192.168.0.3:2101/

Checklist:

  • The code change is tested and works locally.
  • [] Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Contributor

Hi @gjbadros,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

elk_datas = hass.data[ELK_DOMAIN]
for prefix, elk_data in elk_datas.items():
elk = elk_data['elk']
entities = create_elk_entities(elk_data, elk.outputs, 'output', ElkOutput, [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (86 > 79 characters)

@@ -1,26 +1,29 @@
"""Support for control of ElkM1 sensors."""
import logging

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'logging' imported but unused

elk_datas = hass.data[ELK_DOMAIN]
for prefix, elk_data in elk_datas.items():
elk = elk_data['elk']
entities = create_elk_entities(elk_data, elk.tasks, 'task', ElkTask, [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (80 > 79 characters)

for prefix, elk_data in elk_datas.items():
elk = elk_data['elk']
async_add_entities(
create_elk_entities(elk_data, elk.lights, 'plc', ElkLight, []), True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

elk_datas = hass.data[ELK_DOMAIN]
for prefix, elk_data in elk_datas.items():
elk = elk_data['elk']
entities = create_elk_entities(elk_data, elk.areas, 'area', ElkArea, [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (80 > 79 characters)

device = devices.get(prefix, None)
if device != None:
if prefix != "":
_LOGGER.error("Need to use a prefix configuration command on second and later elk m1s")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (103 > 79 characters)


prefix = conf.get(CONF_PREFIX,"")
device = devices.get(prefix, None)
if device != None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comparison to None should be 'if cond is not None:'

_LOGGER.error("Config item: %s; %s", item, err)
return False

prefix = conf.get(CONF_PREFIX,"")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace after ','

'included': [not conf[item]['include']] * max_}
try:
_included(conf[item]['include'], True, config[item]['included'])
_included(conf[item]['exclude'], False, config[item]['included'])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (81 > 79 characters)

config[item] = {'enabled': conf[item][CONF_ENABLED],
'included': [not conf[item]['include']] * max_}
try:
_included(conf[item]['include'], True, config[item]['included'])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (80 > 79 characters)

_LOGGER.error("Need to use a prefix configuration command " +
"on second and later elk m1s")
else:
_LOGGER.error("Duplicate prefix on elk prefix: %s", m1s)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'm1s'

@gjbadros
Copy link
Contributor Author

gjbadros commented Apr 1, 2019 via email

@gjbadros
Copy link
Contributor Author

gjbadros commented Apr 1, 2019 via email

@rohankapoorcom
Copy link
Member

I just read through the documentation again for ZM and it's definitely not obvious that multiple hosts can be supported. I originally got this approach from @MartinHjelmare (to avoid the breaking change when adding multiple host support). He may have some suggestions on how to best document this.

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Apr 2, 2019

Please ask the question about the docs in the docs PR. The docs team will probably have a suggestion. So far we've just relied on the example I think.

@gjbadros
Copy link
Contributor Author

gjbadros commented Apr 3, 2019 via email

@gjbadros
Copy link
Contributor Author

gjbadros commented Apr 5, 2019 via email

homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
elk = elkm1.Elk({'url': conf[CONF_HOST], 'userid':
conf[CONF_USERNAME],
'password': conf[CONF_PASSWORD]})
elk.connect()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the connect fail if credentials are incorrect? Do we need to catch that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled by the library.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fail set up if credentials are incorrect. Or at least if all devices have incorrect credentials.

homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/alarm_control_panel.py Outdated Show resolved Hide resolved
@MartinHjelmare
Copy link
Member

Please update the PR description after the change in direction regarding the config schema.

@gjbadros
Copy link
Contributor Author

gjbadros commented Apr 5, 2019 via email

homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/__init__.py Show resolved Hide resolved
homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/climate.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/light.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/scene.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/elkm1/switch.py Outdated Show resolved Hide resolved
awarecan and others added 7 commits April 26, 2019 19:55
…tant#23408)

* Allow host/ipv6 address for broadlink service

This matches switch config and is a regression fix

* Restore padding of packets for broadlink

* Drop unused import

* Fix comment on test
* Make setup more robust

* Fix typing
…ome-assistant#23419)

* Correct media player feature gates

* Fix failing test

* Lint...
* Refactor NETATMO_AUTH to use hass.data

* Minor cleanup

* Rename conf to auth and other suggestions by Martin

* Revert webhook name change

* Rename constant

* Move auth

* Don't use hass.data.get()

* Fix auth string
* Fix Flux component

* Update manifest.json

* Update manifest.json
@bachya
Copy link
Contributor

bachya commented May 13, 2019

This PR is borked. You can try to rebase it and remove commits that aren't applicable, or you may need to start a new one.

@gjbadros
Copy link
Contributor Author

Updating to the latest in the dev branch and rebasing this doesn't seem to have gotten me to a reasonable pull request, so I'll abandon this one and start a new PR after I've tested the changes against the latest (I was away from this for 5 weeks.)

@gjbadros gjbadros closed this May 13, 2019
@gjbadros
Copy link
Contributor Author

gjbadros commented May 13, 2019 via email

@gjbadros gjbadros mentioned this pull request May 16, 2019
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet