@digital-alchemy/hass 24.9.1 → 24.9.2
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/dist/extensions/call-proxy.extension.js +14 -8
- package/dist/extensions/call-proxy.extension.js.map +1 -1
- package/dist/helpers/fetch/index.d.ts +1 -0
- package/dist/helpers/fetch/index.js +1 -0
- package/dist/helpers/fetch/index.js.map +1 -1
- package/dist/helpers/fetch/weather-forecasts.d.ts +68 -0
- package/dist/helpers/fetch/weather-forecasts.js +4 -0
- package/dist/helpers/fetch/weather-forecasts.js.map +1 -0
- package/package.json +3 -3
|
@@ -29,14 +29,10 @@ function CallProxy({ logger, lifecycle, internal, hass, config, }) {
|
|
|
29
29
|
key,
|
|
30
30
|
async (parameters) => {
|
|
31
31
|
const data = value.services[key];
|
|
32
|
-
if (core_1.is.boolean(data?.response?.optional)) {
|
|
33
|
-
// https://github.com/Digital-Alchemy-TS/hass/issues/34
|
|
34
|
-
logger.warn(`calling services with responses not supported`);
|
|
35
|
-
}
|
|
36
32
|
const service = `${value.domain}.${key}`;
|
|
37
|
-
await sendMessage(service, {
|
|
33
|
+
return await sendMessage(service, {
|
|
38
34
|
...parameters,
|
|
39
|
-
});
|
|
35
|
+
}, core_1.is.boolean(data?.response?.optional));
|
|
40
36
|
},
|
|
41
37
|
]));
|
|
42
38
|
logger.trace({ name: loadServiceList, services }, `loaded domain [%s]`, value.domain);
|
|
@@ -45,7 +41,7 @@ function CallProxy({ logger, lifecycle, internal, hass, config, }) {
|
|
|
45
41
|
/**
|
|
46
42
|
* Prefer sending via socket, if available.
|
|
47
43
|
*/
|
|
48
|
-
async function sendMessage(serviceName, service_data) {
|
|
44
|
+
async function sendMessage(serviceName, service_data, return_response) {
|
|
49
45
|
// pause for rest also
|
|
50
46
|
if (hass.socket.pauseMessages) {
|
|
51
47
|
return undefined;
|
|
@@ -53,13 +49,23 @@ function CallProxy({ logger, lifecycle, internal, hass, config, }) {
|
|
|
53
49
|
const sendViaRest = (config.hass.CALL_PROXY_ALLOW_REST === "allow" &&
|
|
54
50
|
hass.socket.connectionState !== "connected") ||
|
|
55
51
|
config.hass.CALL_PROXY_ALLOW_REST === "prefer";
|
|
52
|
+
if (sendViaRest && return_response) {
|
|
53
|
+
// See https://github.com/home-assistant/core/issues/106379#issuecomment-1878548124 for the reason for this warning
|
|
54
|
+
logger.warn({ name: sendMessage }, "Services that require a return_response are not allowed to be sent via REST, they must use WebSockets");
|
|
55
|
+
}
|
|
56
56
|
if (sendViaRest) {
|
|
57
57
|
return await hass.fetch.callService(serviceName, service_data);
|
|
58
58
|
}
|
|
59
59
|
const [domain, service] = serviceName.split(".");
|
|
60
60
|
__1.CALL_PROXY_SERVICE_CALL.labels({ domain, service }).inc();
|
|
61
61
|
// User can just not await this call if they don't care about the "waitForChange"
|
|
62
|
-
return await hass.socket.sendMessage({
|
|
62
|
+
return await hass.socket.sendMessage({
|
|
63
|
+
domain,
|
|
64
|
+
return_response,
|
|
65
|
+
service,
|
|
66
|
+
service_data,
|
|
67
|
+
type: "call_service",
|
|
68
|
+
}, true);
|
|
63
69
|
}
|
|
64
70
|
function buildCallProxy() {
|
|
65
71
|
return new Proxy(rawProxy, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-proxy.extension.js","sourceRoot":"","sources":["../../src/extensions/call-proxy.extension.ts"],"names":[],"mappings":";;AAUA,
|
|
1
|
+
{"version":3,"file":"call-proxy.extension.js","sourceRoot":"","sources":["../../src/extensions/call-proxy.extension.ts"],"names":[],"mappings":";;AAUA,8BA2IC;AArJD,gDAA2D;AAE3D,0BAMY;AAEZ,SAAgB,SAAS,CAAC,EACxB,MAAM,EACN,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,MAAM,GACS;IACf,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,QAAQ,GAAG,EAA6C,CAAC;IAC/D;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,IAA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AE;gBACtC,mCAAmC;gBACnC,sCAAsC;gBACtC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;oBACjD,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE;wBACrB,MAAM,CAAC,KAAK,CACV,0EAA0E,CAC3E,CAAC;wBACF,sCAAsC;wBACtC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;oBAC7B,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;YACD,GAAG,CAAC,CAAC,EAAE,QAAgB;gBACrB,OAAO,QAAQ,IAAI,QAAQ,CAAC;YAC9B,CAAC;YACD,OAAO;gBACL,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/B,CAAC;YACD,GAAG;gBACD,UAAU;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,cAAc,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -5,4 +5,5 @@ tslib_1.__exportStar(require("./calendar"), exports);
|
|
|
5
5
|
tslib_1.__exportStar(require("./configuration"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./server-log"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./service-list"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./weather-forecasts"), exports);
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/fetch/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,0DAAgC;AAChC,uDAA6B;AAC7B,yDAA+B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/fetch/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,0DAAgC;AAChC,uDAA6B;AAC7B,yDAA+B;AAC/B,8DAAoC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type WeatherCondition = "clear-night" | "cloudy" | "fog" | "hail" | "lightning" | "lightning-rainy" | "partlycloudy" | "pouring" | "rainy" | "snowy" | "snowy-rainy" | "sunny" | "windy" | "windy-variant" | "exceptional";
|
|
2
|
+
export interface WeatherGetForecasts {
|
|
3
|
+
/**
|
|
4
|
+
* Time of the forecasted conditions.
|
|
5
|
+
* Format is YYYY-MM-DDTHH:mm:ss+zz:zz
|
|
6
|
+
*/
|
|
7
|
+
datetime: string;
|
|
8
|
+
/**
|
|
9
|
+
* Only set for `twice_daily` forecasts
|
|
10
|
+
*/
|
|
11
|
+
is_daytime: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The apparent (feels-like) temperature in the unit indicated by the `temperature_unite` state attribute.
|
|
14
|
+
*/
|
|
15
|
+
apparent_temperature: number;
|
|
16
|
+
/**
|
|
17
|
+
* The cloud coverage in %.
|
|
18
|
+
*/
|
|
19
|
+
cloud_coverage: number;
|
|
20
|
+
/**
|
|
21
|
+
* The weather condition
|
|
22
|
+
*/
|
|
23
|
+
condition: WeatherCondition;
|
|
24
|
+
/**
|
|
25
|
+
* The dew point temperature in the unit indicated by the `temperature_unite` state attribute.
|
|
26
|
+
*/
|
|
27
|
+
dew_point: number;
|
|
28
|
+
/**
|
|
29
|
+
* The relative humidity in %.
|
|
30
|
+
*/
|
|
31
|
+
humidity: number;
|
|
32
|
+
/**
|
|
33
|
+
* The probability of precipitation in %;
|
|
34
|
+
*/
|
|
35
|
+
precipitation_probability: number;
|
|
36
|
+
/**
|
|
37
|
+
* The precipitation amount in the unit indicated by the `precipitation_unit` state attribute.
|
|
38
|
+
*/
|
|
39
|
+
precipitation: number;
|
|
40
|
+
/**
|
|
41
|
+
* The air pressure in the unit indicated by the `pressure_unit` state attribute.
|
|
42
|
+
*/
|
|
43
|
+
pressure: number;
|
|
44
|
+
/**
|
|
45
|
+
* The temperature in the unit indicated by the `temperature_unite` state attribute. If `templow` is also provided this is the higher temperature.
|
|
46
|
+
*/
|
|
47
|
+
temperature: number;
|
|
48
|
+
/**
|
|
49
|
+
* The lower temperature in the unit indicated by the `temperature_unite` state attribute.
|
|
50
|
+
*/
|
|
51
|
+
templow: number;
|
|
52
|
+
/**
|
|
53
|
+
* The UV index.
|
|
54
|
+
*/
|
|
55
|
+
uv_index: number;
|
|
56
|
+
/**
|
|
57
|
+
* The wind bearing in azimuth angle (degrees) or 1-3 letter cardinal direction
|
|
58
|
+
*/
|
|
59
|
+
wind_bearing: number | string;
|
|
60
|
+
/**
|
|
61
|
+
* The wind gust speed in the unit indicated by the `wind_speed_unit` state attribute.
|
|
62
|
+
*/
|
|
63
|
+
wind_gust_speed: number;
|
|
64
|
+
/**
|
|
65
|
+
* The wind speed in the unit indicated by the `wind_speed_unit` state attribute.
|
|
66
|
+
*/
|
|
67
|
+
wind_speed: number;
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weather-forecasts.js","sourceRoot":"","sources":["../../../src/helpers/fetch/weather-forecasts.ts"],"names":[],"mappings":";AAAA,6FAA6F"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@digital-alchemy/hass",
|
|
3
3
|
"repository": "https://github.com/Digital-Alchemy-TS/hass",
|
|
4
4
|
"homepage": "https://docs.digital-alchemy.app",
|
|
5
|
-
"version": "24.9.
|
|
5
|
+
"version": "24.9.2",
|
|
6
6
|
"description": "Typescript APIs for Home Assistant. Includes rest & websocket bindings",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rm -rf dist/; tsc",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@cspell/eslint-plugin": "^8.8.4",
|
|
64
64
|
"@digital-alchemy/core": "^24.8.4",
|
|
65
|
-
"@digital-alchemy/synapse": "^24.
|
|
66
|
-
"@digital-alchemy/type-writer": "^24.
|
|
65
|
+
"@digital-alchemy/synapse": "^24.9.3",
|
|
66
|
+
"@digital-alchemy/type-writer": "^24.9.1",
|
|
67
67
|
"@types/figlet": "^1.5.8",
|
|
68
68
|
"@types/jest": "^29.5.12",
|
|
69
69
|
"@types/js-yaml": "^4.0.9",
|