Change github sensor state to short commit sha (#31581)

* change state to latest_release_url

to have a meaningful frontend representation.
self._github_data.latest_commit_sha is still available in the attributes, so no info is lost

* template state to show only the tag

and not the full url to the tag

* add guard to update(self) for state

* add empty line 150

black...

* Update sensor.py

* add SHA if no release url

* Correct sha to 7 digits

* take out fallback on state
This commit is contained in:
Marius 2020-02-28 12:34:39 +01:00 committed by GitHub
parent adb3bb3653
commit 7714160f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,12 +132,12 @@ class GitHubSensor(Entity):
self._github_data.update()
self._name = self._github_data.name
self._state = self._github_data.latest_commit_sha
self._repository_path = self._github_data.repository_path
self._available = self._github_data.available
self._latest_commit_message = self._github_data.latest_commit_message
self._latest_commit_sha = self._github_data.latest_commit_sha
self._latest_release_url = self._github_data.latest_release_url
self._state = self._github_data.latest_commit_sha[0:8]
self._open_issue_count = self._github_data.open_issue_count
self._latest_open_issue_url = self._github_data.latest_open_issue_url
self._pull_request_count = self._github_data.pull_request_count