Skip to content

Commit

Permalink
Only add Lightbulb service if state is also present. This should fix
Browse files Browse the repository at this point in the history
  • Loading branch information
itavero committed Jul 5, 2020
1 parent 93e60b4 commit 42f9d81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,10 @@ and after the project will apply [Semantic Versioning](https://semver.org/spec/v

- README now mentions how to run the "development" version.

### Fixed

- Hue Dimmer Switch appears as a light bulb ([#1](https://github.com/itavero/homebridge-z2m/issues/1))

## [0.0.3][] - 2020-07-01
### Added

Expand Down
11 changes: 7 additions & 4 deletions src/platformAccessory.ts
Expand Up @@ -248,10 +248,13 @@ export class Zigbee2mqttAccessory {
case 'color_temp':
case 'color':
{
this.removeOtherServicesUsingKey('state');
const wrapper = new LightbulbServiceWrapper(this.getOrAddService(this.platform.Service.Lightbulb),
this.platform.Characteristic, this.publishSet.bind(this));
this.addService(wrapper, state, handledKeys);
if (state === undefined || state.has('state')) {
// Only add a light bulb if the `state` is also available.
this.removeOtherServicesUsingKey('state');
const wrapper = new LightbulbServiceWrapper(this.getOrAddService(this.platform.Service.Lightbulb),
this.platform.Characteristic, this.publishSet.bind(this));
this.addService(wrapper, state, handledKeys);
}
break;
}
case 'position':
Expand Down

0 comments on commit 42f9d81

Please sign in to comment.