set up the new component for temp humidity
This commit is contained in:
parent
2edca58f7c
commit
971355d424
6 changed files with 98 additions and 7 deletions
|
|
@ -60,6 +60,7 @@ import { LineData, Point } from "charts/measurementCharts/MultiLineGraph";
|
|||
import moment, { Moment } from "moment";
|
||||
import { avg } from "utils";
|
||||
import { Airflow } from "./ComponentTypes/Airflow";
|
||||
import { TempHumidity } from "./ComponentTypes/TempHumidity";
|
||||
|
||||
const COMPONENT_TYPE_MAP = new Map<quack.ComponentType, Function>([
|
||||
[quack.ComponentType.COMPONENT_TYPE_INVALID, Invalid],
|
||||
|
|
@ -96,7 +97,8 @@ const COMPONENT_TYPE_MAP = new Map<quack.ComponentType, Function>([
|
|||
[quack.ComponentType.COMPONENT_TYPE_SEN5X, Sen5x],
|
||||
[quack.ComponentType.COMPONENT_TYPE_VIBRATION_CHAIN, VibrationCable],
|
||||
[quack.ComponentType.COMPONENT_TYPE_DRAGER_GAS_DONGLE, dragerGasDongle],
|
||||
[quack.ComponentType.COMPONENT_TYPE_AIRFLOW, Airflow]
|
||||
[quack.ComponentType.COMPONENT_TYPE_AIRFLOW, Airflow],
|
||||
[quack.ComponentType.COMPONENT_TYPE_TEMP_HUMIDITY, TempHumidity]
|
||||
]);
|
||||
|
||||
export interface Subtype {
|
||||
|
|
|
|||
85
src/pbHelpers/ComponentTypes/TempHumidity.ts
Normal file
85
src/pbHelpers/ComponentTypes/TempHumidity.ts
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
import TemperatureHumidityDarkIcon from "assets/components/temperatureHumidityDark.png";
|
||||
import TemperatureHumidityLightIcon from "assets/components/temperatureHumidityLight.png";
|
||||
import { convertedUnitMeasurement } from "models/UnitMeasurement";
|
||||
import {
|
||||
AreaChartData,
|
||||
ComponentTypeExtension,
|
||||
GraphFilters,
|
||||
LineChartData,
|
||||
simpleAreaChartData,
|
||||
simpleLineChartData,
|
||||
simpleMeasurements,
|
||||
simpleSummaries,
|
||||
Summary,
|
||||
unitMeasurementSummaries
|
||||
} from "pbHelpers/ComponentType";
|
||||
import { describeMeasurement } from "pbHelpers/MeasurementDescriber";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { quack } from "protobuf-ts/quack";
|
||||
|
||||
export function TempHumidity(subtype: number = 0): ComponentTypeExtension {
|
||||
let temperature = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_TEMPERATURE,
|
||||
quack.ComponentType.COMPONENT_TYPE_TEMP_HUMIDITY,
|
||||
subtype
|
||||
);
|
||||
let humidity = describeMeasurement(
|
||||
quack.MeasurementType.MEASUREMENT_TYPE_PERCENT,
|
||||
quack.ComponentType.COMPONENT_TYPE_TEMP_HUMIDITY,
|
||||
subtype
|
||||
);
|
||||
return {
|
||||
type: quack.ComponentType.COMPONENT_TYPE_TEMP_HUMIDITY,
|
||||
subtypes: [
|
||||
{
|
||||
key: quack.TempHumiditySubtype.TEMP_HUMIDITY_SUBTYPE_HDC302,
|
||||
value: "TEMP_HUMIDITY_SUBTYPE_HDC302",
|
||||
friendlyName: "HDC302"
|
||||
}
|
||||
],
|
||||
friendlyName: "Temperature/Humidity",
|
||||
description: "Measures the temperature and humidity",
|
||||
isController: false,
|
||||
isSource: true,
|
||||
isCalibratable: true,
|
||||
addressTypes: [quack.AddressType.ADDRESS_TYPE_I2C],
|
||||
interactionResultTypes: [],
|
||||
states: [],
|
||||
measurements: simpleMeasurements(temperature, humidity),
|
||||
measurementSummary: async function(measurement: quack.Measurement): Promise<Array<Summary>> {
|
||||
return simpleSummaries(measurement, temperature, humidity);
|
||||
},
|
||||
unitMeasurementSummary: (
|
||||
measurements: convertedUnitMeasurement
|
||||
): Summary[] => {
|
||||
return unitMeasurementSummaries(
|
||||
measurements,
|
||||
quack.ComponentType.COMPONENT_TYPE_TEMP_HUMIDITY,
|
||||
subtype
|
||||
);
|
||||
},
|
||||
areaChartData: (
|
||||
measurement: pond.UnitMeasurementsForComponent,
|
||||
smoothingAverages?: number,
|
||||
filters?: GraphFilters
|
||||
): AreaChartData => {
|
||||
return simpleAreaChartData(measurement, smoothingAverages, filters);
|
||||
},
|
||||
lineChartData: (
|
||||
measurement: pond.UnitMeasurementsForComponent,
|
||||
smoothingAverages?: number,
|
||||
filters?: GraphFilters
|
||||
): LineChartData => {
|
||||
return simpleLineChartData(
|
||||
quack.ComponentType.COMPONENT_TYPE_TEMP_HUMIDITY,
|
||||
measurement,
|
||||
smoothingAverages,
|
||||
filters
|
||||
);
|
||||
},
|
||||
minMeasurementPeriodMs: 1000,
|
||||
icon: (theme?: "light" | "dark"): string | undefined => {
|
||||
return theme === "light" ? TemperatureHumidityDarkIcon : TemperatureHumidityLightIcon;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -64,7 +64,8 @@ const DefaultAvailability: DeviceAvailabilityMap = new Map<quack.AddressType, De
|
|||
[quack.ComponentType.COMPONENT_TYPE_SEN5X, [0x69]],
|
||||
[quack.ComponentType.COMPONENT_TYPE_AIRFLOW, [0x6c]],
|
||||
[quack.ComponentType.COMPONENT_TYPE_GRAIN_CABLE, [0x71]], // the address cables will use when they are plugged into the expander with V2 device only
|
||||
[quack.ComponentType.COMPONENT_TYPE_DRAGER_GAS_DONGLE, [0x6d]]
|
||||
[quack.ComponentType.COMPONENT_TYPE_DRAGER_GAS_DONGLE, [0x6d]],
|
||||
[quack.ComponentType.COMPONENT_TYPE_TEMP_HUMIDITY, [0x44]]
|
||||
])
|
||||
],
|
||||
[quack.AddressType.ADDRESS_TYPE_DAC, [0, 1]],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue