Various tweaks, fixes and updated documentation.
This commit is contained in:
102
documentation/configuration-panel.md
Normal file
102
documentation/configuration-panel.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# The Browser Mod Configuration Panel
|
||||
|
||||
## This browser
|
||||
|
||||
A basic concept for Browser Mod is the _Browser_. A _Browser_ is identified by a unique `BrowserID` stored in the browsers [LocalStorage](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API).
|
||||
|
||||
Browser Mod will initially assigning a random `BrowserID` to each _Browser_ that connects, but you can change this if you want.
|
||||
|
||||
LocalStorage works basically like cookies in that the information is stored locally on your device. Unlike a cookie, though, the information is bound to a URL. Therefore you may get different `BrowserID`s in the same browser if you e.g. access Home Assistant through different URLs inside and outside of your LAN, or through Home Assistant Cloud.
|
||||
|
||||
### Register
|
||||
|
||||
Registering a _Browser_ as a device will create a Home Assistant Device associated with that browser. The device has the following entities:
|
||||
|
||||
- A `media_player` entitiy which will play sound and video through the browser.
|
||||
- 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.
|
||||
- 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.
|
||||
- A number of `sensor` and `binary_sensor` entities providing different bits of information about the Browser which you may or may not find useful.
|
||||
|
||||
Registering a browser also enables it to act as a target for Browser Mod _services_.
|
||||
|
||||
### Browser ID
|
||||
|
||||
This box lets you set the `BrowserID` for the current _Browser_.
|
||||
Note that it is possible to assign the same `BrowserID` to several browsers, but unpredictable things _may_ happen if several of them are open at the same time.
|
||||
There may be benefits to using the same `BrowserID` in some cases, so you'll have to experiment with what works for you.
|
||||
|
||||
Browser Mod is trying hard to keep the Browser ID constant
|
||||
|
||||
### Enable camera
|
||||
|
||||
If your device has a camera, this will allow it to be forwarded as a `camera` entity to Home Assistant.
|
||||
|
||||
## Registered Browsers
|
||||
|
||||
This section shows all currently registered _Browsers_ and allows you to unregister them. This is useful e.g. if a `BrowserID` has changed or if you do not have access to a device anymore.
|
||||
|
||||
### Register CAST browser
|
||||
|
||||
If you are using [Home Assistant Cast](https://www.home-assistant.io/integrations/cast/#home-assistant-cast) to display a lovelace view on a Chromecast device it will get a BrowserID of "`CAST`". Since you can't access the Browser Mod config panel from the device, clicking this button will register the `CAST` browser. Most Browser Mod services will work under Home Assistant Cast.
|
||||
|
||||
## Frontend Settings
|
||||
|
||||
This section is for settings that change the default behavior of the Home Assistant frontend.
|
||||
|
||||
Each setting has three levels, _Global_, _Browser_ and _User_.
|
||||
|
||||
- Changes made on the _Global_ tab will be applied for everyone on every browser.
|
||||
- Changes made on the _Browser_ tab will be applied for this _Browser_. The settings here override any _Global_ settings.
|
||||
- Changes made on the _User_ tab will be applied for the user you're currently logged in as - on any device. The settings here override any _Global_ or _Browser_ settings.
|
||||
|
||||
Note that if a setting is set at a lower level but _cleared_ on a higher, it is not _undone_. It's just not overridden.
|
||||
|
||||
Also note that _User_ level settings can only be made when logged in as the user in question, and that the Browser Mod configuration panel is only available to administrators. If you need to change a setting for a non-admin user, you will need to temporarily make them admin for the setup, and then un-admin them.
|
||||
|
||||
### Favicon template
|
||||
|
||||
This allows you to set and dynamically update the favicon of the browser tab/window. I.e. the little icon next to the page title. Favicons can be .png or .ico files and should be placed in your `<config>/www` directory. The box here should then contain a jinja [template](https://www.home-assistant.io/docs/configuration/templating/) which resolves to the path of the icon with `<config>/www/` replaced by `/local/` (see [Hosting files](https://www.home-assistant.io/integrations/http/#hosting-files)).
|
||||
|
||||
> Ex:
|
||||
>
|
||||
> ```jinja
|
||||
> {% if is_state("light.bed_light", "on") %}
|
||||
> /local/icons/green.png
|
||||
> {% else %}
|
||||
> /local/icons/red.png
|
||||
> {% endif %}
|
||||
> ```
|
||||
|
||||
Note that this _only_ applies to the current favicon of the page, not any manifest icons such as the loading icon or the icon you get if you save the page to your smartphones homescreen. For those, please see the [hass-favicon](https://github.com/thomasloven/hass-favicon) integration.
|
||||
|
||||
### Title template
|
||||
|
||||
This allows you to set and dynamically update the title text of the browser tab/window by means on a Jinja [template](https://www.home-assistant.io/docs/configuration/templating/).
|
||||
|
||||
> Ex:
|
||||
>
|
||||
> ```jinja
|
||||
> {{ states.persistent_notification | list | count}} - Home Assistant
|
||||
> ```
|
||||
|
||||
### Hide Sidebar
|
||||
|
||||
This will hide the sidebar wit the navigation links. You can still access all the pages via normal links.
|
||||
|
||||
> Tip: add `/browser-mod` to the end of your home assistant URL when you need to turn this off again...
|
||||
|
||||
### Hide header
|
||||
|
||||
This will hide the header bar. Completely. It does not care if there are useful navigation links there or not. It's gone.
|
||||
|
||||
> Tip: See the big yellow warning box at the top of this card? For some reason, it seems to be really easy to forget you turned this on. Please do not bother the Home Assistant team about the header bar missing if you have hidden it yourself. Really, I've forgotten multiple times myself.
|
||||
|
||||
### Sidebar order
|
||||
|
||||
Did you know that you can change the order and hide items from the sidebar? To do so, either go into your profile settings at the bottom left and click "Change the order and hide items from the sidebar", or click and hold on the "Home Assistant" text at the top of the sidebar.
|
||||
|
||||
Normally, the order and hidden items only applies to the current device, but this will make it persistent according to the levels described above.
|
||||
|
||||
### Default dashboard
|
||||
|
||||
Like the Sidebar order, the default dashboard (the page shown when you simply access `https://<your home assistant url>/` with nothing after the `/`) can be set in your profile settings but only applies to the current device. This fixes that.
|
||||
65
documentation/popups.md
Normal file
65
documentation/popups.md
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
## Anatomy of a popup
|
||||
|
||||
```yaml
|
||||
service: browser_mod.popup
|
||||
data:
|
||||
title: The title
|
||||
content: The content
|
||||
right_button: Right button
|
||||
left_button: Left button
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Displaying a dashboard card in a popup
|
||||
|
||||
```yaml
|
||||
service: browser_mod.popup
|
||||
data:
|
||||
title: The title
|
||||
right_button: Right button
|
||||
left_button: Left button
|
||||
content:
|
||||
type: entities
|
||||
entities:
|
||||
- light.bed_light
|
||||
- light.ceiling_lights
|
||||
- light.kitchen_lights
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Actionable popups
|
||||
|
||||
```yaml
|
||||
service: browser_mod.popup
|
||||
data:
|
||||
content: Do you want to turn the light on?
|
||||
right_button: "Yes"
|
||||
left_button: "No"
|
||||
right_button_action:
|
||||
service: light.turn_on
|
||||
data:
|
||||
entity_id: light.bed_light
|
||||
left_button_action:
|
||||
service: browser_mod.popup
|
||||
data:
|
||||
title: Really?
|
||||
content: Are you sure?
|
||||
right_button: "Yes"
|
||||
left_button: "No"
|
||||
right_button_action:
|
||||
service: browser_mod.popup
|
||||
data:
|
||||
content: Fine, live in darkness.
|
||||
dismissable: false
|
||||
title: Ok
|
||||
timeout: 3000
|
||||
left_button_action:
|
||||
service: light.turn_on
|
||||
data:
|
||||
entity_id: light.bed_light
|
||||
```
|
||||
|
||||

|
||||
254
documentation/services.md
Normal file
254
documentation/services.md
Normal file
@@ -0,0 +1,254 @@
|
||||
|
||||
## Reading guide
|
||||
Service parameters are described using the following conventions:
|
||||
|
||||
- `<type>` in brackets describe the type of a parameter, e.g.
|
||||
|
||||
- `<string>` is a piece of text
|
||||
- `<number>` is a number
|
||||
- `<TRUE/false>` means the value must be either `true` or `false` with `true` being the default
|
||||
- `<service call>` means a full service call specification. Note that this can be any service, not just Browser Mod services
|
||||
- `<Browser IDs>` is a list of BrowserIDs
|
||||
|
||||
- Square brackets `[ ]` indicate that a parameter is optional and can be omitted.
|
||||
|
||||
### `<service call>`
|
||||
|
||||
A service call is a combination of a service and it's data:
|
||||
|
||||
Ex, a `<service call>` for `browser_mod.more_info` with `light.bed_light` as entity:
|
||||
|
||||
```yaml
|
||||
service: browser_mod.more_info
|
||||
data:
|
||||
entity: light.bed_light
|
||||
```
|
||||
|
||||
If `data` contains `browser_id: THIS` then `THIS` will be replaced with the current browser ID.
|
||||
|
||||
|
||||
## A note about targets
|
||||
|
||||
Browser Mod services can be called in two different ways which behave slightly differently.
|
||||
|
||||
The first way is as a *server* call. This is when the service is called from a script or automation, from the dev-services panel or from a dashboard `call-service` action.
|
||||
|
||||
The second way is as a *browser* call. This is when the service is called from a dashboard `fire-dom-event` action, as a part of a `browser_mod.sequence` call or as a `browser_mod.popup` `_action`.
|
||||
|
||||
The notable difference between the two is when no target (`browser_id`) is specified, in which case:
|
||||
- A *server* call will perform the service on ALL REGISTERED BROWSERS.
|
||||
- A *browser* call will perform the service on THE CURRENT BROWSER, i.e. the browser it was called from.
|
||||
|
||||
---
|
||||
|
||||
Finally, in *browser* calls, a parameter `browser_id` with the value `THIS` will be replaced with the current Browsers browser ID.
|
||||
|
||||
Ex:
|
||||
|
||||
```yaml
|
||||
tap_action:
|
||||
action: fire-dom-event
|
||||
browser_mod:
|
||||
service: script.print_clicking_browser
|
||||
data:
|
||||
browser_id: THIS
|
||||
```
|
||||
|
||||
with the script:
|
||||
|
||||
```yaml
|
||||
script:
|
||||
print_clicking_browser:
|
||||
sequence:
|
||||
- service: system_log.write
|
||||
data:
|
||||
message: "Button was clicked in {{browser_id}}"
|
||||
```
|
||||
|
||||
Will print `"Button was clicked in 79be65e8-f06c78f" to the Home Assistant log.
|
||||
|
||||
# Browser Mod Services
|
||||
|
||||
## `browser_mod.navigate`
|
||||
|
||||
Point the browser to the given Home Assistant path.
|
||||
|
||||
```yaml
|
||||
service: browser_mod.navigate
|
||||
data:
|
||||
path: <string>
|
||||
[browser_id:
|
||||
- <Browser ID>
|
||||
- <Browser ID>]
|
||||
```
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|`path` | A Home Assistant path. <br/>E.x. `/lovelace/`, `/my-dashboard/bedroom`, `/browser_mod/`, `/config/devices/device/20911cc5a63b1caafa2089618545eb8a`...|
|
||||
|
||||
## `browser_mod.refresh`
|
||||
|
||||
Reload the current page.
|
||||
|
||||
```yaml
|
||||
service: browser_mod.refresh
|
||||
data:
|
||||
[browser_id: <Browser IDs>]
|
||||
```
|
||||
|
||||
## `browser_mod.more_info`
|
||||
|
||||
Show a more-info dialog.
|
||||
|
||||
```yaml
|
||||
service: browser_mod.more_info
|
||||
data:
|
||||
entity: <string>
|
||||
[large: <true/FALSE>]
|
||||
[ignore_popup_card: <true/FALSE>]
|
||||
[browser_id: <Browser IDs>]
|
||||
```
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|`entity`| The entity whose more-info dialog to display. |
|
||||
|`large`| If true, the dialog will be displayed wider, as if you had clicked the title of the dialog. |
|
||||
| `ignore_popup_card` | If true the more-info dialog will be shown even if there's currently a popup-card which would override it. |
|
||||
|
||||
## `browser_mod.popup`
|
||||
|
||||
Display a popup dialog
|
||||
|
||||
```yaml
|
||||
service: browser_mod.popup
|
||||
data:
|
||||
[title: <string>]
|
||||
content: <string / Dashboard card configuration>
|
||||
[size: <NORMAL/wide/fullscreen>]
|
||||
[right_button: <string>]
|
||||
[right_button_action: <service call>]
|
||||
[left_button: <string>]
|
||||
[left_button_action: <service call>]
|
||||
[dismissable: <TRUE/false>]
|
||||
[dismiss_action: <service call>]
|
||||
[autoclose: <true/FALSE>]
|
||||
[timeout: <number>]
|
||||
[timeout_action: <service call>]
|
||||
[style: <string>]
|
||||
[browser_id: <Browser IDs>]
|
||||
```
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|`title` | The title of the popup window.|
|
||||
|`content`| HTML or a dashboard card configuration to display.|
|
||||
| `size` | `wide` will make the popup window wider. `fullscreen` will make it cover the entire screen. |
|
||||
| `right_button`| The text of the right action button.|
|
||||
| `right_button_action`| Action to perform when the right action button is pressed. |
|
||||
| `left_button`| The text of the left action button.|
|
||||
| `left_button_action`| Action to perform when the left action button is pressed. |
|
||||
| `dismissable`| If false the dialog cannot be closed by the user without clicking an action button. |
|
||||
| `dismiss_action` | An action to perform if the dialog is closed by the user without clicking an action button. |
|
||||
| `autoclose` | If true the dialog will close automatically when the mouse, screen or keyboard is touched. This will perform the `dismiss_action`. |
|
||||
| `timeout` | If set will close the dialog after `timeout` milliseconds. |
|
||||
| `timeout_action` | An action to perform if the dialog is closed by timeout. |
|
||||
| `style` | CSS styles to apply to the dialog. |
|
||||
|
||||
The default value for `style` is as follows:
|
||||
|
||||
```yaml
|
||||
style:
|
||||
--popup-min-width: 400px;
|
||||
--popup-max-width: 600px;
|
||||
--popup-border-width: var(--ha-card-border-width, 2px);
|
||||
--popup-border-color: var(--ha-card-border-color, var(--divider-color, #eee));
|
||||
--popup-border-radius: 8px;
|
||||
--popup-background-color: var(--ha-card-background, var(--card-background-color, white));
|
||||
--popup-header-background-color: var(--popup-background-color, var(--sidebar-background-color));
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
For usage examples, see [popups.md](popups.md).
|
||||
|
||||
|
||||
## `browser_mod.close_popup`
|
||||
|
||||
Close any currently open popup or more-info dialog.
|
||||
|
||||
```yaml
|
||||
service: browser_mod.close_popup
|
||||
data:
|
||||
[browser_id: <Browser IDs>]
|
||||
```
|
||||
|
||||
## `browser_mod.sequence`
|
||||
|
||||
Perform several services sequentially.
|
||||
|
||||
```yaml
|
||||
service: browser_mod.sequence
|
||||
data:
|
||||
sequence:
|
||||
- <service call>
|
||||
- <service call>
|
||||
- ...
|
||||
[browser_id: <Browser IDs>]
|
||||
```
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|`sequence` | List of actions to perform. |
|
||||
|
||||
Note that if `browser_id` is omitted in the service calls listed in `sequence` the services will be performed on the Browser that's targeted as a whole rather than all browsers.
|
||||
|
||||
## `browser_mod.delay`
|
||||
|
||||
Wait for a specified time.
|
||||
|
||||
```yaml
|
||||
service: browser_mod.delay
|
||||
data:
|
||||
time: <number>
|
||||
[browser_id: <Browser IDs>]
|
||||
```
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|`time` | Number of milliseconds to wait.|
|
||||
|
||||
This is probably most useful as part of a `browser_mod.sequence` call.
|
||||
|
||||
## `browsermod.console`
|
||||
|
||||
Print a text to the browsers javascript console.
|
||||
|
||||
```yaml
|
||||
service: browser_mod.console
|
||||
data:
|
||||
message: <string>
|
||||
[browser_id: <Browser IDs>]
|
||||
```
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|`message` | Text to print. |
|
||||
|
||||
## `browsermod.javascript`
|
||||
|
||||
Run arbitrary javascript code in the browser.
|
||||
|
||||
```yaml
|
||||
service: browser_mod.console
|
||||
data:
|
||||
code: <string>
|
||||
[browser_id: <Browser IDs>]
|
||||
```
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|`code` | Code to run. |
|
||||
|
||||
Only use this one if you know what you're doing.
|
||||
|
||||
The `hass` frontend object is available as global variable `hass`.
|
||||
Reference in New Issue
Block a user