Do not take this plugin as a security measure. Anything on client side is insecure by default and anyone with the minimum knowldge and with access to the device can inspect the code, the network tab and check your secrets. This is more intended to avoid kids/spouse/friends to interact with certain elements/entities of Home Assistant.
In Home Assistant, it is very common to hide or restrict elements from non-admins users. There are multiple HACS plugins that are used to restrict critical sections, dasboards, UI elements, cards, etc. from unauthorized users (kiosk-mode, custom-sidebar, lovelace-state-switch, are some of them). This is a recurrent task in kiosk devices that are intended to be used by the whole family or by a large group of users. The issue comes when the owner or admin wants to interact with those elements on the device because these elements are hidden also for them.
Even if those elements could be shown switching some entity, the admin needs to go to a device in which that entity is visible to be able to interact with it. It is something no so straightforward to do on the same restricted device.
But what about showing the desired element, navigating to the desired dashboard, or switching the desired entity not with an UI element but with something hidden and only known by the admin/owner?
This is when Home Assistant Secret Taps
comes to scene, you can configure "secrets" based on sequences of taps on the screen and perform certain actions when these secret taps are executed. Call a service, open the more-info dialog of an entity or navigating to a dashboard are the main actions that could be performed only touching in any part of the screen using the correct sequence.
Do you have the header hidden and to show it you need to change an input_boolean
?
You can configure a sequence of taps that will call the toggle
service on that entity to show the header, then you can perform the changes that you want, and turn it off again using the same tap sequence.
Do you want to hide the header in mobile but this impedes you to open the sidebar?
You can configure a secret sequence of taps that opens and closes the sidebar without interacting with any visible element.
Do you have a hidden subview that is not linked from any other view and which is full of entities to administrate your Home Assistant instance?
You could navigate to that subview without clicking on a link, just executing the correct tap sequence that you configured for that.
These are just common hypotehtical use cases but I am sure that you will ideate your own. Just configure and perform your secrets taps and execute your actions without any visible interactive element and without letting any trace 🥷
You can install the plugin manually or through HACS, not both. If you install the plugin using the two installations methods you could have issues or errors.
Note: if your version of
HACS
is lower thanv2
consult the section Through old HACS versions (< v2)
- Go to
HACS
dashboard - Search for
home-assistant-secret-taps
and click on it - On the plugin page, click on the
Download
yellow button in the bottom-right corner - Click on
Download
in the more-info dialog - When the plugin is already downloaded, add the url of the plugin as an extra_module_url in your
configuration.yaml
:
frontend:
extra_module_url:
- /hacsfiles/home-assistant-secret-taps/home-assistant-secret-taps-plugin.js
- Make sure you add
home-assistant-secret-taps-plugin.js
and nothome-assistant-secret-taps.js
- Restart Home Assistant
- Go to
HACS
dashboard - Go to
Frontend
- Click on
Explore and download repositories
button in the bottom-right of the screen - Search for
home-assistant-secret-taps
and install it - Add the url of the plugin as an extra_module_url in your
configuration.yaml
:
frontend:
extra_module_url:
- /hacsfiles/home-assistant-secret-taps/home-assistant-secret-taps-plugin.js
- Make sure you add
home-assistant-secret-taps-plugin.js
and nothome-assistant-secret-taps.js
- Restart Home Assistant
- Download the latest home-assistant-secret-taps release
- Copy
home-assistant-secret-taps-plugin.js
into<config directory>/www/
- Add the url of the plugin as an extra_module_url in your
configuration.yaml
:
frontend:
extra_module_url:
- /local/home-assistant-secret-taps-plugin.js?v1.0.0
- Make sure you add
home-assistant-secret-taps-plugin.js
and nothome-assistant-secret-taps.js
and make sure you add the correct version at the end of the URL (e.g.?v=1.0.0
) because in this way you make Home Assistant to load the new version instead of a version stored in cache - Restart Home Assistant
The configuration must be stored in a yaml
file that needs be placed inside the <config directory>/www/
directory. The name of the configuration file should be secret-taps.yaml
. It could be easier if you copy the example secret-taps.yaml file, and edit it to match your needs.
Property | Type | Required | Default | Description |
---|---|---|---|---|
enabled | Boolean | no | false | Enables or disables the plugin |
threshold | Number | no | 1000 | Maximum number of milliseconds between taps |
notification | Boolean | no | false | Trigger a notification when a secret is successfully executed or when it failed to call the secret because a wrong config |
debug | Boolean | no | false | If it is true it will print debug messages on the developer console that will help to debug an issue |
profiles | Array of Profile | yes | - | List of profiles |
Note: the
threshold
among taps is by default1000
milliseconds (1 second) and you can increase it. Just take into account that this number is also the delay between the last tap and when the action is executed, because during this time the plugin is still expecting that another tap could be executed.
Property | Type | Required | Default | Description |
---|---|---|---|---|
user | String or Array of String | no | - | User's name (or list of users names) that match the profile (it should be the name of a user not a username) |
admin | boolean | no | - | Match the profile depending on the admin level |
owner | boolean | no | - | Match the profile depending on the system ownership |
secrets | Array of Secret | yes | - | List of secrets |
Notes:
- If you don't set at least one property from
user
,admin
orowner
, the profile will match with any user- Multiple profiles could match with an user. For example, if you have a profile for admins and another profile for the user
John
, if the userJohn
is admin the two profiles will available to him
All secrets should have these properties:
Property | Type | Required | Default | Description |
---|---|---|---|---|
taps | Array of Tap |
yes | - | Sequence of taps |
action | String | yes | - | Action to perform |
Note: you should always configure the
taps
property using multiple taps and not a very common taps pattern. If you set up an action to be performed with a singletap
, it will be executed every time that you tap on the screen, always.
tap
: single tap on the screendouble-tap
: two consecutive taps on the screentriple-tap
: three consecutive taps on the screen
Sequence of taps example
taps:
- tap
- triple-tap
- double-tap
call-service
: action to call a servicemore-info
: action to open a more-info dialognavigate
: action to navigate to a certain pathtoggle-menu
: action to open or close the sidebarjavascript
: action to execute aJavaScript
code block
Each secret
can be any of the next ones:
Call-service secret example
action: call-service
service: light.toggle
data:
entity_id: light.woonkamer
More-info secret example
action: more-info
entity_id: sun.sun
Navigate secret example
action: navigate
navigation_path: /config/dashboard
## Optional parameter. It is false by default
## Whether to replace the current page in the history
navigation_replace: true
Toggle menu secret example
action: toggle-menu
JavaScript secret example
action: javascript
code: |
if (user_is_admin) {
location.reload();
}
Note: the
JavaScript
action makes use of the home-assistant-javascript-templates library. So all the objects and methods of this library will be available in theJavaScript
code.
## enable the plugin
enabled: true
## list of profiles
profiles:
## This profile will match only with these users
- user:
- Jim Hawkins
- Long John Silver
secrets:
- taps:
- double-tap
- tap
- triple-tap
action: call-service
service: input_boolean.toggle
data:
entity_id: input_boolean.kiosk_header
- taps:
- tap
- double-tap
- tap
action: more-info
entity_id: sun.sun
- taps:
- double-tap
- double-tap
- tap
action: navigate
navigation_path: /config/dashboard
## This profile will match only with non-admin users
- admin: false
secrets:
- taps:
- double-tap
- tap
- triple-tap
action: toggle-menu
- taps:
- double-tap
- tap
- tap
action: javascript
code: 'location.reload();'