Prevent turning off a device if it's still on?

So I have been thinking and trying and messing about but I am stuck. I am missing something and I just don’t know what.

I have my PC behind a Shelly Plug S, so I can check the #Power variable to see if it’s actually on or not. I want to prevent any flow or manual interaction with the plug unless the PC is turned off, so if #Power is below X. BUT I do want to be able to trigger an off>on Flow to boot the PC when I want to boot it remotely. So turning it into an always-on device wouldn’t work either, unless I can toggle that state with a flow but I don’t think that is possible?

I have looked for a good two hours now online to find possible solutions but I haven’t found one so far, anyone has an idea on how to achieve this? Or how to do a flow on “PC turned off” and end a flow without a “then” action, would that prevent the PC from turning off?

Thanks, but, your story is a bit too fuzzy to me.
Can you decribe the things you’d like to happen in steps?

Basically: prevent a Shelly plug from being turned off (either from a flow or from the dashboard) unless the PC that is attached to it is also turned off.

In “pseudo flow” form:

  • IF some action would turn off the Shelly
  • AND the current power draw of the Shelly is below X watt
  • THEN allow the Shelly to be turned off
  • ELSE prevent the Shelly from being turned off

Ah sorry, it was late in the evening so I get that it might not have been a clear description.

I have the Shelly plug to which my PC is connected as a favourite in my app. To see how much it uses and to easily trigger a power cycle and let it automatically boot when the power comes on. But since that also means I can easily hit that button when opening the app and accidentally turn off the PC I want to prevent that. In the practical sense:

I want to prevent the Shelly socket from turning off the power if the PC is on.

So basically as Robert also said:

Which comes down to this I think:

I am only struggling with the ELSE in that flow, I have set up an advanced flow but those are a bit new to me so I might just be missing an option. If leave the Logics Yellow/Cross option without anything connected to it would that end the flow without doing anything?

The “turned off” trigger (the “IF” part) executes when the socket is actually being turned off, so that can’t be used (because it would be too late).

I don’t think there’s a way of making this work with flows unless the Shelly device and/or its app has some specific mode that will prevent “off” signals from being sent to, or processed by, the device and a way of turning on/off that mode (in order to be able to turn off the device when the measured power is below a certain wattage).

  • IF measured power is below X watt
  • THEN turn off “always on” mode
  • ELSE turn on “always on” mode

Aii that sucks, I was hoping the “Turn off” is triggering at the time of turning off instead of once it turned off.

I’ll have a look through the Shelly settings if I can find something like that, maybe Shelly has an option to not turn off unless there is almost no power running through it.

I know Homey has a feature called “Always on” but I don’t think Flows can trigger that option right?

I don’t think so, no.

Use a virtual device to display your Shelly plug power

Thanks that’s a perfect inbetween option! I think that at least solves thick-finger/accidental hit problems. And I think I can prevent the accidental shutdown as well by using a flow to trigger the PC boot where I check for the right power or not.

Though now I am stuck on two, non-critical, points:

  1. This issue [Feature request] Excluding zones and devices from Homey Energy :sweat_smile: It’s showing double the power
  2. And I can’t do that for the kWh variable, the VD only seems to have a Power usage option and not a Power total.

It’s not a necessity to fix them but it would be nice to have it fixed, any ideas?

Lets just hope that Homey will add more exclude options.

And, i totaly understand the thick finger/accidental hit problem. :grinning:

1 Like

No need to say sorry, it happens to me as well, sometimes it’s just hard to describe what the issue is, or what you’d like to achieve.

That’s called Energy / meter_power and available in virtual device, also check the improved version, called “advanced virtual device”; it comes with the app Device Capabilities.

So,
Power (used now, W) = measure_power
Energy (power used during an hour, kWh) = meter_power

Is a ping to your pc not an option?

The issue isn’t determining if the PC is running or not, the issue is toggling the “always on” state of the Shelly.

1 Like

Maybe set the device in Homey to ‘allways on’ so it can’t be turned off with Homey.
Then use the Shelly App itself to restart the PC by turning on and off the power? (Or is this ‘Insulting a man in his place of worship’) :sweat_smile:

Thanks for the explanation, that’s something I’ll have to dive in to once I’m back home.
If I can get that to work it solves my problems for now.

Thank you for the suggestion, unfortunately that would defeat my purpose of using Homey for all my automations. My idea is that it would do more with this way of the flow based on if my PC is on. For example on Wednesdays I tend to work at home, I could do a flow: IF my PC is on (not just the plug) AND it’s Wednesday THEN I want to turn on my DeskPhone plug.

In theory your idea would work but it would be a workaround and not exactly what I’m looking for :grin:

I’m not sure if i fully understood it but mistakes can be avoided with an advanced virtual device.

  1. It can show power usage in the icon on your favorite list
  2. If you do not define the first of the button options in the settings, then pressing the device accidentally won’t have any effect
  3. You can define within the device multiple buttons including for example one button that is on when power>5W and when pressed starts a flow to restart your PC. To access that button you will have to long press the device, select the buttons tab and then press the button
1 Like

For this kind of things I use a variable. In this case:
Pc Yes (it’s on)
Pc No (it’s of)

In a flow with the and construction:
and PC = Yes
Etc.