Calculate smart plug Run duration & frequency

Couldn't you do some variable math in a rule, or something?

To install the app you need to copy the text from the link towards the top of the thread, got to the Apps Code section on your HE hub and click New App, paste in the code and click save. You can then go to the Apps page and click Add User App, selecting the app from the list presented.

THANK YOU!!
Installing now.

1 Like

That reminds me, you could trigger off the plug turning off, get the last on event time and calculate the time since that occurred. I think it was @FriedCheese2006 who mentioned that recently... You could then output that to a file as a record.

1 Like

@velvetfoot
um, maybe, but how? I know the HE has all the data, I just want to get the data visible so I can evaluate and then make a rule. Until I evaluate normal ops, I have no idea what rule I should write...

Thank you so much for the help.

So I installed the app. Looks like it reports "Total on Time" until such time as it is reset, at which point it discards it's data and starts over. There is apparently some way to cause it to automatically reset. So interesting info but not really info that will help me to determine the max run time I should set for the dehumidifier.

I was looking for a simple way to get a report out of HE of info it already has. Looks like it won't be simple. I'm sure I can go into the logs and calculate this, I just thought HE might have a simple way to output/process the data it already has....

1 Like

Going back and reading what you're trying to do, I think this could be done with a fairly simple RM rule. When. I get a chance, I'll post an example. Basically what @sburke781 was getting at earlier.

1 Like

Here you go.

When the plug turns on, timesUsed will increment by 1 to keep a count of cycles. It then sets timeOn to the current date/time. Once the plug is turned.off, timeOff is set to the current date/time, then a line to do theath to calculate usage in minutes. The last line writes the count number and how long it was on to a local file.

Note the use of local variables in the rule. You'll need to set those up first. Pay particular attention to the rypes. Let it run for a week and get your average.

Here's the Actions page for a cleaner view.

1 Like

Nice work. That looks like exactly what @calinatl will need.

Being a data kind of guy, a couple of ideas on the output....

  • Perhaps produce a CSV style output, including comma's in between each "column"
  • For ease you could include a 1 that can be summed for a total usage count by whatever reads in the file, though most should be able to produce a simple row count as well (removes the need for this to be maintained as a variable)
  • Maybe include the start and stop date/time in the file output
  • You could include the timeUse for ease, or the application taking in the data could also calculate that as well

So something like:

1, 2023-04-24 06:45, 2023-04-24 09:15, 150
1, 2023-04-25 14:23, 2023-04-25 14:53, 30

The device name might be useful in other situations where multiple devices are being monitored.

I should probably stop.... :slight_smile:

This looks great.
It comes with the added benefit of forcing me to learn ALOT about the Hubitat...

I'm still on the setting up local variables portion - LOL!

  • In the Name field, where is states "Name the local variable" if I enter "%device%" I do not get the option for Device in the Type column. I think there is something with those first two entries that I'm not understanding...
1 Like

%device% and %value% are auto populated so you don't need to add them.

@FriedCheese2006
Thank you. I will now carry on then report back...

1 Like

@FriedCheese2006
OK, rule is written. I think I understand about 75% of what I just did and certainly learned ALOT about what HE can do. It did auto populate the two condition fields after I ran the rule. I even found where the file is in Settings/File manager. As a placeholder for my first time I replaced my dehumid switch with a light right next to me so I can turn that on and off while I test this, which I have done.

Obviously I did something wrong, because when I click on the file I get a blank page except for '6-null' at the top...
Any ideas what would cause that?

1 Like

Can you post a screenshot of the rule?

1 Like

Here is the screenshot. As noted, until I get it working the device I have it tied to is a lamp next to me so I can turn that on and off and test this. It looks like it is reporting on and off correctly, it's just that when I go to Settings/File Manager and 2x click on the file I get a blank page except for the words '6-null' at the top

Thanks!

You only need to single click the file to open it.

In your last line, you have the variable name as timeUse but the variable name is timeuse.

You are correct - single click.
I saw that capitalized U when I posted the screenshot and wondered if that would matter. Apparently it does. I've fixed it.
Now when I single click on the file I get a blank page with '8-null' on top.

1 Like

I use Hubigraphs to track the on off cycling of my hot water heater blower fan. A Zooz smart switch measuring power controls a virtual switch for the graph input. On the graph you can see when it turns on and for how long. The vertical green bar is an indicator of when a recirc pump turns on.

I'm not sure about the file. Maybe try deleting it and let the rule recreate it.

One thing I realized I led you astray on. Instead of "write to file" you want "append to file"

@FriedCheese2006
I made the recommended revision; "Write to file" is now 'append to file"
The file is returning some sort of data, but I don't understand what it is returning. This is what the file now shows when I open it:
12-19313-014-015-26416-15817-157