Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Initial support for Shelly Script comes with firmware version 0.9, September

# Changelog

## 2024-06
- Delay relay on after predefined time in seconds
## 2024-04
- Load shedding with Shelly Pro4PM and Pro3EM
## 2023-11
Expand Down
23 changes: 23 additions & 0 deletions delay-relay-on.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const CONFIG = {
/**
* Choose your device switch ID to be used for turning on the switch after time delay
*/
ID: 0,

/**
* Choose DELAY time in seconds after which the switch is turned on
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the switch will be turned on with delay from when?

*/
DELAY: 5
}

let timerID;

function turnSwitchOn() {
Shelly.call("Switch.Set", {"id": CONFIG.ID, "on": true});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the component type to the config, the user might want to turn on a light or rgb component.

if (timerID) {
Timer.clear(timerID);
}
}

timerID = Timer.set(1000 * CONFIG.DELAY, false, turnSwitchOn);

5 changes: 5 additions & 0 deletions examples-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"fname": "delay-relay-on.js",
"title": "Delay switching on the relay after device is plugged in",
"description": "This script allows you to set time in seconds to delay the switch to turn on after the device is plugged in"
},
{
"fname": "hue-lights-control.js",
"title": "Controlling hue lights with Shelly BLU Button or virtual buttons",
Expand Down