Announcement

Collapse
No announcement yet.

How to make simple math

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

    How to make simple math

    I am making several events where it would be nice to use simple math.
    Like adding my solar power values together, to get one total value.
    Or to multiply 2 values to get the power.

    I know it is possible to make a script. But I am no master at scripting, and if I understand it correct it will be much work for a very small piece of math ;-)

    Anybody with a good idea?

    #2
    I highly recommend scripting. It can become VERY complex and there is virtually no "Cliff's Notes" documentation that will lead you by the hand, but your stated needs are quite simple. You might also consider the Plug-In "Easy Trigger."
    HomeSeer Version: HS4 Pro Edition 4.2.18.1
    Operating System: Microsoft Windows 10 Pro - Desktop
    Z-Wave Devices via two Z-Net G3s
    Zigbee Devices via RaspBee on RPi 3b+
    WiFi Devices via Internal Router.

    Enabled Plug-Ins
    AK Weather 4.0.5.37,AmbientWeather 3.0.1.9,Big6 3.34.0.0,BLBackup 2.0.63.0,BLGData 3.0.55.0,BLLock 3.0.39.0,BLUPS 2.0.26.0,Device History 3.3.1.0,EasyTrigger 3.0.0.76,Harmony Hub 4.0.14.0,HSBuddy 3.30.1003.1,JowiHue 4.0.8.7,LG ThinQ 4.0.24.0,rnbWeather 4.4.0.0,SDJ-Health 3.1.1.4,TPLinkSmartHome4 2022.12.30.0,UltraCID3 3.0.6681.34300,Z-Wave 3.0.11.0 2

    Comment


      #3
      Try the EasyTrigger plug-in. I use it for my solar calculations, net consumption calculations, etc.

      Comment


        #4
        +1 for EasyTrigger for simple math. It's a nice tool that will many times keep you from having to dive into scripting. The upside of scripting is that you can do just about anything with it. The downside (at least for me) is you have to keep track of the devices you are referencing in scripts and, unlike events, scripts are not searchable from within HS.
        "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

        Comment


          #5
          Also you can create an event with a immediate command, for example:

          &hs.setdevicevaluebyref(123, ((hs.devicevalueex(111) + hs.devicevalueex(222))), True)

          where:

          123: virtual device (you need to create) with the total value
          111: solar power 1 device
          222: solar power 2 device

          Comment


            #6
            Originally posted by racerfern View Post
            Try the EasyTrigger plug-in. I use it for my solar calculations, net consumption calculations, etc.
            I have the easytrigger installed, but I can't see any funktions like this.

            Comment


              #7
              Try following the example I've attached. It's rudimentary but should get you going in the right direction.

              The first expression converts watts to kW
              The second expression add the two legs of the mains together and stores it in a virtual device set up as numeric.
              The third expression subtracts one from another and stores the result in another virtual device.

              Click image for larger version

Name:	Screen Shot 02-24-23 at 01.22 PM.png
Views:	58
Size:	34.1 KB
ID:	1594978

              Comment


                #8
                Thanx, everybody. I ended up using Immediate command, as nunoary‚Äč suggested. It worked perfectly :-)

                Comment

                Working...
                X