import { ZWaveError , ZWaveErrorCodes } from "@zwave-js/core" ; import { decodeSetbackState , encodeSetbackState , SetbackState , } from "./SetbackState" ; export interface Switchpoint { hour : number ; minute : number ; state : SetbackState | undefined ; } export function decodeSwitchpoint ( data ) { return { hour : data [ 0 ] & 31 , minute : data [ 1 ] & 63 , state : decodeSetbackState ( data [ 2 ] ) } ; } export function encodeSwitchpoint ( point ) { if ( point . state == undefined ) throw new ZWaveError ( "The given Switchpoint is not valid!" , ZWaveErrorCodes . CC_Invalid ) ; return Buffer . from ( [ point . hour & 31 , point . minute & 63 , encodeSetbackState ( point . state ) , ] ) ; }