Make a smart plug into a reset plug


#1

Hello

Is there a way to change a smart plug into a reset socket. What I want is then an “on” command is sent to the switch what it actually does it turn the switch off for a split second then turns it on again??

If the switch is in the off state I would like it to just turn it on.

The situation for this is a raspberry pi plugged into the switch, I turn the raspberry pi off via the device itself which in turn dismounts the micro sd and shuts down the device correctly, the problem is to start the device again the only way is to remove the micro usb from the rear for a second and plug it in again which triggers the restart, I would like to replicate this via a smart plug and my Logitech harmony remote.

Ideally I would just get the Logitech harmony to send an off command followed by an on command but this is not possible so need to see if I can do it via the plug itself, any help is much appreciated.

Thank You


(Chris) #2

You should be able to accomplish this with the Smart Lighting app. I have something similar set up for my dog door opener. The opener is a solenoid that requires momentary power. I have it set so that when the outlet turns on, Smart Lighting turns it immediately back off. If you need any kind of delay (like turn the outlet off, wait 10 seconds, then turn back on) you could do it with CoRE as well, Smart Lighting doesn’t offer the ability to add a delay.

This Smart Lighting app turns the dog door outlet off when it’s turned on.


#3

Thanks this works almost perfect does exactly what I want it to do apart from it puts the power back on so quickly that it doesn’t actually reset the device.

I need to add a delay using CoRE, CoRE is not something I have ever used, could you possibly explain how I would add a 2 second delay between the harmony turning the power off and the smartapps triggering the power back on again?

Thanks for the help


(Chris) #4

Once you have CoRE set up on your account, you’d add a Basic piston like follows:

Due to the nature of scheduling events on the hub, it may not always be 2 seconds exactly…


#5

Thank you install core and got it setup working perfectly. Not sure why delays below 3 seconds did nothing. It was like there was no delay at all the switch went off and back on instantly but 3 seems to be the magic number.

Ideally i would have liked to get it down to 1 second but cite didn’t seem to send the delay unless it’s 3 seconds or more.

Either way though this still works just adds a couple of seconds to the boot up of the activity nothing to cry about.


#6

I’m doing the exact same thing with my raspberry pi as well. Sometimes it just becomes unresponsive and it’s a pain to get up and go fiddle behind the TV to get it back on. Now a simple “Alexa, turn media center off” command to my echo dot turns it off and this CoRE Piston flips it back on. A God send especially for my fiance, this has made my life so much easier. I also have another Piston which turns it off at a scheduled time every morning.

I used to use a cronjob on the device itself, but some mornings when my 2yo wakes me and I can’t get back to sleep, I’d be watching a show and it would turn off without any care of if I was watching or not. With the kodi smartapp I’m able to use the above Piston to tell it to only fire if the status is stopped. Pretty cool if you ask me!


#7

Seems to be an ideal solution, what device are you using to determine if the device is “stopped”?


#8

After setting that up and adding your kodi to it (I’m using osmc on my pi 2 and 3), you can use it in CoRE but use it as a music player. You can trigger things based on the status which include playing paused and stopped.


#9

Ah right very clever, I’m not actually using my Pi 3 for Kodi though it is a Lakka little mini games console. I’m hoping to use power usage as a trigger.

For example if power usage is below 2watts it knows the device is actually “off” and can have the power pulled safely, however is power usage is above 2watts it is doing something and should be left alone.


(Robin) #10

By defult, CoRE will only send a command if it’s needed… For example, if a switch is already on, CoRE won’t send it an ‘on’ command.

In your case, CoRE turns off the switch, waits a few seconds and then back on… ST can take a few seconds to update the known state so it’s likely CoRE thinks your switch is still on (as it’s only been off for a few seconds and not been updated yet).

At the bottom of each CoRE piston there is an ‘advanced options’ section, expand this and select ‘Disable command optimizations’… Now CoRE will always send the command you want regardless of what it thinks the current switch state may be.

Let me know if this helps :slight_smile:


( I hate Mondays) #11

CoRE is not able to reliably control things with delays below 2seconds and in practice that may extend to 3-5 seconds. Anyhow, any wait of or below 2 seconds is actually executed right away because of a very high rate of missed events at such a fast rate. Which is why the (delayed) version exists for some device commands. Turn on/off has that, for example. When using the delayed versions, the command is actually sent ahead to the hub with instructions to delay it so many milliseconds. Side effect is that these commands can no longer be cancelled, but they will happen more or less accurately by using this method. I strongly recommend against turning a plug on and off that fast, but your application may vary.

;tl;dr; CoRE executes ahead any event scheduled within the next two seconds, which renders any wait of 2 or less seconds useless.