No announcement yet.

How to make simple math

  • 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?

    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
    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,AmbientWeather,Big6,BLBackup,BLGData,BLLock,BLUPS,Device History,EasyTrigger,Harmony Hub,HSBuddy 3.30.1003.1,JowiHue,LG ThinQ,rnbWeather,SDJ-Health,TPLinkSmartHome4 2022.12.30.0,UltraCID3 3.0.6681.34300,Z-Wave 2


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


        +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)


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

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


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


            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.


              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


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