Skip to content

Commit 403ffac

Browse files
authored
fix: typing & icons (#2444)
1 parent b2158ae commit 403ffac

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/components/power-source/index.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
33
import { Device, DeviceState } from '../../types';
44
import style from './style.module.css';
55
import { powerSourceTypeToTranslationKey } from './powerSourceTypeToTranslationKey';
6+
import type { PowerSource } from '../../types';
67

78
interface PowerSourceProps {
89
device?: Device;
@@ -12,7 +13,7 @@ interface PowerSourceProps {
1213

1314
const PowerSource: FunctionComponent<PowerSourceProps> = ({ device, deviceState, showLevel, ...rest }) => {
1415
const { t } = useTranslation('zigbee');
15-
let source: string | undefined = undefined;
16+
let source: PowerSource | undefined = undefined;
1617

1718
if (device !== undefined) {
1819
source = device.power_source;
@@ -94,8 +95,8 @@ const PowerSource: FunctionComponent<PowerSourceProps> = ({ device, deviceState,
9495
<i className={`fa ${batteryClass}`} title={title} {...rest} />
9596
</Fragment>
9697
);
97-
9898
case 'Mains (single phase)':
99+
case 'Mains (3 phase)':
99100
case 'DC Source':
100101
return (
101102
<i
@@ -104,7 +105,20 @@ const PowerSource: FunctionComponent<PowerSourceProps> = ({ device, deviceState,
104105
{...rest}
105106
/>
106107
);
108+
case 'Emergency mains and transfer switch':
109+
case 'Emergency mains constantly powered':
110+
return (
111+
<i
112+
className={`fa fa-plug-circle-exclamation ${style.plug}`}
113+
title={t(powerSourceTypeToTranslationKey(source))}
114+
{...rest}
115+
/>
116+
);
107117
default:
118+
if (device?.type === 'GreenPower') {
119+
return <i className={`fa fa-leaf`} title={`Green`} {...rest} />;
120+
}
121+
108122
return <i className={`fa fa-question`} title={source} {...rest} />;
109123
}
110124
};

src/types.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { JSONSchema7 } from 'json-schema';
22
import { CustomClusters } from './zcl/definition/tstype';
33

4-
export type DeviceType = 'EndDevice' | 'Router' | 'Coordinator';
4+
export type DeviceType = 'Coordinator' | 'Router' | 'EndDevice' | 'Unknown' | 'GreenPower';
55
export type FriendlyName = string;
66
export type IEEEEAddress = string;
77

@@ -123,7 +123,14 @@ export interface BridgeInfo {
123123
restart_required: boolean;
124124
}
125125

126-
export type PowerSource = 'Battery' | 'Mains (single phase)' | 'DC Source';
126+
export type PowerSource =
127+
| 'Unknown'
128+
| 'Mains (single phase)'
129+
| 'Mains (3 phase)'
130+
| 'Battery'
131+
| 'DC Source'
132+
| 'Emergency mains constantly powered'
133+
| 'Emergency mains and transfer switch';
127134

128135
export type GenericFeatureType = 'numeric' | 'binary' | 'enum' | 'text' | 'list';
129136
export type CompositeFeatureType = 'fan' | 'light' | 'switch' | 'cover' | 'lock' | 'composite' | 'climate';

0 commit comments

Comments
 (0)