Announcement

Collapse
No announcement yet.

Show the total value of devices in a group to a VD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Show the total value of devices in a group to a VD

    I made a device group where I added all my devices that uses power (child named Power or Watts). I would like a virtual device to show the total current power usage. Is this possible and how?

  • #2
    Originally posted by lasseruud View Post
    I made a device group where I added all my devices that uses power (child named Power or Watts). I would like a virtual device to show the total current power usage. Is this possible and how?
    This is a great idea. Very useful

    Sent from my SM-G950U using Tapatalk

    Comment


    • #3
      Yes, it requires some very simple scripting (cut and paste level stuff). I’ll explain with reference to figures from my system, shown below.

      First create a counter from the [Tools] -> [Global Variables, Timers and Counters] menu. Let's call it "Total_Watts". In my figures, below, this is device Reference # 551.

      I then have several energy readings I want to add together and store in the counter. These energy meters are devices #s 16, 20, 25, 29, 34, 38
      In the Events tab, I created a new event which triggers every 15 seconds, when it triggers it runs an “immediate” script. In the script box, I have pasted a “hs.setDevicevaluebyref” script which sets the value of the device 551, the counter, by adding together the values of the 6 energy meters.

      You just need to edit this to insert your counter reference #s in place of 551, and to add together your energy meters. You could set the triggers to trigger whenever the energy meters change, but I found that can cause too many events to trigger and found, instead, that a steady 15 second triggering rate worked well for me. The Script you need is along the following lines:


      &hs.setdevicevaluebyref( 551, hs.devicevalueex(16) + hs.devicevalueex(20) + hs.devicevalueex(25) + hs.devicevalueex(29) + hs.devicevalueex(34) + hs.devicevalueex(38), True)



      Click image for larger version  Name:	Energy Meters.png Views:	1 Size:	235.9 KB ID:	1259903





      Click image for larger version  Name:	Event.png Views:	1 Size:	293.9 KB ID:	1259904
      Last edited by jvm; November 16th, 2018, 08:06 PM.

      Comment


      • #4
        You should be able to use Easy Trigger “Set Device to an Expression” using replacement variables. See this post

        EDIT:
        It does work, but the virtual device must be controllable (cannot be Status only). I used a text box for control, but updated the device with the sum of 4 different energy devices via the Easy Trigger Action

        Click image for larger version  Name:	AF516B61-8620-412C-AC08-3264A10D1A8D.jpeg Views:	1 Size:	8.4 KB ID:	1259919
        Last edited by rprade; November 16th, 2018, 09:59 PM.
        Randy Prade
        Aurora, CO
        Prades.net

        PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

        Comment


        • #5
          jvm - your script works like a charm! To make it easier when I add devices, I want to use EasyTriggers Device Group to determine which devices is included. I've added all power devices in a device group and want to use this group to sum all values. I think it's what rprade has done, but I can't figure out what you did. Could you provide a screenshot of your event, please?

          Comment


          • #6
            lasseruud - I don't think you can use Easy Trigger Device Groups to determine which devices to add together. The Group mechanism doesn't give you a way to access / read the individual devices in the group (though, if you use the group as a trigger, Easy Trigger does allow you to read certain environmental variables that identify which of the devices in the group triggered).

            Also, I did notice something odd which I hadn't noticed before.

            When you set up the Counter, it creates a corresponding virtual device which you use to store the totaled Watts. I noticed that as you total the watts and store it in the virtual device the Counter does not change. You can even delete the Counter and the virtual device remains and still functions. So, you don't actually need the counter - it is just a convenient way to create the virtual device. A lesson from this is not to use the "Counter" variable directly in any other function as it doesn't actually hold the sum - that's held in the virtual device. To me, this seems like a bug in HomeSeer as I would have expected the Counter and its virtual device to remain in sync.

            Comment


            • #7
              I'll see if I can help. I created a virtual device with a range of values from 0-10000 with 2 decimal place resolution. I made the range status and control and set a range graphic to match my other devices. As I mentioned above the Easy Trigger "Set Device to Expression will not set a vevice value if the device is status only.

              Click image for larger version

Name:	capture.png
Views:	66
Size:	60.9 KB
ID:	1260042

              There are 17 wattage measurement devices in my server closet that I wanted to sum, plus the new virtual device

              Click image for larger version

Name:	Capture1.PNG
Views:	59
Size:	183.9 KB
ID:	1260043

              Then I used a simple addition expression to total the 17 devices. You cannot use an Easy Trigger group to sum values, so each replacement variable must be entered. The string is this
              Code:
              $$DVR:4889:+$$DVR:4887:+$$DVR:4885:+$$DVR:4882:+$$DVR:4879:+$$DVR:4876:+$$DVR:5068:+$$DVR:5066:+$$DVR:5064:+$$DVR:5061:+$$DVR:5058:+$$DVR:5044:+$$DVR:176:+$$DVR:172:+$$DVR:169:+$$DVR:165:+$$DVR:162
              The event simply triggers on the HA1 value changing. It is my HomeSeer server ad frequently changes. You could also put all devices in an Easy Trigger group and trigger on a change of any device. The event looks like this

              Click image for larger version

Name:	Capture2.PNG
Views:	59
Size:	31.5 KB
ID:	1260044

              There is a bug in how HS handles such a long string when collapsed, which I will let Spud and Rich know about, but the Event functions well.

              Click image for larger version

Name:	Capture6.PNG
Views:	58
Size:	24.4 KB
ID:	1260045

              The immediate script that jvm posted is just as easy and would allow you to set the device as status only.

              Randy Prade
              Aurora, CO
              Prades.net

              PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

              Comment


              • #8
                Here is the same result using an immediate script. I was able to make the device status only.

                Code:
                &hs.setdevicevaluebyref( 391, hs.devicevalueex(4889) + hs.devicevalueex(4887) + hs.devicevalueex(4885) + hs.devicevalueex(4882) + hs.devicevalueex(4879) + hs.devicevalueex(4876) + hs.devicevalueex(5068) + hs.devicevalueex(5066) + hs.devicevalueex(5064) + hs.devicevalueex(5061) + hs.devicevalueex(5058) + hs.devicevalueex(5044) + hs.devicevalueex(176) + hs.devicevalueex(172) + hs.devicevalueex(169) + hs.devicevalueex(165) + hs.devicevalueex(162) , True)
                Click image for larger version  Name:	Capture6.PNG Views:	1 Size:	44.2 KB ID:	1260048


                Click image for larger version  Name:	Capture4.PNG Views:	1 Size:	182.7 KB ID:	1260047
                Randy Prade
                Aurora, CO
                Prades.net

                PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                Comment


                • #9
                  I will see if I can put in a fix. The problem is that there are no spaces in your string so the html does not wrap. I should be able to force a wrap with some CSS.
                  An easy fix on your end is to add some spaces. I suspect the EasyTrigger plugin is not going to mind if you put a space in front of the "+". Then is will wrap ok.

                  You can force the same issue if you create a simple speak action then enter text without spaces, you see the same problem.

                  Originally posted by rprade View Post
                  I'll see if I can help. I created a virtual device with a range of values from 0-10000 with 2 decimal place resolution. I made the range status and control and set a range graphic to match my other devices. As I mentioned above the Easy Trigger "Set Device to Expression will not set a vevice value if the device is status only.

                  Click image for larger version

Name:	capture.png
Views:	66
Size:	60.9 KB
ID:	1260042

                  There are 17 wattage measurement devices in my server closet that I wanted to sum, plus the new virtual device

                  Click image for larger version

Name:	Capture1.PNG
Views:	59
Size:	183.9 KB
ID:	1260043

                  Then I used a simple addition expression to total the 17 devices. You cannot use an Easy Trigger group to sum values, so each replacement variable must be entered. The string is this
                  Code:
                  $$DVR:4889:+$$DVR:4887:+$$DVR:4885:+$$DVR:4882:+$$DVR:4879:+$$DVR:4876:+$$DVR:5068:+$$DVR:5066:+$$DVR:5064:+$$DVR:5061:+$$DVR:5058:+$$DVR:5044:+$$DVR:176:+$$DVR:172:+$$DVR:169:+$$DVR:165:+$$DVR:162
                  The event simply triggers on the HA1 value changing. It is my HomeSeer server ad frequently changes. You could also put all devices in an Easy Trigger group and trigger on a change of any device. The event looks like this

                  Click image for larger version

Name:	Capture2.PNG
Views:	59
Size:	31.5 KB
ID:	1260044

                  There is a bug in how HS handles such a long string when collapsed, which I will let Spud and Rich know about, but the Event functions well.

                  Click image for larger version

Name:	Capture6.PNG
Views:	58
Size:	24.4 KB
ID:	1260045

                  The immediate script that jvm posted is just as easy and would allow you to set the device as status only.
                  website | buy now | support | youtube

                  Comment


                  • #10
                    Originally posted by rjh View Post
                    I will see if I can put in a fix. The problem is that there are no spaces in your string so the html does not wrap. I should be able to force a wrap with some CSS.
                    An easy fix on your end is to add some spaces. I suspect the EasyTrigger plugin is not going to mind if you put a space in front of the "+". Then is will wrap ok.

                    You can force the same issue if you create a simple speak action then enter text without spaces, you see the same problem.


                    Good to know. I will be sure and add spaces.

                    Click image for larger version

Name:	capture.png
Views:	60
Size:	93.1 KB
ID:	1261153
                    Randy Prade
                    Aurora, CO
                    Prades.net

                    PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                    Comment


                    • #11
                      Originally posted by devanb
                      I am trying to use Easy trigger to add two values generated by reference pointers. I am getting the error:

                      Apr-30 21:30:24 EasyTrigger ERROR SetDeviceValue: Cannot find control value 2081.03 for device 195
                      I am not sure how to configure my virtual device to allow it's value to be changed by Easy Trigger.

                      Thanks,

                      Devan



                      Only the most recent Easy Trigger beta will allow you to set values on devices without controls. What version are you running?

                      Randy Prade
                      Aurora, CO
                      Prades.net

                      PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                      Comment


                      • #12
                        Originally posted by rprade View Post
                        Only the most recent Easy Trigger beta will allow you to set values on devices without controls. What version are you running?
                        Version 3.0.0.64

                        I have it working now setting the Text Box in the Control column.

                        Is there a way to run an expression within a change device string command?

                        I'd like the total watts to be listed under status.

                        Currently with my above expression, it reports "948 + 1401" instead of the actual value of 2349.

                        Comment

                        Working...
                        X