Hello. I’m looking for a way to secure this app so that changes cannot be made unless a password or pin is entered. I do not want other people to make changes after I set up the screen. Thanks.
You can restrict Settings access in the mobile apps by adding a “Settings Password” to your project. This option is located on the Settings -> Advanced tab in the Designer.
If you need to restrict access on custom pages you could Prompt
for a password or pin in JavaScript. Attached is an example that only opens a page “SecurePage.xaml” if the user enters 1234
.
Prompt_Demo.hrp (3.9 KB)
I was looking for the first option. Works perfectly! Thanks for the fast response and the awesome work on this project!
Still trying learn the Designer, but the videos on the site are very helpful.
I’ve just set this up, its working but not quite as I expected.
I expected that when clicking on the Settings on the slide out menu on the left hand side, it would then prompt for a pin code at this stage and then let you in to the settings area.
It works a bit differently, if you click the Settings from the menu it lets you in to the settings area and doesn’t prompt you for a pin code and then you can see all the Device objects, Groups, etc.
If you click on any of these objects its at this point it then prompts you for the pin code.
The only thing I was able to change without a pin was Light / Dark Mode and the Scale setting.
I’m looking at the pin code example project.
I can see how it works, you have a button and upon click it uses the Script to prompt for the pin code and if correct it then loads a hard coded page .xaml
var promptResult = prompt("Please enter the pin number (1234):");
if(promptResult == "1234")
{
App.OpenPage("SecurePage.xaml");
}
else
{
alert("Failure");
}
What about if I want to secure a tile that runs scenes @Device.Scene, I need to change this part to run the scenes instead?
App.OpenPage("SecurePage.xaml");
Here I am editing a tile that runs Scenes, I’ve added the Script action.
My Data Action is still set to @Device.Scene
Please advise.
Thank you.
Remove the DataAction
that triggers the Scene & place it inside the script. I do intend to add support an alternative way to prompt for a PIN that doesn’t require scripting. For the time being though, do something like this:
var promptResult = prompt("Please enter the pin number (1234):");
if(promptResult == "1234")
{
App.SetDeviceAttribute("@Device.Scene", "");
}
else
{
alert("Failure");
}
Thank you that works nicely for the PIN code !
This also enabled me to create a basic Y or N prompt to run a scene.
var promptResult = prompt("Enter Y to launch the scene or N to Cancel:");
if(promptResult == "Y")
{
alert("OK Now Launching Scene");
App.SetDeviceAttribute("@Device.Scene", "");
}
else
{
alert("OK Aborting");
}
Is it possible to launch a specific Vera scene via a script ?
For example say my scene is called “Home”.
In HR it would be Home.Scene presumably.
Found this on the old Google Group.
“Yes. Just call App.SetVariableValue(“YOUR_SCENE_VARIABLE_NAME”, “”). The value you set it to can be whatever. Any write request will trigger the scene.”
I tried this but doesn’t work.
App.SetVariableValue("Home.Scene", "");
What is the variable name ?
Yes, but don’t use SetVariableValue. That’s since been renamed to SetDeviceAttribute. Do the same thing you were doing in your previous post, just replace @Device with “Home”.
var promptResult = prompt("Enter Y to launch the scene or N to Cancel:");
if(promptResult == "Y")
{
alert("OK Now Launching Scene");
App.SetDeviceAttribute("Home.Scene", "");
}
else
{
alert("OK Aborting");
}
Thanks that works.
I’ve had to build a new “Modes” details .xaml page, as I run Vera scenes that set the Vera house modes and also do other stuff in addition, rather than just setting the Vera house modes directly as the original details .xaml file was doing.
The “Home” one I wanted to protect with a PIN code.
Hi Bill, I tried the script to pin a button, it’s great. Is it possible to only open the numeric keypad to have the digits in bulk instead of having the entire keyboard open? Making it easier to enter the password.
It currently is not possible to limit that keypad to only digits.
Bill,
Trying to use your exemple of the scriptaction to confirm a button action but I need some guidance please.
I have a button with an EvenTrigger containing a 2 different DataActions based on conditions that sets a HomeseerDevice value.
I am looking at a way when someone press the button to popup a “Yes/No” confirmation window before continuing with the EvenTrigger and set the HS Device value but can’t figure out how to call an EventTrigger in a script.
------------------ Update--------------------------------------
found a way with scenes , tnaks anyway
You can’t call an EventTrigger from a ScriptAction. You can only call a ScriptAction from an EventTrigger. What you would do will probably look something like this.
var txt;
var r = confirm("Click OK to turn on the switch");
if (r == true) {
// You pressed OK!
App.SetDeviceAttribute("@Device.Switch", "On");
} else {
// Do nothing, you pressed Cancel
}
I need to add an alternative/easier way of doing this that doesn’t require a script. Until that happens, you’ll have to use code similar to that above.
Hi, Could this be used to protect any individual switch from being switched on or off?
I can confirm this can be used to protect the accidental Press of any button