Forward browser_id in service calls from frontend

This commit is contained in:
Thomas Lovén 2022-07-25 00:00:02 +00:00
parent 23cbdaef2d
commit 8dbd00aa0f
4 changed files with 22 additions and 8 deletions

View File

@ -1015,10 +1015,14 @@ const ServicesMixin = (SuperClass) => {
}
async _service_action({ service, data }) {
let _service = service;
if (!_service.startsWith("browser_mod.") && _service.includes(".")) {
if ((!_service.startsWith("browser_mod.") && _service.includes(".")) ||
data.browser_id !== undefined) {
const d = Object.assign({}, data);
if (d.browser_id === "THIS")
d.browser_id = this.browserID;
// CALL HOME ASSISTANT SERVICE
const [domain, srv] = _service.split(".");
return this.hass.callService(domain, srv, data);
return this.hass.callService(domain, srv, d);
}
if (_service.startsWith("browser_mod.")) {
_service = _service.substring(12);
@ -2101,8 +2105,8 @@ const BrowserIDMixin = (SuperClass) => {
x Information about interaction requirement
x Information about fullykiosk
- Commands
- Change targets from the frontend
- Send browser ID to the backend in service calls?
x Change targets from the frontend
x Send browser ID to the backend in service calls?
x Rename browser_mod commands to browser_mod services
x Framework
x ll-custom handling

View File

@ -32,8 +32,8 @@ import { BrowserIDMixin } from "./browserID";
x Information about interaction requirement
x Information about fullykiosk
- Commands
- Change targets from the frontend
- Send browser ID to the backend in service calls?
x Change targets from the frontend
x Send browser ID to the backend in service calls?
x Rename browser_mod commands to browser_mod services
x Framework
x ll-custom handling

View File

@ -95,10 +95,15 @@ export const ServicesMixin = (SuperClass) => {
async _service_action({ service, data }) {
let _service: String = service;
if (!_service.startsWith("browser_mod.") && _service.includes(".")) {
if (
(!_service.startsWith("browser_mod.") && _service.includes(".")) ||
data.browser_id !== undefined
) {
const d = { ...data };
if (d.browser_id === "THIS") d.browser_id = this.browserID;
// CALL HOME ASSISTANT SERVICE
const [domain, srv] = _service.split(".");
return this.hass.callService(domain, srv, data);
return this.hass.callService(domain, srv, d);
}
if (_service.startsWith("browser_mod.")) {

View File

@ -52,3 +52,8 @@ script:
cm_debug:
sequence:
- service: browser_mod.debug
print_id:
sequence:
- service: system_log.write
data:
message: "Button was clicked in {{browser_id}}."