Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
Fixes #158 - Groups do not turn on/off lights (#167)
Browse files Browse the repository at this point in the history
* Fixes #158 - Groups do not turn on/off lights

I'm not sure if this has any side effects but it allows me to turn my groups on and off.

* Fixes code style issues
  • Loading branch information
mathewpeterson authored and robbiet480 committed Jul 19, 2017
1 parent fd264c6 commit 64060e9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions accessories/switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ HomeAssistantSwitch.prototype = {
const that = this;
const serviceData = {};
serviceData.entity_id = this.entity_id;
var callDomain = this.domain === 'group' ? 'homeassistant' : this.domain;

if (powerOn) {
this.log(`Setting power state on the '${this.name}' to on`);

this.client.callService(this.domain, 'turn_on', serviceData, (data) => {
this.client.callService(callDomain, 'turn_on', serviceData, (data) => {
if (this.domain === 'scene') {
setTimeout(() => {
this.service.getCharacteristic(Characteristic.On)
Expand All @@ -65,7 +66,7 @@ HomeAssistantSwitch.prototype = {
} else {
this.log(`Setting power state on the '${this.name}' to off`);

this.client.callService(this.domain, 'turn_off', serviceData, (data) => {
this.client.callService(callDomain, 'turn_off', serviceData, (data) => {
if (data) {
that.log(`Successfully set power state on the '${that.name}' to off`);
callback();
Expand Down

0 comments on commit 64060e9

Please sign in to comment.