mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Home Assistant JS now returns class
This commit is contained in:
parent
15cb01cb5b
commit
f1bad9e5f6
@ -16,7 +16,7 @@
|
|||||||
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"home-assistant-js": "git+https://github.com/balloob/home-assistant-js.git#c345559ab7b8cc9b9bc1421dc22198df0a86740b",
|
"home-assistant-js": "git+https://github.com/balloob/home-assistant-js.git#7bc70c0b75c274166ddba0d647356b6d0b7d696e",
|
||||||
"lodash": "^3.10.1",
|
"lodash": "^3.10.1",
|
||||||
"moment": "^2.10.6"
|
"moment": "^2.10.6"
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { entityGetters } from 'home-assistant-js';
|
import { entityGetters } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { eventGetters } from 'home-assistant-js';
|
import { eventGetters } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
authActions,
|
authActions,
|
||||||
navigationActions,
|
navigationActions,
|
||||||
util
|
util
|
||||||
} from 'home-assistant-js';
|
} from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { voiceGetters } from 'home-assistant-js';
|
import { voiceGetters } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { moreInfoActions } from 'home-assistant-js';
|
import { moreInfoActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { util } from 'home-assistant-js';
|
import { util } from '../util/home-assistant-js-instance';
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
||||||
const UPDATE_INTERVAL = 60000; // 60 seconds
|
const UPDATE_INTERVAL = 60000; // 60 seconds
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { serviceGetters } from 'home-assistant-js';
|
import { serviceGetters } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
||||||
|
|
||||||
<link rel="import" href="../cards/state-card.html">
|
<link rel="import" href="../state-summary/state-card.html">
|
||||||
|
|
||||||
<dom-module id="state-cards">
|
<dom-module id="state-cards">
|
||||||
<style>
|
<style>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
||||||
require('../cards/state-card');
|
require('../state-summary/state-card');
|
||||||
|
|
||||||
export default new Polymer({
|
export default new Polymer({
|
||||||
is: 'state-cards',
|
is: 'state-cards',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { streamGetters, streamActions } from 'home-assistant-js';
|
import { streamGetters, streamActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<!-- <link rel="import" href="../../bower_components/neon-animation/animations/slide-up-animation.html">
|
<!-- <link rel="import" href="../../bower_components/neon-animation/animations/slide-up-animation.html">
|
||||||
<link rel="import" href="../../bower_components/neon-animation/animations/slide-down-animation.html">
|
<link rel="import" href="../../bower_components/neon-animation/animations/slide-down-animation.html">
|
||||||
-->
|
-->
|
||||||
<link rel="import" href="../cards/state-card-content.html">
|
<link rel="import" href="../state-summary/state-card-content.html">
|
||||||
<link rel="import" href="../components/state-history-charts.html">
|
<link rel="import" href="../components/state-history-charts.html">
|
||||||
<link rel="import" href="../more-infos/more-info-content.html">
|
<link rel="import" href="../more-infos/more-info-content.html">
|
||||||
|
|
||||||
|
@ -4,12 +4,12 @@ import {
|
|||||||
entityHistoryActions,
|
entityHistoryActions,
|
||||||
moreInfoGetters,
|
moreInfoGetters,
|
||||||
moreInfoActions
|
moreInfoActions
|
||||||
} from 'home-assistant-js';
|
} from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
|
||||||
require('../cards/state-card-content');
|
require('../state-summary/state-card-content');
|
||||||
require('../components/state-history-charts');
|
require('../components/state-history-charts');
|
||||||
require('../more-infos/more-info-content');
|
require('../more-infos/more-info-content');
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
syncGetters,
|
syncGetters,
|
||||||
localStoragePreferences,
|
localStoragePreferences,
|
||||||
startLocalStoragePreferencesSync
|
startLocalStoragePreferencesSync
|
||||||
} from 'home-assistant-js';
|
} from './util/home-assistant-js-instance';
|
||||||
|
|
||||||
import nuclearObserver from './util/bound-nuclear-behavior';
|
import nuclearObserver from './util/bound-nuclear-behavior';
|
||||||
import validateAuth from './util/validate-auth';
|
import validateAuth from './util/validate-auth';
|
||||||
|
@ -2,7 +2,7 @@ import {
|
|||||||
navigationGetters,
|
navigationGetters,
|
||||||
startUrlSync,
|
startUrlSync,
|
||||||
stopUrlSync,
|
stopUrlSync,
|
||||||
} from 'home-assistant-js';
|
} from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
||||||
import { authGetters } from 'home-assistant-js';
|
import { authGetters } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
import validateAuth from '../util/validate-auth';
|
import validateAuth from '../util/validate-auth';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { serviceActions } from 'home-assistant-js';
|
import { serviceActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { eventActions } from 'home-assistant-js';
|
import { eventActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { reactor, entityGetters, entityActions } from 'home-assistant-js';
|
import { reactor, entityGetters, entityActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
entityHistoryGetters,
|
entityHistoryGetters,
|
||||||
entityHistoryActions
|
entityHistoryActions
|
||||||
} from 'home-assistant-js';
|
} from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { logbookGetters, logbookActions } from 'home-assistant-js';
|
import { logbookGetters, logbookActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -28,14 +28,6 @@
|
|||||||
line-height: 2em;
|
line-height: 2em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.interimTranscript {
|
|
||||||
color: darkgrey;
|
|
||||||
}
|
|
||||||
|
|
||||||
.listening paper-spinner {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
syncActions,
|
syncActions,
|
||||||
voiceActions,
|
voiceActions,
|
||||||
util
|
util
|
||||||
} from 'home-assistant-js';
|
} from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { notificationGetters } from 'home-assistant-js';
|
import { notificationGetters } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -2,7 +2,7 @@ import {
|
|||||||
streamGetters,
|
streamGetters,
|
||||||
syncActions,
|
syncActions,
|
||||||
serviceActions
|
serviceActions
|
||||||
} from 'home-assistant-js';
|
} from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../bower_components/polymer/polymer.html">
|
||||||
|
|
||||||
<link rel="import" href="../cards/state-card-content.html">
|
<link rel="import" href="../state-summary/state-card-content.html">
|
||||||
|
|
||||||
<dom-module id="more-info-group">
|
<dom-module id="more-info-group">
|
||||||
<style>
|
<style>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
entityGetters,
|
entityGetters,
|
||||||
moreInfoGetters
|
moreInfoGetters
|
||||||
} from 'home-assistant-js';
|
} from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import nuclearObserver from '../util/bound-nuclear-behavior';
|
import nuclearObserver from '../util/bound-nuclear-behavior';
|
||||||
|
|
||||||
require('../cards/state-card-content');
|
require('../state-summary/state-card-content');
|
||||||
|
|
||||||
export default new Polymer({
|
export default new Polymer({
|
||||||
is: 'more-info-group',
|
is: 'more-info-group',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { serviceActions } from 'home-assistant-js';
|
import { serviceActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import attributeClassNames from '../util/attribute-class-names';
|
import attributeClassNames from '../util/attribute-class-names';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { serviceActions } from 'home-assistant-js';
|
import { serviceActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import attributeClassNames from '../util/attribute-class-names';
|
import attributeClassNames from '../util/attribute-class-names';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { util } from 'home-assistant-js';
|
import { util } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import formatTime from '../util/format-time';
|
import formatTime from '../util/format-time';
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { serviceActions } from 'home-assistant-js';
|
import { serviceActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
import attributeClassNames from '../util/attribute-class-names';
|
import attributeClassNames from '../util/attribute-class-names';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { serviceActions } from 'home-assistant-js';
|
import { serviceActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
export default new Polymer({
|
export default new Polymer({
|
||||||
is: 'more-info-updater',
|
is: 'more-info-updater',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { serviceActions } from 'home-assistant-js';
|
import { serviceActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { moreInfoActions } from 'home-assistant-js';
|
import { moreInfoActions } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import Polymer from '../polymer';
|
import Polymer from '../polymer';
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { reactor } from 'home-assistant-js';
|
import { reactor } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
import nuclearObserver from './nuclear-behavior';
|
import nuclearObserver from './nuclear-behavior';
|
||||||
|
|
||||||
|
3
src/util/home-assistant-js-instance.js
Normal file
3
src/util/home-assistant-js-instance.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import HomeAssistant from 'home-assistant-js';
|
||||||
|
|
||||||
|
export default new HomeAssistant();
|
@ -1,4 +1,4 @@
|
|||||||
import { reactor, serviceGetters } from 'home-assistant-js';
|
import { reactor, serviceGetters } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
const DOMAINS_WITH_CARD = [
|
const DOMAINS_WITH_CARD = [
|
||||||
'thermostat', 'configurator', 'scene', 'media_player'];
|
'thermostat', 'configurator', 'scene', 'media_player'];
|
||||||
@ -6,7 +6,7 @@ const DOMAINS_WITH_CARD = [
|
|||||||
export default function stateCardType(state) {
|
export default function stateCardType(state) {
|
||||||
if (DOMAINS_WITH_CARD.indexOf(state.domain) !== -1) {
|
if (DOMAINS_WITH_CARD.indexOf(state.domain) !== -1) {
|
||||||
return state.domain;
|
return state.domain;
|
||||||
} else if (reactor.evaluate(serviceGetters.canToggle(state.entityId))) {
|
} else if (reactor.evaluate(serviceGetters.canToggleEntity(state.entityId))) {
|
||||||
return 'toggle';
|
return 'toggle';
|
||||||
}
|
}
|
||||||
return 'display';
|
return 'display';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { authActions, localStoragePreferences } from 'home-assistant-js';
|
import { authActions, localStoragePreferences } from '../util/home-assistant-js-instance';
|
||||||
|
|
||||||
export default function(authToken, rememberAuth) {
|
export default function(authToken, rememberAuth) {
|
||||||
authActions.validate(authToken, {
|
authActions.validate(authToken, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user