mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
updates #3
This commit is contained in:
@@ -43,7 +43,7 @@ import { formatValue } from './deviceValue';
|
||||
|
||||
import { DeviceValueUOM_s, DeviceEntityMask, DeviceType } from './types';
|
||||
import { deviceValueItemValidation } from './validators';
|
||||
import type { Device, CoreData, DeviceData, DeviceValue } from './types';
|
||||
import type { Device, DeviceValue } from './types';
|
||||
import type { FC } from 'react';
|
||||
import { ButtonRow, SectionContent, MessageBox } from 'components';
|
||||
import { AuthenticatedContext } from 'contexts/authentication';
|
||||
@@ -74,10 +74,9 @@ const DashboardDevices: FC = () => {
|
||||
devices: []
|
||||
},
|
||||
force: true,
|
||||
immediate: false
|
||||
immediate: true
|
||||
});
|
||||
|
||||
// TODO prevent firing when page is loaded
|
||||
const { data: deviceData, send: readDeviceData } = useRequest((id) => EMSESP.readDeviceData(id), {
|
||||
initialData: {
|
||||
data: []
|
||||
@@ -86,7 +85,6 @@ const DashboardDevices: FC = () => {
|
||||
immediate: false
|
||||
});
|
||||
|
||||
// TODO prevent firing when page is loaded
|
||||
const { loading: submitting, send: writeDeviceValue } = useRequest(
|
||||
(id: number, deviceValue: DeviceValue) => EMSESP.writeDeviceValue(id, deviceValue),
|
||||
{
|
||||
@@ -251,8 +249,6 @@ const DashboardDevices: FC = () => {
|
||||
// };
|
||||
|
||||
async function onSelectChange(action: any, state: any) {
|
||||
// TODO check if still needed
|
||||
// setDeviceData({ data: [] });
|
||||
setSelectedDevice(state.id);
|
||||
if (action.type === 'ADD_BY_ID_EXCLUSIVELY') {
|
||||
await readDeviceData(state.id);
|
||||
|
||||
@@ -11,7 +11,6 @@ import type {
|
||||
DeviceEntity,
|
||||
UniqueID,
|
||||
CustomEntities,
|
||||
WriteDeviceValue,
|
||||
WriteTemperatureSensor,
|
||||
WriteAnalogSensor,
|
||||
SensorData,
|
||||
@@ -37,7 +36,9 @@ export const readDeviceData = (id: number) =>
|
||||
export const writeDeviceValue = (id: number, devicevalue: DeviceValue) =>
|
||||
alovaInstance.Post('/writeDeviceValue', { id, devicevalue });
|
||||
|
||||
// TODO to change to alova
|
||||
//
|
||||
// TODO change below to use alova
|
||||
//
|
||||
|
||||
export function restart(): AxiosPromise<void> {
|
||||
return AXIOS.post('/restart');
|
||||
|
||||
@@ -132,6 +132,7 @@ export interface DeviceValue {
|
||||
x?: number; // max, optional
|
||||
}
|
||||
|
||||
// TODO can be refacvtored to DeviceValue[]?
|
||||
export interface DeviceData {
|
||||
data: DeviceValue[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user