diff --git a/src/cards/ha-domain-card.js b/src/cards/ha-domain-card.js
index b0544632ae..ff63c91231 100644
--- a/src/cards/ha-domain-card.js
+++ b/src/cards/ha-domain-card.js
@@ -2,6 +2,7 @@ import Polymer from '../polymer';
import { moreInfoActions } from '../util/home-assistant-js-instance';
require('../components/ha-card');
+require('../components/entity/ha-entity-toggle');
require('../state-summary/state-card-content');
export default new Polymer({
@@ -14,6 +15,9 @@ export default new Polymer({
states: {
type: Array,
},
+ groupEntity: {
+ type: Object,
+ },
},
computeDomainTitle(domain) {
diff --git a/src/components/entity/ha-entity-toggle.html b/src/components/entity/ha-entity-toggle.html
new file mode 100644
index 0000000000..3a5945eb3b
--- /dev/null
+++ b/src/components/entity/ha-entity-toggle.html
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
diff --git a/src/components/entity/ha-entity-toggle.js b/src/components/entity/ha-entity-toggle.js
new file mode 100644
index 0000000000..65a5cd697f
--- /dev/null
+++ b/src/components/entity/ha-entity-toggle.js
@@ -0,0 +1,63 @@
+import { serviceActions } from '../../util/home-assistant-js-instance';
+
+import Polymer from '../../polymer';
+
+export default new Polymer({
+ is: 'ha-entity-toggle',
+
+ properties: {
+ stateObj: {
+ type: Object,
+ observer: 'stateObjChanged',
+ },
+
+ toggleChecked: {
+ type: Boolean,
+ value: false,
+ },
+ },
+
+ ready() {
+ this.forceStateChange();
+ },
+
+ toggleChanged(ev) {
+ const newVal = ev.target.checked;
+
+ if (newVal && this.stateObj.state === 'off') {
+ this.turn_on();
+ } else if (!newVal && this.stateObj.state !== 'off') {
+ this.turn_off();
+ }
+ },
+
+ stateObjChanged(newVal) {
+ if (newVal) {
+ this.updateToggle(newVal);
+ }
+ },
+
+ updateToggle(stateObj) {
+ this.toggleChecked = stateObj && stateObj.state !== 'off';
+ },
+
+ forceStateChange() {
+ this.updateToggle(this.stateObj);
+ },
+
+ turn_on() {
+ // We call updateToggle after a successful call to re-sync the toggle
+ // with the state. It will be out of sync if our service call did not
+ // result in the entity to be turned on. Since the state is not changing,
+ // the resync is not called automatic.
+ serviceActions.callTurnOn(this.stateObj.entityId).then(() => this.forceStateChange());
+ },
+
+ turn_off() {
+ // We call updateToggle after a successful call to re-sync the toggle
+ // with the state. It will be out of sync if our service call did not
+ // result in the entity to be turned on. Since the state is not changing,
+ // the resync is not called automatic.
+ serviceActions.callTurnOff(this.stateObj.entityId).then(() => this.forceStateChange());
+ },
+});
diff --git a/src/components/ha-zone-cards.html b/src/components/ha-zone-cards.html
index 5a811eb362..cec69ba0f6 100644
--- a/src/components/ha-zone-cards.html
+++ b/src/components/ha-zone-cards.html
@@ -57,6 +57,7 @@
diff --git a/src/state-summary/state-card-toggle.js b/src/state-summary/state-card-toggle.js
index 992e8868df..18b620bf2c 100644
--- a/src/state-summary/state-card-toggle.js
+++ b/src/state-summary/state-card-toggle.js
@@ -1,65 +1,8 @@
-import { serviceActions } from '../util/home-assistant-js-instance';
-
import Polymer from '../polymer';
require('../components/state-info');
+require('../components/entity/ha-entity-toggle');
export default new Polymer({
is: 'state-card-toggle',
-
- properties: {
- stateObj: {
- type: Object,
- observer: 'stateObjChanged',
- },
-
- toggleChecked: {
- type: Boolean,
- value: false,
- },
- },
-
- ready() {
- this.forceStateChange();
- },
-
- toggleChanged(ev) {
- const newVal = ev.target.checked;
-
- if (newVal && this.stateObj.state === 'off') {
- this.turn_on();
- } else if (!newVal && this.stateObj.state !== 'off') {
- this.turn_off();
- }
- },
-
- stateObjChanged(newVal) {
- if (newVal) {
- this.updateToggle(newVal);
- }
- },
-
- updateToggle(stateObj) {
- this.toggleChecked = stateObj && stateObj.state !== 'off';
- },
-
- forceStateChange() {
- this.updateToggle(this.stateObj);
- },
-
- turn_on() {
- // We call updateToggle after a successful call to re-sync the toggle
- // with the state. It will be out of sync if our service call did not
- // result in the entity to be turned on. Since the state is not changing,
- // the resync is not called automatic.
- serviceActions.callTurnOn(this.stateObj.entityId).then(() => this.forceStateChange());
- },
-
- turn_off() {
- // We call updateToggle after a successful call to re-sync the toggle
- // with the state. It will be out of sync if our service call did not
- // result in the entity to be turned on. Since the state is not changing,
- // the resync is not called automatic.
- serviceActions.callTurnOff(this.stateObj.entityId).then(() => this.forceStateChange());
- },
});