Announcement

Collapse
No announcement yet.

Is this the correct way of entering a mathematical expression to a device?

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

    Is this the correct way of entering a mathematical expression to a device?

    Hi!

    Set Device
    "Power management Unknown Average rackord of 3hours a month" (Power consumption kWh)
    to
    $$DVR:R939:+$$DVR:R941:+$$DVR:943:/3

    Is this the correct way to type the expression? Device 939 + device 941 + device 943 divided by 3, and the result will be written to device
    "Power management Unknown Average rackord of 3hours a month" (Device: 945)?

    Thanks!

    #2
    try :

    ($$DVR:939:+$$DVR:941:+$$DVR:943 : ) /3

    ignore spaces, just avoiding smilies.

    Comment


      #3
      Thanks for your reply.

      I am not getting a result on the receiving device as of now. This is how it looks in HS:
      Attached Files

      Comment


        #4
        I'm pretty sure (have not done it in a while) you need to put spaces around the mathematical operators like + and /

        Comment


          #5
          Hi.

          I checked my LOG file: There is this message:
          06.07.2022 19:18:09
          Legacy-Plugin
          EasyTrigger
          ERROR mismatched input ',' expecting ')' at line 1:2 missing EOF at ',' at line 1:8


          My devices values are set-up with 1.234, but the status values are 1,234 using a comma.

          I wonder if Easytrigger use the status values for it's calculations, and my use of comma's are the culprit.


          Attached Files

          Comment


            #6
            Maybe. I have a similar event and in my case both the status and the value use the "." as a separator. If so, you may need to check your HS PC's region settings. However, I leave here my formula applied to your case.

            &hs.setdevicevaluebyref(945, (((hs.devicevalueex(939) + hs.devicevalueex(941) + hs.devicevalueex(943)) / 3)), True)

            Comment


              #7
              Thanks for your reply.

              Is this the correct formula to use for my expression to work in the "Set device to expression" event?
              I tried to apply the formula, but another error showed up: ERROR no viable alternative at input '&' at line 1:0 missing EOF at 'setdevicevaluebyref' at line 1:4

              OR, is this formula to be used in "Run script or command"?

              I will have to wait until i get home next week, to set the local PC to see if there is any affect from changing the regional settings.

              Thanks!

              Comment


                #8
                To be used in "Run script or command".

                Comment


                  #9
                  Originally posted by nunoary View Post
                  To be used in "Run script or command".
                  Thanks!

                  Scripts is one of my priorities for what to do next..

                  There sems to be a problem somewhere:

                  Do you got the time to explain what to look for here? I got experience from ISO-programming (CNC-etc) I just need to learn this new language.. :
                  Attached Files

                  Comment


                    #10
                    Check the boxe “immediate command". Save .
                    You will see the event form changing.

                    Then enter
                    Code:
                    &hs.setdevicevaluebyref(945, (((hs.devicevalueex(939) + hs.devicevalueex(941) + hs.devicevalueex(943)) / 3)), True)
                    there

                    Comment


                      #11
                      Yes. Like pistacheL0 wrote. Delete the command you put on "Sub or Func" and "Parameters" then check the box “immediate command" and finally put that command in "command"

                      Comment


                        #12
                        Originally posted by pistacheL0 View Post
                        Check the boxe “immediate command". Save .
                        You will see the event form changing.

                        Then enter
                        Code:
                        &hs.setdevicevaluebyref(945, (((hs.devicevalueex(939) + hs.devicevalueex(941) + hs.devicevalueex(943)) / 3)), True)
                        there
                        You Guys are the best! It works!

                        Comment


                          #13
                          There is another challenge I have trouble figuring out how to solve.

                          There are a new way of calculating charges for electricity-consumption here now. Your average consumption (kWh) tell how much you pay each month.

                          The rules are:
                          To make it easier for the consumer,(stated by the electricity companies), the average is the average of 3hours, power-records if you like, on three separate days.

                          So, you cannot have two or three records the same day.

                          The average kWh-consumption each month in steps tell charge the power-tax for over-consumption.
                          Steps:
                          0-2kWh
                          2-5kWh
                          5-10kWh
                          10-15kWh
                          and so on... ---> 100kWh.

                          I want to run within the consumption-step I have gotten into. If I already have passed the 5kWh limit, there is no point trying to keep within 5kWh, I can then jump to the 10kWh limit.

                          The average number and the smallest of the three records must be at focus, because I always want to replace the lowest record of the three.

                          An example: If my average value already is 4,99kWh, based on record 1@6kWh, record 2 @ 5kWh, and record 3 @ 3,97kWh, I cannot go past record 3, to keep within the 5kWh limit.

                          I already got a value from my electricity provider on the api named: AccumulatedConsumptionThisHour, it gives me the actual consumption this hour, and I can compare this value to my saved record, just before the top of every hour. The device reset on the top of every hour.


                          So much for making it easy! One hour was unfair, but it was easy to relate to. Now there is three values, on three different days!

                          Do you got the time to help me move in a direction?


                          Edit: I just had a epiffany:

                          If I make a new monthly record one day, lets use the above example, at 6kWh, that means that within THAT day, it is possible to use up to 6kWh every other hour after this record.
                          If we stick to the above example and the same numbers, and day we get the 6kWh record on record 1 (from.. say 3kWh), it is possible to charge your electric veichle, heat your house, water and use up to 6kWh every hour until midnight.
                          After midnight, the limit will be record 3, that is 3,97kWh..

                          I need to learn scripting, and get good at it.
                          Last edited by Join; July 7, 2022, 08:08 PM. Reason: Epiffany

                          Comment

                          Working...
                          X