├── example.png ├── hacs.json ├── tracker.json ├── LICENSE ├── github-entity-row.js └── README.md /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benct/lovelace-github-entity-row/HEAD/example.png -------------------------------------------------------------------------------- /hacs.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GitHub Entity Row", 3 | "filename": "github-entity-row.js", 4 | "render_readme": true 5 | } 6 | -------------------------------------------------------------------------------- /tracker.json: -------------------------------------------------------------------------------- 1 | { 2 | "github-entity-row": { 3 | "updated_at": "2022-02-15", 4 | "version": "2.1.0", 5 | "remote_location": "https://raw.githubusercontent.com/benct/lovelace-github-entity-row/master/github-entity-row.js", 6 | "visit_repo": "https://github.com/benct/lovelace-github-entity-row", 7 | "changelog": "https://github.com/benct/lovelace-github-entity-row" 8 | } 9 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Ben Tomlin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /github-entity-row.js: -------------------------------------------------------------------------------- 1 | import { html, LitElement } from 'https://unpkg.com/lit-element@2.0.1/lit-element.js?module'; 2 | 3 | class GithubEntityRow extends LitElement { 4 | 5 | static get properties() { 6 | return { 7 | _hass: {}, 8 | _config: {}, 9 | }; 10 | } 11 | 12 | render() { 13 | return html` 14 | 33 | 34 |
35 |
36 | 37 | ${this.stateObjIssues.state} 38 |
39 |
40 | 41 | ${this.stateObjPRs.state} 42 |
43 |
44 | 45 | ${this.stateObjStars.state} 46 |
47 |
48 |
49 | `; 50 | } 51 | 52 | issues(e) { this.goto(e, 'issues'); } 53 | pulls(e) { this.goto(e, 'pulls'); } 54 | stars(e) { this.goto(e, 'stargazers'); } 55 | 56 | goto(event, path) { 57 | event.stopPropagation(); 58 | window.open(`https://github.com/${this._config.repo}/${path}`); 59 | } 60 | 61 | setConfig(config) { 62 | if (!config.repo) throw new Error('Please define a GitHub repository path.'); 63 | 64 | const sensor = config.sensor || config.repo.replaceAll('-', '_').replaceAll('/', '_'); 65 | this._config = { 66 | ...config, 67 | name: config.name || config.repo, 68 | icon: config.icon || 'mdi:github', 69 | sensor: sensor, 70 | entity: `sensor.${sensor}_issues`, // required by ha-generic-entity-row 71 | }; 72 | } 73 | 74 | getStateObject(hass, sensor, suffix) { 75 | const entity = `sensor.${sensor}_${suffix}`; 76 | return entity in hass.states ? hass.states[entity] : null; 77 | } 78 | 79 | set hass(hass) { 80 | this._hass = hass; 81 | 82 | if (hass && this._config) { 83 | this.stateObjStars = this.getStateObject(hass, this._config.sensor, 'stars'); 84 | this.stateObjIssues = this.getStateObject(hass, this._config.sensor, 'issues'); 85 | this.stateObjPRs = this.getStateObject(hass, this._config.sensor, 'pull_requests'); 86 | } 87 | } 88 | } 89 | 90 | console.info( 91 | '%c GITHUB-ENTITY-ROW %c 2.1.0 ', 92 | 'color: cyan; background: black; font-weight: bold;', 93 | 'color: darkblue; background: white; font-weight: bold;' 94 | ); 95 | 96 | customElements.define('github-entity-row', GithubEntityRow); 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # github-entity-row 2 | 3 | Show GitHub repository sensor data on entity rows in Home Assistant's Lovelace UI 4 | 5 | [![GH-release](https://img.shields.io/github/v/release/benct/lovelace-github-entity-row.svg?style=flat-square)](https://github.com/benct/lovelace-github-entity-row/releases) 6 | [![GH-downloads](https://img.shields.io/github/downloads/benct/lovelace-github-entity-row/total?style=flat-square)](https://github.com/benct/lovelace-github-entity-row/releases) 7 | [![GH-last-commit](https://img.shields.io/github/last-commit/benct/lovelace-github-entity-row.svg?style=flat-square)](https://github.com/benct/lovelace-github-entity-row/commits/master) 8 | [![GH-code-size](https://img.shields.io/github/languages/code-size/benct/lovelace-github-entity-row.svg?color=red&style=flat-square)](https://github.com/benct/lovelace-github-entity-row) 9 | [![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=flat-square)](https://github.com/hacs) 10 | 11 | **NOTE:** This is not a standalone lovelace card, but a row element for 12 | the [entities](https://www.home-assistant.io/lovelace/entities/) card. 13 | 14 | ## Installation 15 | 16 | Add [github-entity-row.js](https://raw.githubusercontent.com/benct/lovelace-github-entity-row/master/github-entity-row.js) 17 | to your `/www/` folder and add the following to the `configuration.yaml` file: 18 | 19 | ```yaml 20 | lovelace: 21 | resources: 22 | - url: /local/github-entity-row.js?v=2.1.0 23 | type: module 24 | ``` 25 | 26 | _OR_ install using [HACS](https://hacs.xyz/) and add this (if in YAML mode): 27 | 28 | ```yaml 29 | lovelace: 30 | resources: 31 | - url: /hacsfiles/lovelace-github-entity-row/github-entity-row.js 32 | type: module 33 | ``` 34 | 35 | The above configuration can be managed in the Configuration -> Dashboards -> Resources panel when not using YAML mode. 36 | 37 | ## Configuration 38 | 39 | | Name | Type | Default | Description | 40 | |--------|--------|-----------------|-------------------------------------------| 41 | | type | string | **Required** | `custom:github-entity-row` | 42 | | repo | string | **Required** | Your GitHub repository path | 43 | | sensor | string | `_` | Specify a custom sensor entity (optional) | 44 | | name | string | `repo` | Override repository name | 45 | | icon | string | `mdi:github` | Override default entity icon | 46 | 47 | The `repo` field needs to exactly match your GitHub user and repository path, i.e. `benct/lovelace-github-entity-row`. 48 | 49 | If you rename the sensor entity IDs from the GitHub integration, you can specify the updated sensor ID with the `sensor` 50 | field (without the domain and type suffix). For example, if the integration 51 | exposes `sensor.custom_sensor_id_latest_release`, you should specify `custom_sensor_id`. 52 | 53 | ## Migrate to version 2 54 | 55 | The GitHub [integration](https://www.home-assistant.io/integrations/github/) was changed in HA version `2022.2.0` to 56 | include several sensors for each GitHub repository. If you are using the latest HA installation, you need to upgrade to 57 | version `>2.0.0` of this card. The main change is that the `entity` field has been replaced by ~~user 58 | and~~ `repo` (`user` removed in `2.1.0`). You might also need to manually enable the following sensors from your GitHub 59 | integration; `Stars`, `Issues` and `Pull Requests`. 60 | 61 | ## Example 62 | 63 | ![github-entity-row](https://raw.githubusercontent.com/benct/lovelace-github-entity-row/master/example.png) 64 | 65 | ```yaml 66 | type: entities 67 | title: GitHub 68 | entities: 69 | - type: custom:github-entity-row 70 | repo: benct/home-assistant-config 71 | name: HA Config 72 | - type: custom:github-entity-row 73 | repo: benct/lovelace-github-entity-row 74 | icon: mdi:github 75 | - type: custom:github-entity-row 76 | repo: benct/lovelace-multiple-entity-row 77 | - type: custom:github-entity-row 78 | repo: benct/lovelace-xiaomi-vacuum-card 79 | ``` 80 | 81 | ## My cards 82 | 83 | [xiaomi-vacuum-card](https://github.com/benct/lovelace-xiaomi-vacuum-card) | 84 | [multiple-entity-row](https://github.com/benct/lovelace-multiple-entity-row) | 85 | [github-entity-row](https://github.com/benct/lovelace-github-entity-row) | 86 | [battery-entity-row](https://github.com/benct/lovelace-battery-entity-row) | 87 | [~~attribute-entity-row~~](https://github.com/benct/lovelace-attribute-entity-row) 88 | 89 | [![BMC](https://www.buymeacoffee.com/assets/img/custom_images/white_img.png)](https://www.buymeacoff.ee/benct) 90 | --------------------------------------------------------------------------------