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

OwnTracks Config Entry #18759

Merged
merged 11 commits into from Nov 28, 2018

Conversation

@balloob
Member

balloob commented Nov 28, 2018

Description:

This adds a config entry to OwnTracks. It will guide the user to set it up via Private HTTP mode powered by the webhook and it will also configure the encryption.

image

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 the code does not interact with devices:

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

@balloob balloob force-pushed the owntracks branch from 9f6b0b9 to 8458549 Nov 28, 2018


import os
import pytest

from homeassistant.components import device_tracker
from homeassistant.setup import async_setup_component

from tests.common import mock_component, mock_coro
from tests.common import mock_component, mock_coro, MockConfigEntry

This comment has been minimized.

@houndci-bot

houndci-bot Nov 28, 2018

'tests.common.mock_coro' imported but unused

@@ -1,14 +1,14 @@
"""Test the owntracks_http platform."""
import asyncio
from unittest.mock import patch
from unittest.mock import Mock

This comment has been minimized.

@houndci-bot

houndci-bot Nov 28, 2018

'unittest.mock.Mock' imported but unused

balloob added some commits Nov 28, 2018

@balloob balloob added this to the 0.83 milestone Nov 28, 2018

balloob added some commits Nov 28, 2018

@balloob balloob merged commit 48e2884 into dev Nov 28, 2018

3 of 5 checks passed

continuous-integration/travis-ci/push The Travis CI build failed
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA

@delete-merged-branch delete-merged-branch bot deleted the owntracks branch Nov 28, 2018

@wafflebot wafflebot bot removed the in progress label Nov 28, 2018

balloob added a commit that referenced this pull request Nov 28, 2018

OwnTracks Config Entry (#18759)
* OwnTracks Config Entry

* Fix test

* Fix headers

* Lint

* Username for android only

* Update translations

* Tweak translation

* Create config entry if not there

* Update reqs

* Types

* Lint

hass.data[DOMAIN]['context'] = context

async_when_setup(hass, 'mqtt', async_connect_mqtt)

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Nov 29, 2018

Member

Could we, instead of adding the callback, await the forward entry setup of the mqtt component, and if that returns true, subscribe to the mqtt owntracks topic?

This comment has been minimized.

@balloob

balloob Nov 29, 2018

Member

Well the problem is that MQTT might never be setup at all, so there might not be any entry setup.

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Nov 29, 2018

Member

That's true. So either we leave it up to the user to check that the integration is working, or maybe we could make a check in the config flow for mqtt availability with timeout and abort if timeout occurs.

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Nov 29, 2018

Member

I'm interested in this also since I will have to do something similar for mysensors.

This comment has been minimized.

@balloob

balloob Nov 29, 2018

Member

Well OwnTracks can be controlled via either a webhook and MQTT. So what happens here is that we configure the webhook always, and the MQTT when available.


async def async_see(self, **data):
"""Send a see message to the device tracker."""
await self.hass.components.device_tracker.async_see(**data)

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Nov 29, 2018

Member

This function doesn't seem to exist.

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Nov 29, 2018

Member

If we will overwrite this method, maybe we should raise NotImplementedError here?

This comment has been minimized.

@balloob

balloob Nov 29, 2018

Member

You're right, we should. That was part of a leftover initial implementation that I considered too hackish later.

This comment has been minimized.

@balloob

@balloob balloob referenced this pull request Nov 29, 2018

Merged

0.83 #18776

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment