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 for Point component #17466

Merged
merged 7 commits into from Nov 19, 2018

Conversation

@fredrike
Contributor

fredrike commented Oct 15, 2018

Description:

Adds support for the minut.com Point sensor/alarm.

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

Example entry for configuration.yaml (if applicable): configuration.yaml

point:
    client_id: CLIENT_ID
    client_secret: CLIENT_SECRET  

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

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.

Todo:

  • Smoother authentication (does HA have a preferred way to handle components with OAuth2?).
  • Integrate the new webhooks (where is the documentation/example code for this?)
Show resolved Hide resolved homeassistant/components/sensor/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/binary_sensor/point.py Outdated
Show resolved Hide resolved homeassistant/components/binary_sensor/point.py Outdated
@Kane610

This comment has been minimized.

Contributor

Kane610 commented Oct 15, 2018

You should look at doing this integration through config entries.

Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/binary_sensor/point.py Outdated
Show resolved Hide resolved homeassistant/components/binary_sensor/point.py Outdated

@fredrike fredrike force-pushed the fredrike:point branch 2 times, most recently from 496e068 to 31238d2 Oct 15, 2018

@fredrike

This comment has been minimized.

Contributor

fredrike commented Oct 15, 2018

You should look at doing this integration through config entries.

@Kane610 Yes, I'm working on that.. I submitted this PR to get some suggestions on how to improve the integration.

I'll use this as inspiration of both the integration and the webhook part.

@fredrike fredrike force-pushed the fredrike:point branch from 31238d2 to 423e0f9 Oct 16, 2018

Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
@fredrike

This comment has been minimized.

Contributor

fredrike commented Oct 16, 2018

We are required to support for:

  • Handles internet unavailable. Log a warning once when unavailable, log once when reconnected.
  • Handles device/service unavailable. Log a warning once when unavailable, log once when reconnected.

for the Silver Quality Scale, what is the recommended way of doing so? Is this enough?

@Kane610

This comment has been minimized.

Contributor

Kane610 commented Oct 16, 2018

For logging? That should be enough. Maybe some kind of identifier if you can connect to multiple clients

Don't forget that you have to move your MinutPointClient to an external lib

Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
Show resolved Hide resolved homeassistant/components/point.py Outdated
@fredrike

This comment has been minimized.

Contributor

fredrike commented Oct 16, 2018

For logging? That should be enough. Maybe some kind of identifier if you can connect to multiple clients

Great!

What about SCAN_INTERVAL is there some example code I can look at on how it should be implemented or is this ok?
Or is it better to use track_time_interval(hass, self._sync, scan_interval)?

Don't forget that you have to move your MinutPointClient to an external lib

No I'm fully aware of that but have had so many changes that it's easier if everything is in the same place.

@fredrike fredrike force-pushed the fredrike:point branch from fdf5771 to a4119ea Oct 16, 2018

@Kane610

This comment has been minimized.

Contributor

Kane610 commented Oct 16, 2018

scan interval is used like this:

SCAN_INTERVAL = timedelta(seconds=15)

@fredrike

This comment has been minimized.

Contributor

fredrike commented Oct 16, 2018

scan interval is used like this:

home-assistant/homeassistant/components/switch/unifi.py

Line 24 in 6b3e4ca

SCAN_INTERVAL = timedelta(seconds=15)

And how is that used (I can't find a documentation for this)? Only the platform needs to update as that updates all sensors..

@Kane610

This comment has been minimized.

Contributor

Kane610 commented Oct 16, 2018

Sometimes you need to ask the code ;)

Somewhere in entity platform or something will use that parameter to set the update interval for that platform.

@Kane610

This comment has been minimized.

Contributor

Kane610 commented Oct 16, 2018

Was looking for something else and found it.

scan_interval=getattr(platform, 'SCAN_INTERVAL', None),

@fredrike fredrike requested a review from home-assistant/core as a code owner Oct 19, 2018

Show resolved Hide resolved homeassistant/components/point/point_api.py Outdated
Show resolved Hide resolved homeassistant/components/point/point_api.py Outdated
Show resolved Hide resolved homeassistant/components/point/point_api.py Outdated
Show resolved Hide resolved homeassistant/components/point/config_flow.py
Show resolved Hide resolved homeassistant/components/point/config_flow.py
Show resolved Hide resolved homeassistant/components/point/config_flow.py Outdated
Show resolved Hide resolved homeassistant/components/point/config_flow.py Outdated
Show resolved Hide resolved homeassistant/components/point/__init__.py Outdated
Show resolved Hide resolved homeassistant/components/point/__init__.py Outdated

@fredrike fredrike force-pushed the fredrike:point branch from 44825a7 to 8c61b86 Oct 19, 2018

@fredrike

This comment has been minimized.

Contributor

fredrike commented Oct 19, 2018

@Kane610, I have a working configuration flow with authentication against minut.com now! Just a few questions:

  • What do I need to do to get my devices (sensors) to show up under integrations?
  • Do I have to make all translations or will it fall back to components/point/strings.json?
  • I'm not super happy with the current authentication flow, I would like to redirect the user after entering API secrets and automatically show the success dialog when directed back. I.e., the second dialog below should be automatic.
  • I'm using http.register_view() as below, is there a way to de-register the view after the user is authenticated (I read the code but couldn't find anything).
    self.hass.http.register_view(MinutAuthCallbackView(self))

screenshot 2018-10-19 at 9 30 42

screenshot 2018-10-19 at 9 46 10

@frenck frenck added the docs-missing label Oct 21, 2018

@Kane610

This comment has been minimized.

Contributor

Kane610 commented Oct 24, 2018

  • You need to add
  • you need to do one translation, preferably English, but Blekingska is good as well ;)
  • You can redirect to different flows whenever you want, if I understood you correctly
  • I've never used register view so I can't help you there, but can't you just set the object to None?

@fredrike fredrike force-pushed the fredrike:point branch 2 times, most recently from 8ac0edf to d87d1d3 Nov 14, 2018

@fredrike fredrike force-pushed the fredrike:point branch from d87d1d3 to 09ef811 Nov 14, 2018

@home-assistant home-assistant deleted a comment from houndci-bot Nov 14, 2018

Show resolved Hide resolved homeassistant/components/point/__init__.py Outdated
Show resolved Hide resolved homeassistant/components/point/__init__.py Outdated
Show resolved Hide resolved homeassistant/components/point/__init__.py
Show resolved Hide resolved homeassistant/components/point/__init__.py Outdated
Show resolved Hide resolved homeassistant/components/point/__init__.py
Show resolved Hide resolved homeassistant/components/point/config_flow.py Outdated
Show resolved Hide resolved homeassistant/components/point/config_flow.py Outdated
Show resolved Hide resolved homeassistant/components/point/__init__.py Outdated
Show resolved Hide resolved homeassistant/components/point/config_flow.py Outdated
Show resolved Hide resolved homeassistant/components/point/config_flow.py Outdated

@fredrike fredrike force-pushed the fredrike:point branch from 2faf353 to 0885a35 Nov 14, 2018

@fredrike fredrike force-pushed the fredrike:point branch from 0885a35 to 3befa01 Nov 14, 2018

@fredrike

This comment has been minimized.

Contributor

fredrike commented Nov 15, 2018

@MartinHjelmare is my changes ok or are there more things that I need to fix?

What is the timeframe for 0.82.1?

@MartinHjelmare

This comment has been minimized.

Member

MartinHjelmare commented Nov 15, 2018

I think this looks good, but I'd like to read the tests before I approve.

This will not go out before 0.83 since it's a new feature.

@fredrike fredrike force-pushed the fredrike:point branch from 5cab532 to 68e54e7 Nov 16, 2018

Show resolved Hide resolved tests/components/point/test_config_flow.py Outdated
Show resolved Hide resolved tests/components/point/test_config_flow.py Outdated
Show resolved Hide resolved homeassistant/components/point/config_flow.py Outdated
Show resolved Hide resolved tests/components/point/test_config_flow.py Outdated
Show resolved Hide resolved tests/components/point/test_config_flow.py Outdated
Show resolved Hide resolved tests/components/point/test_config_flow.py Outdated
@MartinHjelmare

Looks good! @balloob?

@fredrike fredrike force-pushed the fredrike:point branch from 22ce2df to 6d6ffd8 Nov 16, 2018

@balloob

This comment has been minimized.

Member

balloob commented Nov 19, 2018

I trust Martin :)

Martin says it's ok

@balloob balloob merged commit c1ca7be into home-assistant:dev Nov 19, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.02%) to 93.04%
Details

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

@balloob

This comment has been minimized.

Member

balloob commented Nov 19, 2018

Beta hasn't been cut so it's part of 82.

@MartinHjelmare

This comment has been minimized.

Member

MartinHjelmare commented Nov 19, 2018

I think that was a typo: 0.82 -> 0.83

@fredrike

This comment has been minimized.

Contributor

fredrike commented Nov 19, 2018

@MartinHjelmare & @balloob, Thank you for your comments and improvements for enabling this. I really evaluate the code quality that you are striving for.

mxworm added a commit to mxworm/home-assistant that referenced this pull request Nov 19, 2018

Merge branch 'dev' of https://github.com/home-assistant/home-assistant
…into dev

* 'dev' of https://github.com/home-assistant/home-assistant:
  Bumped ghlocalapi to 0.1.0 (home-assistant#18584)
  Prefix all xiaomi_aqara events (home-assistant#17354)
  Fix MQTT async_added_to_hass (home-assistant#18575)
  Add mikrotik SSL support (home-assistant#17898)
  Reconfigure MQTT binary_sensor component if discovery info is changed (home-assistant#18169)
  Darksky: Expose missing conditions for day 0 forecast (home-assistant#18312)
  Update pyhomematic to 0.1.52 and add features for lights (home-assistant#18499)
  Fix for epson state not updating (home-assistant#18357)
  Support for Point component (home-assistant#17466)
  Template binary sensor to not track all state changes (home-assistant#18573)
  Correct cached stale device tracker handling (home-assistant#18572)
  Add support for sessions (home-assistant#18518)
  Remove turn_on and turn_off feature for clients (home-assistant#18234)
  Log delay and wait_template steps in scripts (home-assistant#18448)
  Logbook speedup (home-assistant#18376)
  Avoid race in entity_platform.async_add_entities() (home-assistant#18445)
  Fix small issue related to topic prefix (home-assistant#18512)
  Enable native support + ADB authentication for Fire TV (home-assistant#17767)
  Re-adding the season attribute (home-assistant#18523)

@balloob balloob referenced this pull request Nov 29, 2018

Merged

0.83 #18776

@fredrike fredrike referenced this pull request Dec 8, 2018

Open

TelldusLive config flow #18758

9 of 10 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment