Skip to content

Commit

Permalink
Add Washer and Dishwasher
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Krug <michi.krug@gmail.com>
  • Loading branch information
michikrug committed May 31, 2024
1 parent 5e85c45 commit 9fad2f9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
4 changes: 3 additions & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Switch { ga="Fireplace" }
Switch { ga="Valve" [ inverted=true ] }
```
### Sprinkler, Vacuum
### Sprinkler, Vacuum, Washer, Dishwasher
| | |
|---|---|
Expand All @@ -206,6 +206,8 @@ Switch { ga="Valve" [ inverted=true ] }
```shell
Switch { ga="Sprinkler" [ inverted=true ] }
Switch { ga="Vacuum" [ inverted=false ] }
Switch { ga="Washer" [ inverted=false ] }
Switch { ga="Dishwasher" [ inverted=false ] }
```
### Lock
Expand Down
9 changes: 9 additions & 0 deletions functions/devices/dishwasher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const StartStopSwitch = require('./startstopswitch.js');

class Dishwasher extends StartStopSwitch {
static get type() {
return 'action.devices.types.DISHWASHER';
}
}

module.exports = Dishwasher;
3 changes: 1 addition & 2 deletions functions/devices/startstopswitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class StartStopSwitch extends DefaultDevice {
state = !state;
}
return {
isRunning: state,
isPaused: !state
isRunning: state
};
}
}
Expand Down
9 changes: 9 additions & 0 deletions functions/devices/washer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const StartStopSwitch = require('./startstopswitch.js');

class Washer extends StartStopSwitch {
static get type() {
return 'action.devices.types.WASHER';
}
}

module.exports = Washer;
12 changes: 4 additions & 8 deletions tests/devices/startstopswitch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ describe('StartStopSwitch Device', () => {
describe('getState', () => {
test('getState', () => {
expect(Device.getState({ state: 'ON' })).toStrictEqual({
isRunning: true,
isPaused: false
isRunning: true
});
expect(Device.getState({ state: 'OFF' })).toStrictEqual({
isRunning: false,
isPaused: true
isRunning: false
});
});

Expand All @@ -36,13 +34,11 @@ describe('StartStopSwitch Device', () => {
}
};
expect(Device.getState(item)).toStrictEqual({
isRunning: false,
isPaused: true
isRunning: false
});
item.state = 'OFF';
expect(Device.getState(item)).toStrictEqual({
isRunning: true,
isPaused: false
isRunning: true
});
});
});
Expand Down

0 comments on commit 9fad2f9

Please sign in to comment.