diff --git a/README.md b/README.md index 2511b05..f4b8d26 100644 --- a/README.md +++ b/README.md @@ -85,9 +85,24 @@ I have collected an API Summary, where you have an quick overview of all methods This project currently supports the following devices: -- [Light](/src/app/LightControl.tsx) -- [Thermostat](/src/app/ThermostatControl.tsx) -- [Blinds](/src/app/BlindsControl.tsx) +[Switch](src/app/controls/SwitchControl.tsx) +![Screenshot](docs/controls/switch.png) + +[Thermostat](src/app/controls/ThermostatControl.tsx) +![Screenshot](docs/controls/thermostat.png) + +[Blinds](/src/app/BlindsControl.tsx) +![Screenshot](docs/controls/blinds.png) + +[Door Operator](src/app/controls/DoorControl.tsx) +![Screenshot](docs/controls/door-operator.png) + +[Floor Heating](src/app/controls/FloorControl.tsx) +![Screenshot](docs/controls/floor-heating.png) + +[Rain Detection Control](src/app/controls/RainDetectionControl.tsx) +![Screenshot](docs/controls/rain.png) + We welcome pull requests to add support for new devices. Your contributions are appreciated! diff --git a/docs/ListOfDevices1.png b/docs/ListOfDevices1.png index 4a2a92c..9bbbb47 100644 Binary files a/docs/ListOfDevices1.png and b/docs/ListOfDevices1.png differ diff --git a/docs/ListOfDevices2.png b/docs/ListOfDevices2.png index 6c5ce43..9d0a3b0 100644 Binary files a/docs/ListOfDevices2.png and b/docs/ListOfDevices2.png differ diff --git a/docs/controls/blinds.png b/docs/controls/blinds.png new file mode 100644 index 0000000..e7e1225 Binary files /dev/null and b/docs/controls/blinds.png differ diff --git a/docs/controls/door-operator.png b/docs/controls/door-operator.png new file mode 100644 index 0000000..4b5d742 Binary files /dev/null and b/docs/controls/door-operator.png differ diff --git a/docs/controls/floor-heating.png b/docs/controls/floor-heating.png new file mode 100644 index 0000000..0943f82 Binary files /dev/null and b/docs/controls/floor-heating.png differ diff --git a/docs/controls/rain.png b/docs/controls/rain.png new file mode 100644 index 0000000..755b6a8 Binary files /dev/null and b/docs/controls/rain.png differ diff --git a/docs/controls/switch.png b/docs/controls/switch.png new file mode 100644 index 0000000..206052e Binary files /dev/null and b/docs/controls/switch.png differ diff --git a/docs/controls/thermostat.png b/docs/controls/thermostat.png new file mode 100644 index 0000000..9fcbae6 Binary files /dev/null and b/docs/controls/thermostat.png differ diff --git a/src/app/ChannelsForType.tsx b/src/app/ChannelsForType.tsx index 9b4a98e..13d1975 100644 --- a/src/app/ChannelsForType.tsx +++ b/src/app/ChannelsForType.tsx @@ -17,6 +17,7 @@ import { useTranslations } from './../i18n/utils'; import { Icon } from '@iconify/react'; import { Channel, ChannelType } from './../types/types'; import { RainDetectionControl } from './controls/RainDetectionControl'; +import { DoorControl } from './controls/DoorControl'; interface ExpandMoreProps { @@ -49,6 +50,8 @@ const getControlComponent = (channel: Channel, refetch: () => void) => { return ; case ChannelType.RAIN_DETECTION_TRANSMITTER: return ; + case ChannelType.KEYMATIC: + return ; default: return ( diff --git a/src/app/components/StyledIcons.tsx b/src/app/components/StyledIcons.tsx index c784f1b..4e2751f 100644 --- a/src/app/components/StyledIcons.tsx +++ b/src/app/components/StyledIcons.tsx @@ -1,7 +1,13 @@ import { Icon } from "@iconify/react"; import { styled } from "@mui/material"; -export const StyledIconButton = styled(Icon)` +interface StyledIconButtonProps { + icon: string; + active?: string; +} + +export const StyledIconButton = styled(Icon)` + color: ${(props) => (props.active === 'true' ? '#0077B6' : '#000')}; font-size: 40px; background-color: lightGrey; border-radius: 10px; diff --git a/src/app/controls/DoorControl.tsx b/src/app/controls/DoorControl.tsx new file mode 100644 index 0000000..d73d55b --- /dev/null +++ b/src/app/controls/DoorControl.tsx @@ -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 = ({ 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 ( + + + + + + + + Door state is uncertain + + + } + /> + ); +}; diff --git a/src/app/controls/RainDetectionControl.tsx b/src/app/controls/RainDetectionControl.tsx index b4589ea..e69ea05 100644 --- a/src/app/controls/RainDetectionControl.tsx +++ b/src/app/controls/RainDetectionControl.tsx @@ -1,5 +1,5 @@ import { Box, CardHeader, Typography, styled } from '@mui/material'; -import { RainDesctionTransmitterChannel } from './../../types/types'; +import { RainDetectionTransmitterChannel } from './../../types/types'; import { StyledHeaderIcon } from '../components/StyledIcons'; const StyledBox = styled(Box)({ @@ -15,7 +15,7 @@ const StyledBox = styled(Box)({ interface RainDetectionControlProps { - channel: RainDesctionTransmitterChannel; + channel: RainDetectionTransmitterChannel; } export const RainDetectionControl: React.FC = ({ diff --git a/src/types/types.ts b/src/types/types.ts index 687a73b..b87d607 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -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; \ No newline at end of file +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;