Jump to content
Shelly IoT Innovation Challenge started! ×

Shelly Plus 1PM Scripting


Recommended Posts

Hi, I am using a Shelly Plus 1PM to turn an electric heater on and off.
I have an app that sets when a device is turned on depending on the price of electricity - using the octopus agile half hour time slots.
The app provides an api that says whether the device should be on or not.
Below is a Shelly script that queries the api every minute and turns the device on or off.
It all seems to work fine, but the script quits after a few hours.
Any ideas why it would stop running?

function httpResponse(result, error_code, error) {
  const j = JSON.parse(result.body);
  const s = j.sel;
  if (error_code === 0 && s === true) {  
   Shelly.call("Switch.set", {'id': 0, 'on': true});
    } else {
   Shelly.call("Switch.set", {'id': 0, 'on': false});
function timerCode() {
 const url = "https://xxxxxx.uk/is_on?device=ors";
 Shelly.call("HTTP.GET", {url: url}, httpResponse);}

 Timer.set( 60000, true, timerCode);


Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...