Skip to content

Commit

Permalink
add disconnected banner to dashboard, #591
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Aug 8, 2022
1 parent 97132a4 commit d367c20
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions interface/src/project/DashboardData.tsx
Expand Up @@ -79,7 +79,7 @@ const DashboardData: FC = () => {

const { enqueueSnackbar } = useSnackbar();

const [coreData, setCoreData] = useState<CoreData>({ devices: [], active_sensors: 0, analog_enabled: false });
const [coreData, setCoreData] = useState<CoreData>({ connected: true, devices: [], active_sensors: 0, analog_enabled: false });
const [deviceData, setDeviceData] = useState<DeviceData>({ label: '', data: [] });
const [sensorData, setSensorData] = useState<SensorData>({ sensors: [], analogs: [] });
const [deviceValue, setDeviceValue] = useState<DeviceValue>();
Expand Down Expand Up @@ -640,7 +640,8 @@ const DashboardData: FC = () => {

const renderCoreData = () => (
<IconContext.Provider value={{ color: 'lightblue', size: '24', style: { verticalAlign: 'middle' } }}>
{coreData.devices.length === 0 && <MessageBox my={2} level="warning" message="Scanning for EMS devices..." />}
{!coreData.connected && <MessageBox my={2} level="error" message="EMSbus disconnected, check settings and board profile" />}
{coreData.connected && coreData.devices.length === 0 && <MessageBox my={2} level="warning" message="Scanning for EMS devices..." />}
<Table data={{ nodes: coreData.devices }} select={device_select} theme={device_theme} layout={{ custom: true }}>
{(tableList: any) => (
<>
Expand Down
1 change: 1 addition & 0 deletions interface/src/project/types.ts
Expand Up @@ -97,6 +97,7 @@ export interface SensorData {
}

export interface CoreData {
connected: boolean;
devices: Device[];
active_sensors: number;
analog_enabled: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/web/WebDataService.cpp
Expand Up @@ -94,6 +94,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) {
// sensors stuff
root["active_sensors"] = EMSESP::dallassensor_.no_sensors() + (EMSESP::analogsensor_.analog_enabled() ? EMSESP::analogsensor_.no_sensors() : 0);
root["analog_enabled"] = EMSESP::analogsensor_.analog_enabled();
root["connected"] = EMSESP::bus_status() != 2;

response->setLength();
request->send(response);
Expand Down

0 comments on commit d367c20

Please sign in to comment.