File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import ErrorMessage from '../widgets/ErrorMessage.jsx';
1010import { useVariant } from '../hooks/useVariant.js' ;
1111
1212const Devices = ( {
13- deviceType ,
13+ deviceGroup ,
1414 deviceActionMapper,
1515} ) => {
1616 const { t } = useTranslation ( ) ;
@@ -24,7 +24,7 @@ const Devices = ({
2424 } ) ;
2525
2626 const filteredDevices = useMemo ( ( ) =>
27- devices ? devices . filter ( device => device . type === deviceType ) : [ ] , [ deviceType , devices ] ) ;
27+ devices ? devices . filter ( device => device . group === deviceGroup ) : [ ] , [ deviceGroup , devices ] ) ;
2828
2929 const variant = useVariant ( ) ;
3030 const isInitLab = variant === 'initlab' ;
@@ -58,7 +58,7 @@ const Devices = ({
5858 } ) : < Col >
5959 < Card >
6060 < Card . Body className = "d-flex flex-column flex-lg-row gap-4" >
61- { t ( 'views.' + deviceType + '.no_access' ) }
61+ { t ( 'views.' + deviceGroup + '.no_access' ) }
6262 </ Card . Body >
6363 </ Card >
6464 </ Col > }
@@ -70,7 +70,7 @@ const Devices = ({
7070} ;
7171
7272Devices . propTypes = {
73- deviceType : PropTypes . string . isRequired ,
73+ deviceGroup : PropTypes . string . isRequired ,
7474 deviceActionMapper : PropTypes . func . isRequired ,
7575} ;
7676
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { getDoorActions } from '../utils/device.js';
22import Devices from './Devices.jsx' ;
33
44const Doors = ( ) => {
5- return ( < Devices deviceType = "door" deviceActionMapper = { getDoorActions } /> ) ;
5+ return ( < Devices deviceGroup = "door" deviceActionMapper = { getDoorActions } /> ) ;
66} ;
77
88export default Doors ;
Original file line number Diff line number Diff line change 1- import { getDeviceActions } from '../utils/device.js' ;
1+ import { getHvacActions } from '../utils/device.js' ;
22import Devices from './Devices.jsx' ;
33
44const Hvac = ( ) => {
5- return ( < Devices deviceType = "hvac" deviceActionMapper = { getDeviceActions } /> ) ;
5+ return ( < Devices deviceGroup = "hvac" deviceActionMapper = { getHvacActions } /> ) ;
66} ;
77
88export default Hvac ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { getLightActions } from '../utils/device.js';
22import Devices from './Devices.jsx' ;
33
44const Lights = ( ) => {
5- return ( < Devices deviceType = "light" deviceActionMapper = { getLightActions } /> ) ;
5+ return ( < Devices deviceGroup = "light" deviceActionMapper = { getLightActions } /> ) ;
66} ;
77
88export default Lights ;
Original file line number Diff line number Diff line change @@ -42,3 +42,11 @@ export function getLightActions(light) {
4242
4343 return actions . filter ( action => action !== ( activityStatus ? 'turn_on' : 'turn_off' ) ) ;
4444}
45+
46+ export function getHvacActions ( device ) {
47+ if ( device . type === 'switch' ) {
48+ return getLightActions ( device ) ;
49+ }
50+
51+ return getDeviceActions ( device ) ;
52+ }
You can’t perform that action at this time.
0 commit comments