Anyone created a piston that counts like motion pr device using $cureneventdevice to feed a variable?


#1

1) Give a description of the problem
(PUT YOUR INFO HERE)
Not realy a problem, more to see if anyone have done one of these

2) What is the expected behavior?
(PUT YOUR INFO HERE)
Feed number of “motion active” into a variable that dynamic feed the name of the sensor and number of active over time.
3) What is happening/not happening?
(PUT YOUR INFO HERE)

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

I haven’t but it sounds like an interesting one. Are you looking at making this for a number of motions sensors, all in an array? Or one variable for each motions sensor, containing its name and count of active motion events?


#3

Thinking of a variable containg all my motio sensors.
And have 3 varables where i log events.
MotionSensorsHome, MotionSensorsAway and MotionsensorsNight

Then feed the name and number of motions counting from 0 and up to X every day.
So every variable will fill up nameOfSenor1, numberofmotions, nameOfSensor2, numberofmotins.
And fill them based on SHM status.
All based on motion on $currentEventDevice.


#4

This was fun, took some doing to get it working but you can see in the “DailyMessage” variable it pulled together a summary of each device and its event count. You can modify that message as you want it displayed pretty easily now, I think.

How it’s set up now:
All sensors are listed in the Device Variable
Events from a sensor (I had to add a light switch for testing, I’ll remove it in the sample I post in a minute) will increment a counter in an array variable.

At midnight:
Blanks out the previous day’s string.
A summary of the Device List and their respective counts are pulled together.
(The date displayed in this variable has 1 hour removed from the current time to make sure “yesterday’s” date is displayed since this runs at midnight.)
The counts are set back to zero for each device’s events.


Need a little help with this Piston..... Energy Reporting for my Pool Pump
#5

Here is the sample piston. Let me know if this does what you’re after or needs tweaking?


#6

Looking real GOOD. Working on it now for just loging when “change to active” and difference at home/away/night. 98% finished here. Some counters go banananas when i reuse the array. But soon I will be there. Thx a bunch. Will post final.


#7

Glad to help, and looking forward to seeing the final product!


#8

Doubt the array will clean up at midnight, but in 28 minutes I will know.
The ActiveDeviceNight and ActiveDeviceAway gets out of bounds somehow.
Any Ideas?
Real close to my goal here :slight_smile:
39


#9

I’m not 100% the ActiveDeviceNumberNight or ActiveDeviceNumberAway variables are required to get what you want, but to keep them from going out of bounds, change the variable in the red boxes to match the variable in the green box:

Glad you’re making progress! I’ll take a closer look at it later tonight to see if those variables above are doing anything or can be removed. I’m leaning towards the latter for now.


#10

Yeah, the two variables aren’t needed. I couldn’t edit it without an import code, but hopefully this is clear enough. Just delete the lines/text struck through and it’ll work:


#11

Works like a charm :smiley:
While testing a value with text was added to one of the EventCounts.
The only way i managed to clean that out was to change the integer List to Integer, zero the variable in script, and then change it back to Integer List. (user tips)

Thanks a lot for you effort here.



#12

In that last post, remove the “only while home” restriction from line 52. Otherwise you’ll get counts applied to the wrong devices in modes other than home.

Outside that, glad it’s working! I’ve had to use that same trick to clean out some really ugly arrays/variables, lol. :slight_smile: