-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6566e0c
Showing
18 changed files
with
10,019 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
extends: airbnb-base | ||
rules: | ||
no-else-return: 0 | ||
no-underscore-dangle: 0 | ||
nonblock-statement-body-position: 0 | ||
curly: 0 | ||
no-return-assign: 0 | ||
consistent-return: 0 | ||
no-mixed-operators: 0 | ||
class-methods-use-this: 0 | ||
no-nested-ternary: 0 | ||
camelcase: 0 | ||
no-console: 0 | ||
globals: | ||
window: true | ||
document: true | ||
customElements: true | ||
getComputedStyle: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules/ | ||
package-lock.json |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Leonardo Merza | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Tracking Number Card for Home Assistant | ||
|
||
|
||
![](./Capture.PNG) | ||
|
||
--- | ||
|
||
[![GitHub Release][releases-shield]][releases] | ||
[![License][license-shield]](LICENSE.md) | ||
|
||
![Project Maintenance][maintenance-shield] | ||
[![GitHub Activity][commits-shield]][commits] | ||
|
||
|
||
## Track Updates | ||
|
||
This custom card can be tracked with the help of [custom-updater](https://github.com/custom-components/custom_updater). | ||
|
||
In your configuration.yaml | ||
|
||
```yaml | ||
custom_updater: | ||
card_urls: | ||
- https://raw.githubusercontent.com/ljmerza/tracking-number-card/master/custom_updater.json | ||
``` | ||
## Usage | ||
You will need the [Email Sensor](https://github.com/ljmerza/ha-email-sensor) installed. | ||
## Options | ||
| Name | Type | Requirement | Description | ||
| ---- | ---- | ------- | ----------- | ||
| type | string | **Required** | `custom:tracking-number-card` | ||
| header | string | **Optional** | `Tracking Numbers` Header of card | ||
| showHeader | boolean | **Optional** | `true` Hide header | ||
|
||
## Configuration | ||
Download `tracking-number-card.js` from the [latest release](https://github.com/ljmerza/tracking-number-card/releases/latest) and upload it your /www folder of your Home Assistant config directory. | ||
|
||
In your ui-lovelace.yaml | ||
|
||
```yaml | ||
resources: | ||
- url: /local/tracking-number-card.js?track=true | ||
type: js | ||
``` | ||
|
||
Add the custom card to views: | ||
|
||
```yaml | ||
views: | ||
- type: custom:tracking-number-card | ||
entities: | ||
- sensor.email_ljmerzagmailcom | ||
``` | ||
|
||
--- | ||
|
||
Enjoy my card? Help me out for a couple of :beers: or a :coffee:! | ||
|
||
[![coffee](https://www.buymeacoffee.com/assets/img/custom_images/black_img.png)](https://www.buymeacoffee.com/JMISm06AD) | ||
|
||
|
||
[commits-shield]: https://img.shields.io/github/commit-activity/y/ljmerza/tracking-number-card.svg?style=for-the-badge | ||
[commits]: https://github.com/ljmerza/tracking-number-card/commits/master | ||
[license-shield]: https://img.shields.io/github/license/ljmerza/tracking-number-card.svg?style=for-the-badge | ||
[maintenance-shield]: https://img.shields.io/badge/maintainer-Leonardo%20Merza%20%40ljmerza-blue.svg?style=for-the-badge | ||
[releases-shield]: https://img.shields.io/github/release/ljmerza/tracking-number-card.svg?style=for-the-badge | ||
[releases]: https://github.com/ljmerza/tracking-number-card/releases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"useBuiltIns": "usage", | ||
"debug": true, | ||
"targets": "> 0.25%, not dead", | ||
"shippedProposals": true | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"tracking-number-card": { | ||
"updated_at": "2019-04-25", | ||
"version": "1.0.0", | ||
"remote_location": "https://raw.githubusercontent.com/ljmerza/tracking-number-card/master/tracking-number-card.js", | ||
"visit_repo": "https://github.com/ljmerza/tracking-number-card", | ||
"changelog": "https://github.com/ljmerza/tracking-number-card/releases/latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "tracking-number-card", | ||
"version": "1.0.0", | ||
"description": "A tracking number card for Home Assistant Lovelace UI", | ||
"keywords": [ | ||
"home-assistant", | ||
"homeassistant", | ||
"hass", | ||
"automation", | ||
"lovelace", | ||
"custom-cards", | ||
"tracking numbers" | ||
], | ||
"repository": "[email protected]:ljmerza/tracking-number-card.git", | ||
"author": "Leonardo Merza <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@babel/polyfill": "^7.4.3", | ||
"core-js": "^2.6.5", | ||
"lit-element": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.4.3", | ||
"@babel/core": "^7.4.3", | ||
"@babel/preset-env": "^7.4.3", | ||
"@babel/register": "^7.4.0", | ||
"babel-loader": "^8.0.5", | ||
"eslint": "^5.16.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.17.1", | ||
"webpack": "^4.30.0", | ||
"webpack-cli": "^3.3.0", | ||
"webpack-merge": "^4.2.1" | ||
}, | ||
"scripts": { | ||
"lint": "eslint ./src", | ||
"start": "webpack --watch --config webpack/config.dev.js", | ||
"build": "webpack --config webpack/config.prod.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
|
||
export default { | ||
header: 'Tracking Numbers', | ||
showHeader: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { LitElement, html } from 'lit-element'; | ||
import style from './style-editor'; | ||
import defaultConfig from './defaults'; | ||
|
||
|
||
const fireEvent = (node, type, detail = {}, options = {}) => { | ||
const event = new Event(type, { | ||
bubbles: options.bubbles === undefined ? true : options.bubbles, | ||
cancelable: Boolean(options.cancelable), | ||
composed: options.composed === undefined ? true : options.composed, | ||
}); | ||
|
||
event.detail = detail; | ||
node.dispatchEvent(event); | ||
return event; | ||
}; | ||
|
||
|
||
export default class TrackingNumberCardEditor extends LitElement { | ||
static get styles() { | ||
return style; | ||
} | ||
|
||
static get properties() { | ||
return { hass: {}, _config: {} }; | ||
} | ||
|
||
setConfig(config) { | ||
this._config = Object.assign({}, defaultConfig, config); | ||
} | ||
|
||
get entityOptions() { | ||
const entities = Object.keys(this.hass.states).filter(eid => /sensor\.email_/.test(eid)); | ||
return entities.map(eid => ({ name: eid, checked: this._config.entities.includes(eid) })); | ||
} | ||
|
||
firstUpdated() { | ||
this._firstRendered = true; | ||
} | ||
|
||
render() { | ||
if (!this.hass) { | ||
return html``; | ||
} | ||
|
||
return html` | ||
<div class="card-config"> | ||
<div class=overall-config'> | ||
<paper-input label="Header (Optional)" .value="${this._config.header}" .configValue="${"header"}" @value-changed="${this._valueChanged}"></paper-input> | ||
<div class='checkbox-options'> | ||
<paper-checkbox @checked-changed="${this._valueChanged}" .checked=${this._config.showHeader} .configValue="${"showHeader"}">Show Header</paper-checkbox> | ||
</div> | ||
</div> | ||
<div class='entities'> | ||
<h3>Entities</h3> | ||
${this.entityOptions.map(entity => { | ||
return html`<paper-checkbox @checked-changed="${this._valueChanged}" .checked=${entity.checked} .entityValue="${entity.name}">${entity.name}</paper-checkbox>`; | ||
})} | ||
</div> | ||
</div> | ||
`; | ||
} | ||
|
||
_valueChanged(ev) { | ||
if (!this._config || !this.hass || !this._firstRendered) return; | ||
|
||
const { target: { configValue, value, entityValue }, detail: { value: checkedValue } } = ev; | ||
|
||
if (entityValue) { | ||
|
||
if (checkedValue) { | ||
const entities = Array.from(this._config.entities) | ||
entities.push(entityValue) | ||
this._config = Object.assign({}, this._config, { entities: entities }); | ||
} else { | ||
const newEntities = this._config.entities.filter(entity => entity !== entityValue); | ||
this._config = Object.assign({}, this._config, { entities: newEntities }); | ||
} | ||
|
||
} else if (checkedValue !== undefined || checkedValue !== null) { | ||
this._config = Object.assign({}, this._config, { [configValue]: checkedValue }); | ||
|
||
} else { | ||
this._config = Object.assign({}, this._config, { [configValue]: value }); | ||
} | ||
|
||
fireEvent(this, 'config-changed', { config: this._config }); | ||
} | ||
} | ||
|
Oops, something went wrong.