Calculate smart plug Run duration & frequency

I have a dehumidifier controlled by a connected plug and humidity sensors. When RH reaches 51%, plug goes on and stays on until humidity reaches 47%. This works great.

However, I would like some way to get a report of how many times and for how long the humidifier goes on. The log is insufficient for this. I guess I could graph it, but I'm wondering if there is method integral to get a report that includes run duration and frequency.

Once I can figure out how often the thing runs in a normal state, I can put rules in HE to prevent the thing from running nonstop, which it will do if the dehumidifier fails and the coils freeze, which is what happened to me last year. Took me until it was running like that for a full power bill cycle to figure it out...

Two things come to mind:

The first is to ask what you are using to manage the smart plug. There may be options in the app you are using that could achieve this without needing to find out the running time on it's own. In a couple of the "smart" humidity apps there are settings for turning off the plug after a set period of time. Equally in RM you could manage this with waits that use a set time (or variable) to turn the plug off.

The second thing is that if you are looking to get the overall running time, there may (or may not) be something in this little app that could be useful:

I have a Dehumidifier in my crawlspace and I monitor it with a dashboard and graphs. It's not running much right now as humidity is quite low. In the peak of summer it gets quite humid here and it runs pretty much all the time. I had setup a rule that monitors it and whenever it shut down on it's own I would kill power to it for 1 hour. After watching it for awhile the on board controller seems to handle that pretty well. So I disabled the rule. If I feel it's running too much I have a virtual switch I set and the rule kicks back in. I also have a rule that alerts me if it is off for more than an hour. Below is my dashboard I use to monitor what's going on.. I am using webcore graphs. They are small but if you double click they open up full screen. The graph on the left is temp and humidity for the three sensors the graph on the right is power usage by the dehumidifier.

2 Likes

@sburke781
The plug has no app. I have managed this with zigbee and zwave plugs and humidity sensors connected to Hubitat and connected to my security system. Either way works.

I do not yet know the duration of time after which I want to turn the plug off. I need to figure out a baseline - what you refer to as "set periord of time" under various conditions so that I can write an automation that turns it off after that time.

If the lights usage table will give me run duration of each time it runs, instead of only cumulative run time it might be exactly what I need.

Now I just need to figure out how in the world to install that custom app...

It may not give you each individual run time... I'm not sure, I haven't used it myself or looked closely enough at the thread to understand fully what it records. 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.

In my own setup I have device events being sent to an InfluxDB and Grafana setup running on a raspberry pi. Much more work on it's own to setup for your current need, but can be quite useful in a number of different situations that may come up, including ongoing monitoring of the smart plug and other devices longer term.

A low-tech option may be to simply look up the events from the Device Edit page and do some mental arithmetic or manually copy / paste them into a spreadsheet, etc.

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!