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
1 parent
b39ae80
commit f49bbfa
Showing
93 changed files
with
962 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,19 @@ | ||
syntax: glob | ||
tags | ||
tmp/* | ||
*.iml | ||
.idea | ||
*/.idea | ||
.DS_Store | ||
*/.DS_Store | ||
sftp-config.json | ||
*/sftp-config.json | ||
.realsync | ||
*.orig | ||
.*.sw? | ||
node_modules/* | ||
.ant-targets-build.xml | ||
/local.properties | ||
.ant_targets | ||
package-lock.json | ||
.sass-cache |
Large diffs are not rendered by default.
Oops, something went wrong.
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,26 @@ | ||
{ | ||
"name": "homeassistant-starline-card", | ||
"version": "1.0.0", | ||
"description": "Custom Lovelace Card for StarLine integration", | ||
"scripts": { | ||
"build": "node scripts/build.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Anonym-tsk/homeassistant-starline-card.git" | ||
}, | ||
"author": "@anonym.tsk", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/Anonym-tsk/homeassistant-starline-card/issues" | ||
}, | ||
"homepage": "https://github.com/Anonym-tsk/homeassistant-starline-card#readme", | ||
"devDependencies": { | ||
"css-b64-images": "^0.2.5", | ||
"fs-extra": "^8.1.0", | ||
"imagemin": "^7.0.0", | ||
"imagemin-pngquant": "^8.0.0", | ||
"node-sass": "^4.12.0", | ||
"replace-in-file": "^4.1.3" | ||
} | ||
} |
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,50 @@ | ||
const sass = require('node-sass'); | ||
const b64img = require('css-b64-images'); | ||
const imagemin = require('imagemin'); | ||
const imageminPngquant = require('imagemin-pngquant'); | ||
const replace = require('replace-in-file'); | ||
const fs = require('fs-extra'); | ||
|
||
fs.mkdirp('./tmp/assets'); | ||
fs.emptyDirSync('./tmp/assets'); | ||
|
||
(async () => { | ||
await imagemin(['./src/assets/*.png'], { | ||
destination: './tmp/assets', | ||
plugins: [ | ||
imageminPngquant({ | ||
quality: [0.6, 0.8] | ||
}) | ||
] | ||
}); | ||
|
||
var result = sass.renderSync({ | ||
file: './src/starline.sass', | ||
outputStyle: 'compact' | ||
}); | ||
|
||
b64img.fromString(result.css, './tmp/', null, {maxSize: 1024 * 32}, function(err, css) { | ||
if (err) { | ||
console.error('Error:', err); | ||
return; | ||
} | ||
|
||
fs.copySync('./src/starline-card.js', './tmp/starline-card.js'); | ||
|
||
replace.sync({ | ||
files: './tmp/starline-card.js', | ||
from: '{%css%}', | ||
to: css, | ||
}); | ||
|
||
fs.readFile('./src/starline.html', 'utf8', function(err, contents) { | ||
replace.sync({ | ||
files: './tmp/starline-card.js', | ||
from: '{%html%}', | ||
to: contents, | ||
}); | ||
|
||
fs.copySync('./tmp/starline-card.js', './dist/starline-card.js'); | ||
}); | ||
}); | ||
})(); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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,92 @@ | ||
class StarlineCard extends HTMLElement { | ||
constructor() { | ||
super(); | ||
|
||
this._config = {}; | ||
|
||
this.$wrapper = null; | ||
this.$container = null; | ||
|
||
this.$controls = null; | ||
this.$controlLeft = null; | ||
this.$controlCenter = null; | ||
this.$controlRight = null; | ||
|
||
this.$info = null; | ||
this.$infoBalance = null; | ||
this.$infoBattery = null; | ||
this.$infoInner = null; | ||
this.$infoEngine = null; | ||
} | ||
|
||
set hass(hass) { | ||
if (!this.$wrapper) { | ||
this._render(); | ||
} | ||
|
||
const entityId = this._config.entity; | ||
const state = hass.states[entityId]; | ||
console.warn(hass); | ||
const stateStr = state ? state.state : 'unavailable'; | ||
} | ||
|
||
_render() { | ||
const card = document.createElement('ha-card'); | ||
const style = document.createElement('style'); | ||
card.header = this._config.title || 'StarLine'; | ||
style.textContent = `{%css%}`; | ||
card.innerHTML = `{%html%}`; | ||
card.appendChild(style); | ||
this.appendChild(card); | ||
|
||
this.$wrapper = card.querySelector('.wrapper'); | ||
this.$container = card.querySelector('.container'); | ||
|
||
this.$controls = card.querySelector('.controls'); | ||
this.$controlLeft = this.$controls.querySelector('.control-left'); | ||
this.$controlCenter = this.$controls.querySelector('.control-center'); | ||
this.$controlRight = this.$controls.querySelector('.control-right'); | ||
|
||
this.$info = card.querySelector('.info'); | ||
this.$infoBalance = this.$info.querySelector('.info-balance'); | ||
this.$infoBattery = this.$info.querySelector('.info-battery'); | ||
this.$infoInner = this.$info.querySelector('.info-inner'); | ||
this.$infoEngine = this.$info.querySelector('.info-engine'); | ||
} | ||
|
||
setConfig(config) { | ||
const entity_types = { | ||
'battery': 'Battery', | ||
'balance': 'Balance', | ||
'ctemp': 'Interior Temperature', | ||
'etemp': 'Engine Temperature', | ||
'gsm_lvl': 'GSM Signal Level', | ||
'hbrake': 'Hand Brake', | ||
'hood': 'Hood', | ||
'trunk': 'Trunk', | ||
'alarm': 'Alarm Status', | ||
'door': 'Doors Status', | ||
'engine': 'Engine', | ||
'webasto': 'Heater', | ||
'out': 'Additional Channel', | ||
'security': 'Security', | ||
'location': 'Location' | ||
}; | ||
|
||
Object.keys(entity_types).forEach((key) => { | ||
if (!config[key]) { | ||
throw new Error('You need to define an entity: ' + entity_types[key]); | ||
} | ||
}); | ||
|
||
this._config = config; | ||
} | ||
|
||
// The height of your card. Home Assistant uses this to automatically | ||
// distribute all cards over the available columns. | ||
getCardSize() { | ||
return 3; | ||
} | ||
} | ||
|
||
customElements.define('starline-card', StarlineCard); |
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,36 @@ | ||
<div class="wrapper"> | ||
<div class="container"> | ||
<div class="car"> | ||
<div class="car-cnt"> | ||
<div class="car-body"></div> | ||
<div class="car-door"></div> | ||
<div class="car-hood"></div> | ||
<div class="car-trunk"></div> | ||
<div class="car-frontlight-left"></div> | ||
<div class="car-frontlight-right"></div> | ||
<div class="car-smoke"></div> | ||
<div class="car-key"></div> | ||
</div> | ||
<div class="car-security"> | ||
<div class="car-security-1"></div> | ||
<div class="car-security-2"></div> | ||
<div class="car-security-3"></div> | ||
<div class="car-security-4"></div> | ||
<div class="car-security-5"></div> | ||
</div> | ||
</div> | ||
|
||
<div class="controls"> | ||
<div class="control-left"></div> | ||
<div class="control-center"></div> | ||
<div class="control-right"></div> | ||
</div> | ||
|
||
<div class="info"> | ||
<div class="info-balance"></div> | ||
<div class="info-battery"></div> | ||
<div class="info-inner"></div> | ||
<div class="info-engine"></div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.