hoffmation-base 3.8.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/action/index.d.ts +1 -0
- package/lib/action/index.js +3 -1
- package/lib/action/soilSensorChangeAction.d.ts +16 -0
- package/lib/action/soilSensorChangeAction.js +15 -0
- package/lib/devices/dachs/dachs.d.ts +79 -2
- package/lib/devices/dachs/dachs.js +214 -18
- package/lib/devices/device-cluster.js +7 -0
- package/lib/devices/devices.d.ts +36 -1
- package/lib/devices/devices.js +67 -0
- package/lib/devices/jsObject/jsObjectEnergyManager.d.ts +16 -1
- package/lib/devices/jsObject/jsObjectEnergyManager.js +23 -0
- package/lib/devices/sharedFunctions/index.d.ts +1 -0
- package/lib/devices/sharedFunctions/index.js +1 -0
- package/lib/devices/sharedFunctions/soilSensor.d.ts +23 -0
- package/lib/devices/sharedFunctions/soilSensor.js +58 -0
- package/lib/devices/victron/victron-device.d.ts +83 -1
- package/lib/devices/victron/victron-device.js +151 -2
- package/lib/devices/victron/victron-morning-release.d.ts +16 -0
- package/lib/devices/victron/victron-morning-release.js +2 -0
- package/lib/devices/zigbee/BaseDevices/index.d.ts +1 -0
- package/lib/devices/zigbee/BaseDevices/index.js +1 -0
- package/lib/devices/zigbee/BaseDevices/zigbeeSoilSensor.d.ts +33 -0
- package/lib/devices/zigbee/BaseDevices/zigbeeSoilSensor.js +62 -0
- package/lib/devices/zigbee/index.d.ts +1 -0
- package/lib/devices/zigbee/index.js +1 -0
- package/lib/devices/zigbee/zigbeeCooloSoilSensor.d.ts +44 -0
- package/lib/devices/zigbee/zigbeeCooloSoilSensor.js +81 -0
- package/lib/enums/DeviceCapability.d.ts +2 -0
- package/lib/enums/DeviceCapability.js +2 -0
- package/lib/enums/commandType.d.ts +1 -0
- package/lib/enums/commandType.js +1 -0
- package/lib/enums/device-cluster-type.d.ts +2 -1
- package/lib/enums/device-cluster-type.js +1 -0
- package/lib/enums/deviceType.d.ts +1 -0
- package/lib/enums/deviceType.js +1 -0
- package/lib/interfaces/baseDevices/iAirQualityCollector.d.ts +2 -1
- package/lib/interfaces/baseDevices/iAirQualityReadings.d.ts +50 -0
- package/lib/interfaces/baseDevices/iAirQualityReadings.js +2 -0
- package/lib/interfaces/baseDevices/iAirQualitySensor.d.ts +1 -54
- package/lib/interfaces/baseDevices/iAirQualitySensor.js +0 -5
- package/lib/interfaces/baseDevices/iEnergyManager.d.ts +43 -0
- package/lib/interfaces/baseDevices/iHumidityCollector.d.ts +0 -1
- package/lib/interfaces/baseDevices/iHumidityCollector.js +0 -2
- package/lib/interfaces/baseDevices/iSoilCollector.d.ts +23 -0
- package/lib/interfaces/baseDevices/iSoilCollector.js +2 -0
- package/lib/interfaces/baseDevices/iSoilSensor.d.ts +32 -0
- package/lib/interfaces/baseDevices/iSoilSensor.js +2 -0
- package/lib/interfaces/baseDevices/iTemperatureCollector.d.ts +0 -1
- package/lib/interfaces/baseDevices/iTemperatureCollector.js +0 -2
- package/lib/interfaces/baseDevices/index.d.ts +7 -0
- package/lib/interfaces/baseDevices/index.js +7 -0
- package/lib/interfaces/baseDevices/undefinedAirQualityValue.d.ts +4 -0
- package/lib/interfaces/baseDevices/undefinedAirQualityValue.js +7 -0
- package/lib/interfaces/baseDevices/undefinedHumidityValue.d.ts +4 -0
- package/lib/interfaces/baseDevices/undefinedHumidityValue.js +7 -0
- package/lib/interfaces/baseDevices/undefinedSoilMoistureValue.d.ts +6 -0
- package/lib/interfaces/baseDevices/undefinedSoilMoistureValue.js +9 -0
- package/lib/interfaces/baseDevices/undefinedTempValue.d.ts +4 -0
- package/lib/interfaces/baseDevices/undefinedTempValue.js +7 -0
- package/lib/interfaces/dachs/KeyListEntity.d.ts +0 -5
- package/lib/interfaces/dachs/KeyListEntityResponse.d.ts +6 -0
- package/lib/interfaces/dachs/KeyListEntityResponse.js +2 -0
- package/lib/interfaces/dachs/index.d.ts +1 -0
- package/lib/interfaces/dachs/index.js +1 -0
- package/lib/interfaces/deviceSettings/iDachsDeviceSettings.d.ts +15 -0
- package/lib/interfaces/iActuatorStateSample.d.ts +13 -0
- package/lib/interfaces/iActuatorStateSample.js +2 -0
- package/lib/interfaces/iBatteryLevelSample.d.ts +13 -0
- package/lib/interfaces/iBatteryLevelSample.js +2 -0
- package/lib/interfaces/iConsumptionWindowSample.d.ts +26 -0
- package/lib/interfaces/iConsumptionWindowSample.js +2 -0
- package/lib/interfaces/iDachsHistoryGateResult.d.ts +29 -0
- package/lib/interfaces/iDachsHistoryGateResult.js +2 -0
- package/lib/interfaces/iEnergyHistoryBasis.d.ts +26 -0
- package/lib/interfaces/iEnergyHistoryBasis.js +2 -0
- package/lib/interfaces/iEnergyHistoryEstimate.d.ts +21 -0
- package/lib/interfaces/iEnergyHistoryEstimate.js +2 -0
- package/lib/interfaces/iEnergyHistoryFeatures.d.ts +21 -0
- package/lib/interfaces/iEnergyHistoryFeatures.js +2 -0
- package/lib/interfaces/iEnergyHistoryModel.d.ts +21 -0
- package/lib/interfaces/iEnergyHistoryModel.js +2 -0
- package/lib/interfaces/iEnergyHistoryOptions.d.ts +29 -0
- package/lib/interfaces/iEnergyHistoryOptions.js +2 -0
- package/lib/interfaces/iEnergyHistoryOutlook.d.ts +41 -0
- package/lib/interfaces/iEnergyHistoryOutlook.js +2 -0
- package/lib/interfaces/iEnergyHistorySample.d.ts +19 -0
- package/lib/interfaces/iEnergyHistorySample.js +2 -0
- package/lib/interfaces/iFossilGeneratorRun.d.ts +22 -0
- package/lib/interfaces/iFossilGeneratorRun.js +2 -0
- package/lib/interfaces/iFossilGeneratorSource.d.ts +21 -0
- package/lib/interfaces/iFossilGeneratorSource.js +2 -0
- package/lib/interfaces/iMorningReserveVerdict.d.ts +38 -0
- package/lib/interfaces/iMorningReserveVerdict.js +2 -0
- package/lib/interfaces/iPersist.d.ts +69 -1
- package/lib/interfaces/iProjectedSocBand.d.ts +7 -0
- package/lib/interfaces/iProjectedSocBand.js +2 -0
- package/lib/interfaces/iSoilMoistureSample.d.ts +13 -0
- package/lib/interfaces/iSoilMoistureSample.js +2 -0
- package/lib/interfaces/iWeatherDaySummary.d.ts +33 -0
- package/lib/interfaces/iWeatherDaySummary.js +2 -0
- package/lib/interfaces/index.d.ts +17 -0
- package/lib/interfaces/index.js +17 -0
- package/lib/services/dbo/actuator-state-row.d.ts +14 -0
- package/lib/services/dbo/actuator-state-row.js +2 -0
- package/lib/services/dbo/battery-level-row.d.ts +16 -0
- package/lib/services/dbo/battery-level-row.js +2 -0
- package/lib/services/dbo/energy-consumption-row.d.ts +16 -0
- package/lib/services/dbo/energy-consumption-row.js +2 -0
- package/lib/services/dbo/postgreSqlPersist.d.ts +52 -1
- package/lib/services/dbo/postgreSqlPersist.js +392 -27
- package/lib/services/dbo/soil-moisture-row.d.ts +14 -0
- package/lib/services/dbo/soil-moisture-row.js +2 -0
- package/lib/services/dbo/weather-day-summary-row.d.ts +20 -0
- package/lib/services/dbo/weather-day-summary-row.js +2 -0
- package/lib/services/energy/energy-history-service.d.ts +168 -0
- package/lib/services/energy/energy-history-service.js +499 -0
- package/lib/services/energy/index.d.ts +1 -0
- package/lib/services/energy/index.js +17 -0
- package/lib/services/energy/plant-energy-dials.d.ts +22 -0
- package/lib/services/energy/plant-energy-dials.js +2 -0
- package/lib/services/https-service.d.ts +48 -2
- package/lib/services/https-service.js +136 -10
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.js +1 -0
- package/lib/services/time-callback-service.d.ts +12 -0
- package/lib/services/time-callback-service.js +16 -2
- package/lib/services/weather/index.d.ts +1 -0
- package/lib/services/weather/index.js +1 -0
- package/lib/services/weather/open-weather-day-summary.d.ts +25 -0
- package/lib/services/weather/open-weather-day-summary.js +2 -0
- package/lib/services/weather/weather-day-summary-fetcher.d.ts +6 -0
- package/lib/services/weather/weather-day-summary-fetcher.js +2 -0
- package/lib/services/weather/weather-history-backfill.d.ts +94 -0
- package/lib/services/weather/weather-history-backfill.js +247 -0
- package/lib/services/weather/weather-service.js +29 -4
- package/lib/settings-service-instance.js +5 -2
- package/lib/settingsObjects/deviceSettings/dachsSettings.d.ts +6 -0
- package/lib/settingsObjects/deviceSettings/dachsSettings.js +14 -1
- package/lib/settingsObjects/deviceSettings/victronDeviceSettings.d.ts +116 -0
- package/lib/settingsObjects/deviceSettings/victronDeviceSettings.js +150 -5
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/dayMs.d.ts +7 -0
- package/lib/utils/dayMs.js +10 -0
- package/lib/utils/energy-history-dials.d.ts +19 -0
- package/lib/utils/energy-history-dials.js +2 -0
- package/lib/utils/energy-history-utils.d.ts +143 -0
- package/lib/utils/energy-history-utils.js +470 -0
- package/lib/utils/energy-manager-utils.d.ts +123 -1
- package/lib/utils/energy-manager-utils.js +226 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +4 -0
- package/lib/utils/model-shadow.d.ts +61 -0
- package/lib/utils/model-shadow.js +83 -0
- package/lib/utils/morning-reserve-dials.d.ts +21 -0
- package/lib/utils/morning-reserve-dials.js +2 -0
- package/lib/utils/morning-verdict.d.ts +5 -0
- package/lib/utils/morning-verdict.js +2 -0
- package/lib/utils/utils.d.ts +0 -1
- package/lib/utils/utils.js +5 -5
- package/package.json +3 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The raw shape the driver hands back for a stored battery level.
|
|
3
|
+
*
|
|
4
|
+
* Numeric columns arrive as a number or a string depending on their postgres type, so they are converted
|
|
5
|
+
* rather than passed through. The timestamp column is `timestamp without time zone` and therefore a Date built
|
|
6
|
+
* from naive components. It is deliberately not typed as `string | Date`: the driver never hands a string back
|
|
7
|
+
* for that column, and pretending otherwise is what hid a timezone offset for a long time.
|
|
8
|
+
*
|
|
9
|
+
* Not part of the published surface - a database row shape is not an interface anyone implements.
|
|
10
|
+
*/
|
|
11
|
+
export type BatteryLevelRow = {
|
|
12
|
+
/** The stored state of charge, as the driver hands it back */
|
|
13
|
+
batteryLevel: string | number | null;
|
|
14
|
+
/** End of the interval the reading closes, built from naive components */
|
|
15
|
+
endDate: Date | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The raw shape the driver hands back for one stored energy calculation interval.
|
|
3
|
+
*
|
|
4
|
+
* Same conversion rules as {@link BatteryLevelRow}: numeric columns may arrive as a string, and the timestamp
|
|
5
|
+
* is a Date built from naive components because the column carries no zone.
|
|
6
|
+
*
|
|
7
|
+
* Not part of the published surface - a database row shape is not an interface anyone implements.
|
|
8
|
+
*/
|
|
9
|
+
export type EnergyConsumptionRow = {
|
|
10
|
+
/** Energy the house took from its own production over the interval, in kWh */
|
|
11
|
+
selfConsumedKwH: string | number | null;
|
|
12
|
+
/** Energy the house took from the grid over the interval, in kWh */
|
|
13
|
+
drawnKwH: string | number | null;
|
|
14
|
+
/** End of the interval the reading closes, built from naive components */
|
|
15
|
+
endDate: Date | null;
|
|
16
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PoolConfig } from 'pg';
|
|
2
|
-
import { iAcDevice, iActuator, iBaseDevice, iBatteryDevice, iButtonSwitch, iDesiredShutterPosition, iHandle, iHeater, iAirQualityCollector, iHumidityCollector, iIlluminationSensor, iMotionSensor, iPersist, iRoomBase, iShutter, iShutterCalibration, iTemperatureCollector, iTemperatureMeasurement, iZigbeeDevice } from '../../interfaces';
|
|
2
|
+
import { iAcDevice, iActuator, iActuatorStateSample, iBaseDevice, iBatteryDevice, iBatteryLevelSample, iButtonSwitch, iConsumptionWindowSample, iDesiredShutterPosition, iHandle, iHeater, iAirQualityCollector, iHumidityCollector, iIlluminationSensor, iMotionSensor, iPersist, iRoomBase, iShutter, iShutterCalibration, iSoilCollector, iSoilMoistureSample, iTemperatureCollector, iTemperatureMeasurement, iWeatherDaySummary, iZigbeeDevice } from '../../interfaces';
|
|
3
3
|
import { CountToday, EnergyCalculation } from '../../models';
|
|
4
4
|
import { ButtonPressType } from '../../enums';
|
|
5
5
|
export declare class PostgreSqlPersist implements iPersist {
|
|
@@ -22,6 +22,16 @@ export declare class PostgreSqlPersist implements iPersist {
|
|
|
22
22
|
/** @inheritDoc */
|
|
23
23
|
getTemperatureHistory(deviceId: string, startDate?: Date, endDate?: Date): Promise<iTemperatureMeasurement[]>;
|
|
24
24
|
/** @inheritDoc */
|
|
25
|
+
getBatteryLevelHistory(startDate: Date, endDate: Date): Promise<iBatteryLevelSample[]>;
|
|
26
|
+
/** @inheritDoc */
|
|
27
|
+
getEnergyConsumptionHistory(startDate: Date, endDate: Date): Promise<iConsumptionWindowSample[]>;
|
|
28
|
+
/** @inheritDoc */
|
|
29
|
+
getActuatorHistory(deviceId: string, startDate: Date, endDate: Date): Promise<iActuatorStateSample[]>;
|
|
30
|
+
/** @inheritDoc */
|
|
31
|
+
getWeatherDaySummaries(startDate: Date, endDate: Date): Promise<iWeatherDaySummary[]>;
|
|
32
|
+
/** @inheritDoc */
|
|
33
|
+
persistWeatherDaySummary(summary: iWeatherDaySummary): void;
|
|
34
|
+
/** @inheritDoc */
|
|
25
35
|
initialize(): Promise<void>;
|
|
26
36
|
/** @inheritDoc */
|
|
27
37
|
persistAC(device: iAcDevice): void;
|
|
@@ -44,6 +54,10 @@ export declare class PostgreSqlPersist implements iPersist {
|
|
|
44
54
|
/** @inheritDoc */
|
|
45
55
|
persistAirQualitySensor(device: iAirQualityCollector): void;
|
|
46
56
|
/** @inheritDoc */
|
|
57
|
+
persistSoilSensor(device: iSoilCollector): void;
|
|
58
|
+
/** @inheritDoc */
|
|
59
|
+
getSoilMoistureHistory(deviceId: string, startDate: Date, endDate: Date): Promise<iSoilMoistureSample[]>;
|
|
60
|
+
/** @inheritDoc */
|
|
47
61
|
persistBatteryDevice(device: iBatteryDevice): void;
|
|
48
62
|
/** @inheritDoc */
|
|
49
63
|
persistZigbeeDevice(device: iZigbeeDevice): void;
|
|
@@ -57,6 +71,43 @@ export declare class PostgreSqlPersist implements iPersist {
|
|
|
57
71
|
persistSettings(id: string, settings: string, customName: string): void;
|
|
58
72
|
/** @inheritDoc */
|
|
59
73
|
loadSettings(id: string): Promise<string | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* Runs a statement, optionally with bind values.
|
|
76
|
+
*
|
|
77
|
+
* `values` is what makes a statement able to carry data that did not come from this process: the driver
|
|
78
|
+
* sends text and values apart, so a value is never parsed as SQL, whatever it spells. Anything that is not
|
|
79
|
+
* a literal fixed by this file belongs in there rather than in the string.
|
|
80
|
+
* @param query - The statement, with `$1..$n` where values are bound
|
|
81
|
+
* @param values - The values to bind, in the order of their placeholders
|
|
82
|
+
* @returns - The rows, or null when the statement did not come back
|
|
83
|
+
*/
|
|
60
84
|
private query;
|
|
85
|
+
/**
|
|
86
|
+
* A missing or unreadable history is a defined state of the history based decisions, not a failure - but it
|
|
87
|
+
* has to be visible once, otherwise "no answer" and "nothing recorded" look the same from the outside.
|
|
88
|
+
* @param reader - The reader that came up empty
|
|
89
|
+
* @param dbResult - null when the query itself did not come back, an empty set otherwise
|
|
90
|
+
* @param startDate - Start of the requested window
|
|
91
|
+
* @param endDate - End of the requested window
|
|
92
|
+
*/
|
|
93
|
+
private static logEmptyAnswer;
|
|
94
|
+
private static logDroppedRows;
|
|
95
|
+
/**
|
|
96
|
+
* Turns what the driver made of a `timestamp without time zone` back into the instant it was stored for.
|
|
97
|
+
*
|
|
98
|
+
* The write path stores `new Date(...).toISOString()`. For a naive column PostgreSQL silently drops the
|
|
99
|
+
* zone suffix of the literal and keeps the UTC wall clock. Reading it back, the driver rebuilds those
|
|
100
|
+
* components with the **local** multi argument Date constructor (`postgres-date/index.js:49-50`, registered
|
|
101
|
+
* for OID 1114 in `pg-types/lib/textParsers.js:175`), so the Date is off by the machine's zone offset - one
|
|
102
|
+
* hour or two in Berlin, and the offset changes inside a single 90 day window at the daylight saving
|
|
103
|
+
* switch. Reading the local components back out as UTC undoes exactly that.
|
|
104
|
+
*
|
|
105
|
+
* Only the read side compensates: `toISOString()` already stores the UTC wall clock and three years of
|
|
106
|
+
* recorded history are written that way, so changing the write path would put old and new rows at odds.
|
|
107
|
+
* @param value - The Date the driver produced, or null for an absent timestamp
|
|
108
|
+
* @returns - The instant, or undefined when there is none to be had
|
|
109
|
+
*/
|
|
110
|
+
private static fromNaiveTimestamp;
|
|
111
|
+
private static toFiniteNumber;
|
|
61
112
|
private isPsqlReady;
|
|
62
113
|
}
|