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

GitHub Sensor #19561

Merged
merged 48 commits into from Feb 7, 2019

Conversation

Projects
None yet
8 participants
@timmo001
Copy link
Contributor

timmo001 commented Dec 24, 2018

Description:

Adds a GitHub sensor with a bunch of data with help from the PyGithub library. Sensors are added from a list of repository paths and optional names.

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

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: github
    access_token: !secret github_access_token
    repositories:
      - path: 'timmo001/home-panel'
        name: 'Home Panel'
      - path: 'timmo001/home-panel-api'
        name: 'Home Panel API'
      - path: 'hassio-addons/addon-matrix'
        name: 'Matrix Add-on'
      - path: 'home-assistant/home-assistant'
      - path: 'home-assistant/home-assistant.io'

Example Data Screenshot

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 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.

@timmo001 timmo001 referenced this pull request Dec 24, 2018

Merged

GitHub Sensor #7942

2 of 2 tasks complete

@timmo001 timmo001 changed the title WIP: GitHub Sensor GitHub Sensor Dec 24, 2018

@ludeeus
Copy link
Member

ludeeus left a comment

For optional config options use config.get(key) this will return None if the key does not exist.

Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
@timstanley1985

This comment has been minimized.

Copy link
Contributor

timstanley1985 commented Dec 25, 2018

Would it be possible to add an attribute for that showed the version number for the most recent release? This could then be used to fire an automation whenever a new release was posted on a particular GitHub repository. That would be really handy for tracking new versions of GitHub hosted software

@timmo001

This comment has been minimized.

Copy link
Contributor Author

timmo001 commented Dec 25, 2018

Would it be possible to add an attribute for that showed the version number for the most recent release? This could then be used to fire an automation whenever a new release was posted on a particular GitHub repository. That would be really handy for tracking new versions of GitHub hosted software

Good idea! I'll take a look at implementing this after the festivities 🎅 👍

@timmo001 timmo001 changed the title GitHub Sensor WIP:GitHub Sensor Dec 26, 2018

@timmo001 timmo001 changed the title WIP:GitHub Sensor WIP: GitHub Sensor Dec 26, 2018

@timmo001 timmo001 changed the title WIP: GitHub Sensor GitHub Sensor Dec 27, 2018

@timmo001

This comment has been minimized.

Copy link
Contributor Author

timmo001 commented Dec 27, 2018

Added latest release as JSON object:
screenshot

@timstanley1985

This comment has been minimized.

Copy link
Contributor

timstanley1985 commented Dec 27, 2018

👍👍👍👍 thanks. This is great but seems like a lot of information to be held in an attribute. I think only the version number and maybe the date is relevant

@timmo001 timmo001 changed the title GitHub Sensor WIP: GitHub Sensor Jan 3, 2019

@timmo001 timmo001 changed the title WIP: GitHub Sensor GitHub Sensor Jan 3, 2019

@timmo001

This comment has been minimized.

Copy link
Contributor Author

timmo001 commented Jan 8, 2019

What is the status on this PR? Any other changes required @ludeeus?

@ludeeus
Copy link
Member

ludeeus left a comment

This generally looks good, added a few notes for you to look over :)

Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated

@timmo001 timmo001 changed the title GitHub Sensor WIP: GitHub Sensor Jan 29, 2019

@timmo001 timmo001 changed the title WIP: GitHub Sensor GitHub Sensor Jan 29, 2019

@timmo001

This comment has been minimized.

Copy link
Contributor Author

timmo001 commented Jan 29, 2019

OK, let me know if I got everything. 👍

I've given the validation a few tests and the platform setup now fails with bad credentials or if any other error pops up during setup.

Updated docs also 📚

@amelchio
Copy link
Member

amelchio left a comment

This generally looks good but it stores so much information, I worry that things are going to break down over time.

Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated

timmo001 added some commits Feb 1, 2019

@timmo001 timmo001 force-pushed the timmo001:github-sensor branch from 0bbf4f0 to 2b8b800 Feb 1, 2019

@timmo001 timmo001 changed the title GitHub Sensor WIP: GitHub Sensor Feb 1, 2019

@timmo001 timmo001 changed the title WIP: GitHub Sensor GitHub Sensor Feb 1, 2019

@amelchio
Copy link
Member

amelchio left a comment

I like this a lot more 👍. Still a few comments though :)

Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated

timmo001 added some commits Feb 3, 2019

@amelchio
Copy link
Member

amelchio left a comment

I think this looks good now 👍

Just a couple of comments that you can consider but I'm willing to merge as-is. Just let me know when you are done :)

timmo001 added some commits Feb 6, 2019

Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
Show resolved Hide resolved homeassistant/components/sensor/github.py Outdated
@timmo001

This comment has been minimized.

Copy link
Contributor Author

timmo001 commented Feb 7, 2019

I'm happy to merge now @amelchio 👍 😃

@amelchio
Copy link
Member

amelchio left a comment

Excellent work. Let's do this!

@amelchio amelchio merged commit 968f987 into home-assistant:dev Feb 7, 2019

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 increased (+0.3%) to 93.353%
Details

@wafflebot wafflebot bot removed the in progress label Feb 7, 2019

bachya added a commit to bachya/home-assistant that referenced this pull request Feb 7, 2019

GitHub Sensor (home-assistant#19561)
*  Add GitHub sensor

* 👕 fix tox lint warning

* 🔨 Add GitHub to .coveragerc

* 👕 Fix pylint warning

* 🔨 Use config.get

* 🔥 Tighten validation

* 👕 fix linter error

* 🔨 Add path for context in errors

*  Add releases

*  Add GitHub Enterprise server support

* 🔨 remove unused constant

* 🔨 Requested changes

* 🔨 Reorder imports

* 🔨 Change to CONF_URL

* 🔨 Add docstring

* 🔨 Add validation for repo list

* ⬆️ Update PyGithub to 1.43.5

* 🔨 Sort attributes

* 🔥 Fix validation

* 👕 Fix linting issue

* 🔨 Fail platform setup when data init fails with bad credentials etc

* 👕 Fix whitespace lint error

* 🔨 Fix requirements_all version

* 👕 Linter fix attempt

* 🔥 Missing bracket

* 🔥 Another attempt to at a linter fix

* 🔥 Fix indentation

* 🔨 Reduce exception down to main one

* 🔥 Remove update throttle logic

* 🔨 Reduce calls

* 👕 Remove unused imports

* 🔥 🔨 Reduce attribute data

* 👕 Remove unused json import

* 🔨 Remove username and password

* 🔥 Fix counts

* 🔨 Update attrs and add any missing

* 🔨 Add unique_id

* 🔥 Convert uuid to string

* 🔥 Replace UUID with repository path

* 🔨 Cleanup

* 🔨 Cleanup

* 🔥 Remove unused variable

* 🔨 Change to update instead of _update

* 🔨 Improved consistency

* 🔨 Improve consistency

* 👕 Fix line lengths

* 🔨 Fix length

* 🔨 Fix syntax

@timmo001 timmo001 deleted the timmo001:github-sensor branch Feb 7, 2019

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