-
-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Thermostat Setback mocks, fix state encoding, remove CC values
- Loading branch information
Showing
5 changed files
with
97 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetback.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { type SetbackState, SetbackType } from "@zwave-js/cc"; | ||
import { | ||
ThermostatSetbackCCGet, | ||
ThermostatSetbackCCReport, | ||
ThermostatSetbackCCSet, | ||
} from "@zwave-js/cc/ThermostatSetbackCC"; | ||
import { type MockNodeBehavior } from "@zwave-js/testing"; | ||
|
||
const STATE_KEY_PREFIX = "ThermostatSetback_"; | ||
const StateKeys = { | ||
setbackType: `${STATE_KEY_PREFIX}setbackType`, | ||
setbackState: `${STATE_KEY_PREFIX}setbackState`, | ||
} as const; | ||
|
||
const respondToThermostatSetbackSet: MockNodeBehavior = { | ||
handleCC(controller, self, receivedCC) { | ||
if (receivedCC instanceof ThermostatSetbackCCSet) { | ||
self.state.set(StateKeys.setbackType, receivedCC.setbackType); | ||
self.state.set(StateKeys.setbackState, receivedCC.setbackState); | ||
return { action: "ok" }; | ||
} | ||
}, | ||
}; | ||
|
||
const respondToThermostatSetbackGet: MockNodeBehavior = { | ||
handleCC(controller, self, receivedCC) { | ||
if (receivedCC instanceof ThermostatSetbackCCGet) { | ||
const setbackType = ( | ||
self.state.get(StateKeys.setbackType) | ||
?? SetbackType.None | ||
) as SetbackType; | ||
const setbackState = ( | ||
self.state.get(StateKeys.setbackState) | ||
?? "Unused" | ||
) as SetbackState; | ||
|
||
const cc = new ThermostatSetbackCCReport(self.host, { | ||
nodeId: controller.host.ownNodeId, | ||
setbackType, | ||
setbackState, | ||
}); | ||
return { action: "sendCC", cc }; | ||
} | ||
}, | ||
}; | ||
|
||
export const ThermostatSetbackCCBehaviors = [ | ||
respondToThermostatSetbackGet, | ||
respondToThermostatSetbackSet, | ||
]; |