Skip to content

Commit dc34ed9

Browse files
authored
Version 2.3.6
2.3.6
2 parents 442174e + 99041d7 commit dc34ed9

File tree

16 files changed

+325
-57
lines changed

16 files changed

+325
-57
lines changed

custom_components/browser_mod/browser_mod.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

custom_components/browser_mod/browser_mod_panel.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,17 @@ function e(e,t,i,o){var s,n=arguments.length,r=n<3?t:null===o?o=Object.getOwnPro
416416
.settingSelector=${{boolean:{},label:"Hide interaction icon"}}
417417
></browser-mod-settings-table>
418418
</ha-expansion-panel>
419-
</div>
419+
<ha-expansion-panel
420+
.header=${"Save screen state"}
421+
.secondary=${"Save screen state when browser is disconnected"}
422+
leftChevron
423+
>
424+
<browser-mod-settings-table
425+
.hass=${this.hass}
426+
.settingKey=${"saveScreenState"}
427+
.settingSelector=${{boolean:{},label:"Save screen state"}}
428+
></browser-mod-settings-table>
429+
</ha-expansion-panel> </div>
420430
</ha-card>
421431
`}static get styles(){return r`
422432
.box {
@@ -436,7 +446,7 @@ function e(e,t,i,o){var s,n=arguments.length,r=n<3?t:null===o?o=Object.getOwnPro
436446
display: flex;
437447
align-items: center;
438448
}
439-
`}}e([le()],_e.prototype,"hass",void 0),e([de()],_e.prototype,"_dashboards",void 0),e([de()],_e.prototype,"_editSidebar",void 0),customElements.define("browser-mod-frontend-settings-card",_e);var fe="2.3.5";(async()=>{var e,t,i,o,s,n,r,a,l,d,h,c,u,p,g;await customElements.whenDefined("partial-panel-resolver");const w=document.createElement("partial-panel-resolver")._getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==w?void 0:w.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t)),await customElements.whenDefined("ha-panel-config");const v=document.createElement("ha-panel-config");await(null===(r=null===(n=null===(s=null===(o=null==v?void 0:v.routerOptions)||void 0===o?void 0:o.routes)||void 0===s?void 0:s.dashboard)||void 0===n?void 0:n.load)||void 0===r?void 0:r.call(n)),await(null===(h=null===(d=null===(l=null===(a=null==v?void 0:v.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.general)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await(null===(g=null===(p=null===(u=null===(c=null==v?void 0:v.routerOptions)||void 0===c?void 0:c.routes)||void 0===u?void 0:u.entities)||void 0===p?void 0:p.load)||void 0===g?void 0:g.call(p)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends se{firstUpdated(){window.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){var e;return window.browser_mod?M`
449+
`}}e([le()],_e.prototype,"hass",void 0),e([de()],_e.prototype,"_dashboards",void 0),e([de()],_e.prototype,"_editSidebar",void 0),customElements.define("browser-mod-frontend-settings-card",_e);var fe="2.3.6";(async()=>{var e,t,i,o,s,n,r,a,l,d,h,c,u,p,g;await customElements.whenDefined("partial-panel-resolver");const w=document.createElement("partial-panel-resolver")._getRoutes([{component_name:"config",url_path:"a"}]);await(null===(i=null===(t=null===(e=null==w?void 0:w.routes)||void 0===e?void 0:e.a)||void 0===t?void 0:t.load)||void 0===i?void 0:i.call(t)),await customElements.whenDefined("ha-panel-config");const v=document.createElement("ha-panel-config");await(null===(r=null===(n=null===(s=null===(o=null==v?void 0:v.routerOptions)||void 0===o?void 0:o.routes)||void 0===s?void 0:s.dashboard)||void 0===n?void 0:n.load)||void 0===r?void 0:r.call(n)),await(null===(h=null===(d=null===(l=null===(a=null==v?void 0:v.routerOptions)||void 0===a?void 0:a.routes)||void 0===l?void 0:l.general)||void 0===d?void 0:d.load)||void 0===h?void 0:h.call(d)),await(null===(g=null===(p=null===(u=null===(c=null==v?void 0:v.routerOptions)||void 0===c?void 0:c.routes)||void 0===u?void 0:u.entities)||void 0===p?void 0:p.load)||void 0===g?void 0:g.call(p)),await customElements.whenDefined("ha-config-dashboard")})().then((()=>{class t extends se{firstUpdated(){window.addEventListener("browser-mod-config-update",(()=>this.requestUpdate()))}render(){var e;return window.browser_mod?M`
440450
<ha-top-app-bar-fixed>
441451
<ha-menu-button
442452
slot="navigationIcon"

custom_components/browser_mod/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"documentation": "https://github.com/dcapslock/hass-browser_mod/blob/master/README.md",
1414
"iot_class": "local_push",
1515
"requirements": [],
16-
"version": "2.3.5"
16+
"version": "2.3.6"
1717
}

custom_components/browser_mod/services.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ popup:
146146
description: Hide timeout progress bar
147147
selector:
148148
boolean:
149+
allow_nested_more_info:
150+
name: Allow nested more-info dialogs
151+
description: Allow nested more-info dialogs to be opened from this popup
152+
selector:
153+
boolean:
149154
style:
150155
name: Styles
151156
description: CSS code to apply to the popup window

custom_components/browser_mod/store.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class SettingsStoreData:
2323
hideInteractIcon = attr.ib(type=bool, default=None)
2424
autoRegister = attr.ib(type=bool, default=None)
2525
lockRegister = attr.ib(type=bool, default=None)
26+
saveScreenState = attr.ib(type=bool, default=None)
2627

2728
@classmethod
2829
def from_dict(cls, data):

documentation/configuration-panel.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LocalStorage works basically like cookies in that the information is stored loca
1313
Registering a _Browser_ as a device will create a Home Assistant Device associated with that browser. The device has the following entities:
1414

1515
- A `media_player` entitiy which will play sound and video through the browser.
16-
- A `light` entity will turn the screen on or off and controll the brightness if you are using [Fully Kiosk Browser](https://www.fully-kiosk.com/) (FKB). If you are not using FKB the function will be simulated by covering the screen with a black (or semitransparent) box.
16+
- A `light` entity will turn the screen on or off and controll the brightness if you are using [Fully Kiosk Browser](https://www.fully-kiosk.com/) (FKB). If you are not using FKB the function will be simulated by covering the screen with a black (or semitransparent) box. There is a [Frontend Setting](#frontend-settings-admin-only) to optionally save the browser screen state for a browser.
1717
- A motion `binary_sensor` which reacts to mouse and/or keyboard activity in the Browser. In FKB this can also react to motion in front of the devices camera.
1818
- A number of `sensor` and `binary_sensor` entities providing different bits of information about the Browser which you may or may not find useful.
1919

@@ -110,7 +110,10 @@ Set the order and hidden items of the sidebar. To change this setting:
110110
This changes the "Home Assistant" text that is displayed at the top of the sidebar.
111111
Accepts Jinja [templates](https://www.home-assistant.io/docs/configuration/templating/).
112112
113-
114113
### Hide interaction icon
115114
116-
This hides the icon in the bottom right corner which indicates that you need to interact with the browser window before Browser Mod will function completely.
115+
This hides the icon in the bottom right corner which indicates that you need to interact with the browser window before Browser Mod will function completely.
116+
117+
### Save screen state
118+
119+
This saves the screen state on browser disconnect and restores on browser reconnect. The screen state (on/off) and brightness are both saved. The state will be saved and restored for all browsers that have this setting applied, including those running Fully Kiosk.

documentation/popups.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,9 @@ data:
202202
}
203203
```
204204
Or through `card-mod-more-info` or `card-mod-more-info-yaml` in a card-mod theme.
205+
206+
## Nested popups
207+
208+
Except for the option to style nested standard Home Assistant more-info dialogs, nested popups are not supported. To allow for nested Home Assistant more-info dialogs, use the `allow_nested_more_info` paramater of `browser_mod.popup` or custom popup card.
209+
210+
__NOTE__: If a custom popup card is is in use on the dashboard, the custom popup card is never nested. If you wish to have a nested more-info dialog in this case, use `browser_mod.more_info` with `ignore_popup_card` set to `true` to nest a standard more-info dialog.

documentation/services.md

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,88 @@ tap_action:
9898

9999
Services called via `fire-dom-event` or called as a part of a different service call will (by default) _only_ target the current Browser (even if it's not registered).
100100

101+
# Actions
101102

103+
Wherever an action is used (`*_action:` in `browser_mod.popup` and `action:` in `browser_mod.notification`), both old style `service:` and new style `action:` can be used. Also actions can be a list allowing for several actions to be called. This can be useful if you only have server actions to run. Otherwise, if you have browser calls you are best to use `broswer_mod.sequence`.
104+
105+
All styles below are valid since Version 2.3.6.
106+
107+
#### New Style
108+
```yaml
109+
action: browser_mod.popup
110+
data:
111+
content: Popup Content
112+
right_button: Toggle Light
113+
right_button_action:
114+
action: light.toggle
115+
target:
116+
entity_id: light.bed_light
117+
```
118+
119+
#### New style with action list
120+
```yaml
121+
action: browser_mod.popup
122+
data:
123+
content: Popup Content
124+
right_button: Wakeup
125+
right_button_action:
126+
- action: light.turn_off
127+
target:
128+
entity_id: light.bed_light
129+
- action: cover.open_cover
130+
target:
131+
entity_id: cover.kitchen_cover
132+
```
133+
134+
#### Old Style
135+
```yaml
136+
action: browser_mod.popup
137+
data:
138+
content: Popup Content
139+
right_button: Toggle Light
140+
right_button_action:
141+
service: light.toggle
142+
data:
143+
entity_id: light.bed_light
144+
```
145+
146+
It is possible to allow for fields in scripts/blueprints to use the `action:` selector and then pass directly to any action parameter. __NOTE__: Only `action:` actions are supported by Browser Mod at this time, whereas the `action:` selector may return other automation building blocks. Use at your own risk checking for any action call errors in the local browser console while testing your installation. See below for a simple example.
147+
148+
#### Script
149+
```yaml
150+
alias: Example Browser Mod using Action field
151+
description: ""
152+
fields:
153+
action:
154+
selector:
155+
action: {}
156+
name: Action
157+
required: true
158+
sequence:
159+
- action: browser_mod.popup
160+
data:
161+
content: Popup Content
162+
right_button: Call Action
163+
right_button_action: "{{ action }}"
164+
```
165+
166+
Yaml after testing up script in developer tools, using the action selector. You will note the actions are returned as a list which is supported.
167+
168+
```yaml
169+
action: script.example_browser_mod_using_action_field
170+
data:
171+
action:
172+
- action: light.turn_off
173+
metadata: {}
174+
data: {}
175+
target:
176+
entity_id: light.bed_light
177+
- action: cover.open_cover
178+
metadata: {}
179+
data: {}
180+
target:
181+
entity_id: cover.kitchen_cover
182+
```
102183

103184
# Browser Mod Services
104185

@@ -171,6 +252,7 @@ data:
171252
[timeout: <number>]
172253
[timeout_action: <service call>]
173254
[timeout_hide_progress: <true/FALSE>]
255+
[allow_nested_more_info: <true/FALSE>]
174256
[style: <string>]
175257
[browser_id: <Browser IDs>]
176258
[user_id: <User IDs]
@@ -191,9 +273,10 @@ data:
191273
| `timeout` | If set will close the dialog after `timeout` milliseconds. |
192274
| `timeout_action` | An action to perform if the dialog is closed by timeout. |
193275
| `timeout_hide_progress` | If true the timeout progress bar will be hidden. |
276+
| `allow_nested_more_info` | If true nested Home Assistant more-info popups are allowed without closing the popup. |
194277
| `style` | CSS styles to apply to the dialog. |
195278

196-
Note that any Browser Mod services performed as `_action`s here will be performed only on the same Browser as initiated the action unless `browser_id` is given.
279+
Note that any Browser Mod services performed as `_action`s here will be performed only on the same Browser as initiated the action unless `browser_id` or `user_id` is given.
197280

198281
If a ha-form schema is used for `content` the resulting data will be inserted into the `data` for any `_action`.
199282

js/config_panel/frontend-settings-card.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,20 @@ class BrowserModFrontendSettingsCard extends LitElement {
243243
}}
244244
></browser-mod-settings-table>
245245
</ha-expansion-panel>
246-
</div>
246+
<ha-expansion-panel
247+
.header=${"Save screen state"}
248+
.secondary=${"Save screen state when browser is disconnected"}
249+
leftChevron
250+
>
251+
<browser-mod-settings-table
252+
.hass=${this.hass}
253+
.settingKey=${"saveScreenState"}
254+
.settingSelector=${{
255+
boolean: {},
256+
label: "Save screen state",
257+
}}
258+
></browser-mod-settings-table>
259+
</ha-expansion-panel> </div>
247260
</ha-card>
248261
`;
249262
}

js/helpers.ts

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,46 @@ export async function getLovelaceRoot(document) {
7171
}
7272
}
7373

74-
export async function getMoreInfoDialogHADialog() {
75-
const base: any = await hass_base_el();
76-
let haDialog = undefined;
77-
if (base) {
78-
const dialog: any = base.shadowRoot.querySelector(
79-
"ha-more-info-dialog"
80-
);
81-
if (dialog) {
82-
haDialog = dialog.shadowRoot.querySelector("ha-dialog");
74+
export async function getMoreInfoDialog(wait = false) {
75+
let _moreInfoDialog = await _getMoreInfoDialog();
76+
while (wait && !_moreInfoDialog) {
77+
await new Promise((resolve) => setTimeout(resolve, 100));
78+
_moreInfoDialog = await _getMoreInfoDialog();
79+
}
80+
return _moreInfoDialog;
81+
82+
async function _getMoreInfoDialog()
83+
{
84+
const base: any = await hass_base_el();
85+
let moreInfoDialog;
86+
if (base) {
87+
moreInfoDialog = base.shadowRoot.querySelector(
88+
"ha-more-info-dialog"
89+
);
90+
}
91+
return moreInfoDialog;
92+
}
93+
}
94+
95+
export async function getMoreInfoDialogHADialog(wait = false) {
96+
let _haDialog: any = await _getMoreInfoDialogHADialog(wait);
97+
while (wait && !_haDialog) {
98+
await new Promise((resolve) => setTimeout(resolve, 100));
99+
_haDialog = await _getMoreInfoDialogHADialog(wait);
100+
}
101+
return _haDialog;
102+
103+
async function _getMoreInfoDialogHADialog(wait = false)
104+
{
105+
const moreInfoDialog: any = await getMoreInfoDialog(wait);
106+
let haDialog;
107+
if (moreInfoDialog) {
108+
haDialog = moreInfoDialog.shadowRoot.querySelector(
109+
"ha-dialog"
110+
);
83111
}
112+
return haDialog;
84113
}
85-
return haDialog;
86114
}
87115

88116
export async function hass_base_el() {

0 commit comments

Comments
 (0)