Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago Bendavid committed Nov 22, 2023
2 parents 40a2ed5 + 06d0625 commit f90f528
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<img src="https://raw.githubusercontent.com/homebridge/branding/latest/logos/homebridge-wordmark-logo-vertical.png" width="150">
</p>

[![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
[![npm package](https://badgen.net/npm/v/homebridge-switch-button)](https://www.npmjs.com/package/homebridge-switch-button)
[![Total downloads](https://badgen.net/npm/dt/homebridge-switch-button)](https://www.npmjs.com/package/homebridge-switch-button)
[![Build, Lint and Type check](https://github.com/sant3001/homebridge-switch-button/actions/workflows/build.yml/badge.svg)](https://github.com/sant3001/homebridge-switch-button/actions/workflows/build.yml)
Expand Down Expand Up @@ -34,3 +35,15 @@ By adding this plugin you can avoid converting your automation to Shorcuts and d
3. Create a second automation to turn `OFF` your physical light when the light switch is turned `OFF`.

Vualá! You're all set.

## PRO tips - Recommended Home Configuration

If you regularly use the Home app or Siri to turn on your lights, it's also best to replace the physical light with the virtual light so that the `ON/OFF` state is always managed by the virtual light. You can do so following these steps:

1. In the Home app, go to the light switch configuration and add it to the same room as the physical light.
2. Open to the room you added the light switch to.
3. Go to your physical light configuration. Toggle `OFF` "Add to Home View", and toggle `OFF` "Include in Favorites". Rename this light to something different from the original name, i.e. "Physical Guest Room Light"
4. Go to your light switch configuration and click in "Show as Separate Tiles" and close it. Now the virtual light and virtual switch should be displayed as separate tiles.
5. Go to the virtual light configuration. Toggle `ON` "Add to Home View" and (optionally) toggle `ON` "Include in Favorites". Rename this light to the original name of your physical light, i.e. "Guest Room Light".

You should now see the virtual light in the Home dashboard.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"displayName": "Plugin Switch Button",
"displayName": "Homebridge Switch Button",
"name": "homebridge-switch-button",
"version": "1.0.2",
"description": "Homebridge button and light switches for simple automations in Homekit. https://github.com/sant3001/homebridge-switch-button",
Expand All @@ -24,7 +24,12 @@
"typecheck": "tsc --noEmit"
},
"keywords": [
"homebridge-plugin", "light", "homebridge", "button", "switch", "homekit"
"homebridge-plugin",
"light",
"homebridge",
"button",
"switch",
"homekit"
],
"dependencies": {},
"devDependencies": {
Expand Down
9 changes: 5 additions & 4 deletions src/accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ export class HomebridgeSwitchButtonAccessory implements AccessoryPlugin {

if (on) {
this.log.debug('Start switch timer');
// Flip the light bulb state
this.states.LightOn = !this.states.LightOn;
this.lightService.getCharacteristic(this.Characteristic.On).updateValue(this.states.LightOn);
this.log.debug('Switch timer completed, light is now ', this.states.LightOn? 'On' : 'Off');

this.timer = setTimeout(() => {
// Turn off the switch
this.states.SwitchOn = false;
this.switchService.getCharacteristic(this.Characteristic.On).updateValue(false);
// Flip the light bulb state
this.states.LightOn = !this.states.LightOn;
this.lightService.getCharacteristic(this.Characteristic.On).updateValue(this.states.LightOn);
this.log.debug('Switch timer completed, light is now ', this.states.LightOn? 'On' : 'Off');
}, this.config.delay || 500);
}
}
Expand Down

0 comments on commit f90f528

Please sign in to comment.