Skip to content

Commit 78811e0

Browse files
committed
Add basic HVAC support
1 parent a007d76 commit 78811e0

7 files changed

Lines changed: 50 additions & 0 deletions

File tree

public/locales/bg.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ views:
127127
open_alternative: отвори
128128
turn_on: включи
129129
turn_off: изключи
130+
turn_on_cooling: охлаждане
131+
turn_on_heating: отопление
130132
offline: В момента няма връзка с устройството
131133
door:
132134
locked: Заключено
@@ -140,6 +142,10 @@ views:
140142
no_access: |
141143
Нямате права за управление на осветлението. Моля, свържете се с представител на Управителния съвет на Инит Лаб на
142144
адрес us@initlab.org, за да заявите достъп.
145+
hvac:
146+
no_access: |
147+
Нямате права за управление на климатиците. Моля, свържете се с представител на Управителния съвет на Инит Лаб на
148+
адрес us@initlab.org, за да заявите достъп.
143149
navigation:
144150
view_edit: Преглед/редакция
145151
sign_in: Вход
@@ -157,6 +163,7 @@ views:
157163
members_fee: Членски внос
158164
network_devices: Мрежови устройства
159165
lights: Осветление
166+
hvac: Климатици
160167
sensors: Графики
161168
oauth_application_management: OAuth интеграция
162169
oauth_token_management: Упълномощени приложения

public/locales/en.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ views:
120120
open_alternative: open
121121
turn_on: turn on
122122
turn_off: turn off
123+
turn_on_cooling: cooling
124+
turn_on_heating: heating
123125
offline: Device is currently offline
124126
door:
125127
locked: Locked
@@ -133,6 +135,10 @@ views:
133135
no_access: |
134136
You don't have the necessary rights to control the lights. Please contact an init Lab board member at
135137
us@initlab.org to request access.
138+
hvac:
139+
no_access: |
140+
You don't have the necessary rights to control the HVACs. Please contact an init Lab board member at
141+
us@initlab.org to request access.
136142
navigation:
137143
view_edit: View/edit
138144
sign_in: Login
@@ -150,6 +156,7 @@ views:
150156
members_fee: Membership fee
151157
network_devices: Network devices
152158
lights: Lights
159+
hvac: HVAC
153160
sensors: Sensors
154161
oauth_application_management: OAuth integration
155162
oauth_token_management: Authorized applications

src/App.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Login from './pages/Login.jsx';
1313
import RequireLoggedIn from './widgets/Route/RequireLoggedIn.jsx';
1414
import ActionLog from './pages/ActionLog.jsx';
1515
import Lights from './pages/Lights.jsx';
16+
import Hvac from './pages/Hvac.jsx';
1617
import { useVariant } from './hooks/useVariant.js';
1718

1819
function App() {
@@ -36,6 +37,9 @@ function App() {
3637
<Route path="/lights" element={<RequireLoggedIn>
3738
<Lights />
3839
</RequireLoggedIn>} />
40+
<Route path="/hvac" element={<RequireLoggedIn>
41+
<Hvac />
42+
</RequireLoggedIn>} />
3943
<Route path="/sensors" element={<Sensors />} />
4044
<Route path="/action-log" element={<ActionLog />} />
4145
<Route path="/oauth-callback" element={<OauthCallback />} />

src/layout/NavBar.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ const NavBar = () => {
8282
{t('views.navigation.lights')}
8383
</Nav.Link>
8484
</RequireRole>
85+
<RequireRole roles={['board_member', 'infra']}>
86+
<Nav.Link as={NavLink} to="/hvac">
87+
<i className="fa-solid fa-fan" />{' '}
88+
{t('views.navigation.hvac')}
89+
</Nav.Link>
90+
</RequireRole>
8591
{isInitLab && <>
8692
<Nav.Link as={NavLink} to="/sensors">
8793
<i className="fa-solid fa-chart-line" />{' '}

src/pages/Hvac.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { getDeviceActions } from '../utils/device.js';
2+
import Devices from './Devices.jsx';
3+
4+
const Hvac = () => {
5+
return (<Devices deviceType="hvac" deviceActionMapper={getDeviceActions} />);
6+
};
7+
8+
export default Hvac;

src/utils/device.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export function getDeviceActions(device) {
2+
return device.supported_actions;
3+
}
4+
15
export function getDoorActions(door) {
26
const lockStatus = door?.statuses?.lock;
37
const validLockStatus = typeof lockStatus === 'string';

src/widgets/DeviceActionButton/DeviceActionButton.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ const types = {
3838
icon: 'fa-regular fa-lightbulb',
3939
},
4040
},
41+
hvac: {
42+
turn_off: {
43+
variant: 'secondary',
44+
icon: 'fa-solid fa-power-off',
45+
},
46+
turn_on_cooling: {
47+
variant: 'primary',
48+
icon: 'fa-solid fa-snowflake',
49+
},
50+
turn_on_heating: {
51+
variant: 'danger',
52+
icon: 'fa-solid fa-sun',
53+
},
54+
},
4155
};
4256
const DeviceActionButton = ({
4357
device,

0 commit comments

Comments
 (0)