rename devicedata nodes

This commit is contained in:
proddy
2020-11-28 23:33:37 +01:00
parent 5a31de24a8
commit bf65b99e7f
3 changed files with 10 additions and 10 deletions

View File

@@ -96,7 +96,7 @@ class EMSESPDevicesForm extends Component<
};
noDeviceData = () => {
return (this.state.deviceData?.deviceData || []).length === 0;
return (this.state.deviceData?.data || []).length === 0;
};
createDeviceItems() {
@@ -330,7 +330,7 @@ class EMSESPDevicesForm extends Component<
<p></p>
<Box bgcolor="info.main" p={1} mt={1} mb={1}>
<Typography variant="body1" color="initial">
{deviceData.deviceName}
{deviceData.name}
</Typography>
</Box>
{!this.noDeviceData() && (
@@ -341,14 +341,14 @@ class EMSESPDevicesForm extends Component<
>
<TableHead></TableHead>
<TableBody>
{deviceData.deviceData.map((item, i) => {
{deviceData.data.map((item, i) => {
if (i % 2) {
return null;
} else {
return (
<TableRow key={i}>
<TableCell component="th" scope="row">{deviceData.deviceData[i]}</TableCell>
<TableCell align="right">{deviceData.deviceData[i + 1]}</TableCell>
<TableCell component="th" scope="row">{deviceData.data[i]}</TableCell>
<TableCell align="right">{deviceData.data[i + 1]}</TableCell>
</TableRow>
);
}

View File

@@ -55,6 +55,6 @@ export interface EMSESPDevices {
}
export interface EMSESPDeviceData {
deviceName: string;
deviceData: string[];
name: string;
data: string[];
}

View File

@@ -677,8 +677,8 @@ void EMSESP::device_info_web(const uint8_t unique_id, JsonObject & root) {
for (const auto & emsdevice : emsdevices) {
if (emsdevice) {
if (emsdevice->unique_id() == unique_id) {
root["deviceName"] = emsdevice->to_string_short(); // can't use c_str() because of scope
JsonArray data = root.createNestedArray("deviceData");
root["name"] = emsdevice->to_string_short(); // can't use c_str() because of scope
JsonArray data = root.createNestedArray("data");
emsdevice->device_info_web(data);
return;
}
@@ -741,7 +741,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std::
for (const auto & emsdevice : emsdevices) {
if (emsdevice) {
if (emsdevice->is_device_id(device_id)) {
LOG_DEBUG(F("Updating details on already existing device ID 0x%02X"), device_id);
LOG_DEBUG(F("Updating details for already active device ID 0x%02X"), device_id);
emsdevice->product_id(product_id);
emsdevice->version(version);
// only set brand if it doesn't already exist