-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
238 additions
and
110 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { Box, CardHeader, Typography } from '@mui/material'; | ||
import { StyledIconButton } from '../components/StyledIcons'; | ||
import { KeymaticChannel } from './../../types/types'; | ||
import { useSetValueMutation } from './../../hooks/useApi'; | ||
|
||
interface DoorControlProps { | ||
channel: KeymaticChannel; | ||
refetch: () => void; | ||
} | ||
|
||
export const DoorControl: React.FC<DoorControlProps> = ({ channel, refetch }) => { | ||
const setValueMutation = useSetValueMutation(); | ||
const { | ||
datapoints: { STATE, STATE_UNCERTAIN }, | ||
} = channel; | ||
|
||
const isUncertain = STATE_UNCERTAIN === 'true'; | ||
const isUnlocked = STATE === 'true'; | ||
|
||
const unlockDoor = async () => { | ||
await setValueMutation.mutateAsync({ | ||
interface: channel.interfaceName, | ||
address: channel.address, | ||
valueKey: 'STATE', | ||
type: 'boolean', | ||
value: true, | ||
}); | ||
refetch() | ||
}; | ||
|
||
const lockDoor = async () => { | ||
await setValueMutation.mutateAsync({ | ||
interface: channel.interfaceName, | ||
address: channel.address, | ||
valueKey: 'STATE', | ||
type: 'boolean', | ||
value: false, | ||
}); | ||
refetch() | ||
}; | ||
|
||
const openDoor = async () => { | ||
await setValueMutation.mutateAsync({ | ||
interface: channel.interfaceName, | ||
address: channel.address, | ||
valueKey: 'OPEN', | ||
type: 'boolean', | ||
value: true, | ||
}); | ||
refetch() | ||
}; | ||
|
||
return ( | ||
<CardHeader | ||
title={ | ||
<Box> | ||
<Box sx={{ display: 'flex', gap: '10px', alignItems: 'center' }}> | ||
<StyledIconButton | ||
icon="material-symbols:lock-outline" | ||
active={(!isUnlocked).toString()} | ||
onClick={lockDoor} | ||
/> | ||
<StyledIconButton | ||
icon="material-symbols:lock-open-outline" | ||
active={isUnlocked.toString()} | ||
onClick={unlockDoor} | ||
/> | ||
<StyledIconButton | ||
icon="material-symbols:door-open-outline" | ||
onClick={openDoor} | ||
/> | ||
</Box> | ||
<Typography | ||
sx={{ display: isUncertain ? 'block' : 'none' }} | ||
variant="caption" | ||
> | ||
Door state is uncertain | ||
</Typography> | ||
</Box> | ||
} | ||
/> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,127 @@ | ||
export enum ChannelType { | ||
SWITCH_VIRTUAL_RECEIVER = "SWITCH_VIRTUAL_RECEIVER", | ||
BLIND_VIRTUAL_RECEIVER = "BLIND_VIRTUAL_RECEIVER", | ||
HEATING_CLIMATECONTROL_TRANSCEIVER = "HEATING_CLIMATECONTROL_TRANSCEIVER", | ||
CLIMATECONTROL_FLOOR_TRANSCEIVER = "CLIMATECONTROL_FLOOR_TRANSCEIVER", | ||
RAIN_DETECTION_TRANSMITTER = "RAIN_DETECTION_TRANSMITTER" | ||
} | ||
|
||
export type SwitchVirtualReceiverDatapoint = { | ||
COMBINED_PARAMETER: string; | ||
ON_TIME: string; | ||
PROCESS: string; | ||
SECTION: string; | ||
SECTION_STATUS: string; | ||
STATE: string; | ||
}; | ||
|
||
export type BlindVirtualReceiverDatapoint = { | ||
ACTIVITY_STATE: string; | ||
COMBINED_PARAMETER: string; | ||
LEVEL: string; | ||
LEVEL_2: string; | ||
LEVEL_2_STATUS: string; | ||
LEVEL_STATUS: string; | ||
PROCESS: string; | ||
SECTION: string; | ||
SECTION_STATUS: string; | ||
STOP: string; | ||
}; | ||
|
||
export type HeatingClimateControlTransceiverDatapoint = { | ||
ACTIVE_PROFILE: string; | ||
ACTUAL_TEMPERATURE: string; | ||
ACTUAL_TEMPERATURE_STATUS: string; | ||
BOOST_MODE: string; | ||
BOOST_TIME: string; | ||
CONTROL_DIFFERENTIAL_TEMPERATURE: string; | ||
CONTROL_MODE: string; | ||
DURATION_UNIT: string; | ||
DURATION_VALUE: string; | ||
FROST_PROTECTION: string; | ||
HEATING_COOLING: string; | ||
HUMIDITY?: string; | ||
HUMIDITY_STATUS?: string; | ||
PARTY_MODE: string; | ||
PARTY_SET_POINT_TEMPERATURE: string; | ||
PARTY_TIME_END: string; | ||
PARTY_TIME_START: string; | ||
QUICK_VETO_TIME: string; | ||
SET_POINT_MODE: string; | ||
SET_POINT_TEMPERATURE: string; | ||
SWITCH_POINT_OCCURED: string; | ||
WINDOW_STATE: string; | ||
LEVEL?: string; | ||
LEVEL_STATUS?: string; | ||
}; | ||
|
||
export type FloorClimateControlTransceiverDatapoint = { | ||
DEW_POINT_ALARM: string; | ||
EMERGENCY_OPERATION: string; | ||
EXTERNAL_CLOCK: string; | ||
FROST_PROTECTION: string; | ||
HUMIDITY_LIMITER: string; | ||
LEVEL: string; | ||
LEVEL_STATUS: string; | ||
VALVE_STATE: string; | ||
} | ||
|
||
export type RainDesctionTransmitterDatapoint = { | ||
RAINING: string; | ||
HEATER_STATE: string; | ||
} | ||
|
||
interface BaseChannel { | ||
id: number; | ||
name: string; | ||
address: string; | ||
interfaceName: string; | ||
} | ||
|
||
export interface SwitchVirtualReceiverChannel extends BaseChannel { | ||
type: ChannelType.SWITCH_VIRTUAL_RECEIVER; | ||
datapoints: SwitchVirtualReceiverDatapoint; | ||
} | ||
|
||
export interface BlindVirtualReceiverChannel extends BaseChannel { | ||
type: ChannelType.BLIND_VIRTUAL_RECEIVER; | ||
datapoints: BlindVirtualReceiverDatapoint; | ||
} | ||
|
||
export interface HeatingClimateControlTransceiverChannel extends BaseChannel { | ||
type: ChannelType.HEATING_CLIMATECONTROL_TRANSCEIVER; | ||
datapoints: HeatingClimateControlTransceiverDatapoint; | ||
} | ||
|
||
export interface FloorClimateControlTransceiverChannel extends BaseChannel { | ||
type: ChannelType.CLIMATECONTROL_FLOOR_TRANSCEIVER; | ||
datapoints: FloorClimateControlTransceiverDatapoint | ||
} | ||
SWITCH_VIRTUAL_RECEIVER = 'SWITCH_VIRTUAL_RECEIVER', | ||
BLIND_VIRTUAL_RECEIVER = 'BLIND_VIRTUAL_RECEIVER', | ||
HEATING_CLIMATECONTROL_TRANSCEIVER = 'HEATING_CLIMATECONTROL_TRANSCEIVER', | ||
CLIMATECONTROL_FLOOR_TRANSCEIVER = 'CLIMATECONTROL_FLOOR_TRANSCEIVER', | ||
RAIN_DETECTION_TRANSMITTER = 'RAIN_DETECTION_TRANSMITTER', | ||
KEYMATIC = 'KEYMATIC', | ||
} | ||
|
||
export interface RainDesctionTransmitterChannel extends BaseChannel { | ||
type: ChannelType.RAIN_DETECTION_TRANSMITTER; | ||
datapoints: RainDesctionTransmitterDatapoint | ||
} | ||
|
||
export type Channel = SwitchVirtualReceiverChannel | BlindVirtualReceiverChannel | HeatingClimateControlTransceiverChannel | FloorClimateControlTransceiverChannel | RainDesctionTransmitterChannel; | ||
export type SwitchVirtualReceiverDatapoint = { | ||
COMBINED_PARAMETER: string; | ||
ON_TIME: string; | ||
PROCESS: string; | ||
SECTION: string; | ||
SECTION_STATUS: string; | ||
STATE: string; | ||
}; | ||
|
||
export type BlindVirtualReceiverDatapoint = { | ||
ACTIVITY_STATE: string; | ||
COMBINED_PARAMETER: string; | ||
LEVEL: string; | ||
LEVEL_2: string; | ||
LEVEL_2_STATUS: string; | ||
LEVEL_STATUS: string; | ||
PROCESS: string; | ||
SECTION: string; | ||
SECTION_STATUS: string; | ||
STOP: string; | ||
}; | ||
|
||
export type HeatingClimateControlTransceiverDatapoint = { | ||
ACTIVE_PROFILE: string; | ||
ACTUAL_TEMPERATURE: string; | ||
ACTUAL_TEMPERATURE_STATUS: string; | ||
BOOST_MODE: string; | ||
BOOST_TIME: string; | ||
CONTROL_DIFFERENTIAL_TEMPERATURE: string; | ||
CONTROL_MODE: string; | ||
DURATION_UNIT: string; | ||
DURATION_VALUE: string; | ||
FROST_PROTECTION: string; | ||
HEATING_COOLING: string; | ||
HUMIDITY?: string; | ||
HUMIDITY_STATUS?: string; | ||
PARTY_MODE: string; | ||
PARTY_SET_POINT_TEMPERATURE: string; | ||
PARTY_TIME_END: string; | ||
PARTY_TIME_START: string; | ||
QUICK_VETO_TIME: string; | ||
SET_POINT_MODE: string; | ||
SET_POINT_TEMPERATURE: string; | ||
SWITCH_POINT_OCCURED: string; | ||
WINDOW_STATE: string; | ||
LEVEL?: string; | ||
LEVEL_STATUS?: string; | ||
}; | ||
|
||
export type FloorClimateControlTransceiverDatapoint = { | ||
DEW_POINT_ALARM: string; | ||
EMERGENCY_OPERATION: string; | ||
EXTERNAL_CLOCK: string; | ||
FROST_PROTECTION: string; | ||
HUMIDITY_LIMITER: string; | ||
LEVEL: string; | ||
LEVEL_STATUS: string; | ||
VALVE_STATE: string; | ||
}; | ||
|
||
export type RainDesctionTransmitterDatapoint = { | ||
RAINING: string; | ||
HEATER_STATE: string; | ||
}; | ||
|
||
export type KeymaticDatapoint = { | ||
ERROR: string; | ||
INHIBIT: string; | ||
OPEN: string; | ||
RELOCK_DELAY: string; | ||
STATE: string; | ||
STATE_UNCERTAIN: string; | ||
}; | ||
|
||
interface BaseChannel { | ||
id: number; | ||
name: string; | ||
address: string; | ||
interfaceName: string; | ||
} | ||
|
||
export interface SwitchVirtualReceiverChannel extends BaseChannel { | ||
type: ChannelType.SWITCH_VIRTUAL_RECEIVER; | ||
datapoints: SwitchVirtualReceiverDatapoint; | ||
} | ||
|
||
export interface BlindVirtualReceiverChannel extends BaseChannel { | ||
type: ChannelType.BLIND_VIRTUAL_RECEIVER; | ||
datapoints: BlindVirtualReceiverDatapoint; | ||
} | ||
|
||
export interface HeatingClimateControlTransceiverChannel extends BaseChannel { | ||
type: ChannelType.HEATING_CLIMATECONTROL_TRANSCEIVER; | ||
datapoints: HeatingClimateControlTransceiverDatapoint; | ||
} | ||
|
||
export interface FloorClimateControlTransceiverChannel extends BaseChannel { | ||
type: ChannelType.CLIMATECONTROL_FLOOR_TRANSCEIVER; | ||
datapoints: FloorClimateControlTransceiverDatapoint; | ||
} | ||
|
||
export interface RainDetectionTransmitterChannel extends BaseChannel { | ||
type: ChannelType.RAIN_DETECTION_TRANSMITTER; | ||
datapoints: RainDesctionTransmitterDatapoint; | ||
} | ||
|
||
export interface KeymaticChannel extends BaseChannel { | ||
type: ChannelType.KEYMATIC; | ||
datapoints: KeymaticDatapoint; | ||
} | ||
|
||
export type Channel = | ||
| SwitchVirtualReceiverChannel | ||
| BlindVirtualReceiverChannel | ||
| HeatingClimateControlTransceiverChannel | ||
| FloorClimateControlTransceiverChannel | ||
| RainDetectionTransmitterChannel | ||
| KeymaticChannel; |