Announcement

Collapse
No announcement yet.

Scripting for device value

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

    Scripting for device value

    Hi folks....script n00b.

    I have a dryer that reports "power", I have this as a homeseer device and its reported to HS via a Sonoff/mqtt device.

    What I need to do...

    Dryer sends updates every 100 seconds.
    When power > 300 the dryer is on
    When finished the power bounces between 0-1

    Clearly I've set the event when power = 0 then event... Problem is when its in the "soft off" mode it still can pull current ie: 0-1 watt. This retriggers my "dryer is off event".

    So what I'm thinking:
    If the device power > 300 then create an event . This newly created event should run when the power = 0 (dryer finished) What I need to do is create the new event ONCE and not "device changes value greater than 300 as it will keep creating an event on every update over 300 ?

    Maybe the test is, if its over 300 and the event doesnt exist, create it. Clearly I want to delete the "power off" event once its run to stop it bouncing when the value goes up to 1 and back to 0.

    ANy thoughts ?

    Pete
    HS 2.2.0.11

    #2
    Hmm

    I'm thinking have 2 events......

    Event1: (Dryer on)
    If hs.DeviceValue > 300
    Enables event 2
    disables itself

    Event2: (Dryer off)
    If hs.DeviceValue=0
    Enables event 1
    Disables itself

    So this would run the ON (>300 power) once and OFF (=0) once

    Is this over complex ?

    Pete
    HS 2.2.0.11

    Comment


      #3
      Originally posted by petez69 View Post
      Hi folks....script n00b.

      I have a dryer that reports "power", I have this as a homeseer device and its reported to HS via a Sonoff/mqtt device.

      What I need to do...

      Dryer sends updates every 100 seconds.
      When power > 300 the dryer is on
      When finished the power bounces between 0-1

      Clearly I've set the event when power = 0 then event... Problem is when its in the "soft off" mode it still can pull current ie: 0-1 watt. This retriggers my "dryer is off event".

      So what I'm thinking:
      If the device power > 300 then create an event . This newly created event should run when the power = 0 (dryer finished) What I need to do is create the new event ONCE and not "device changes value greater than 300 as it will keep creating an event on every update over 300 ?

      Maybe the test is, if its over 300 and the event doesnt exist, create it. Clearly I want to delete the "power off" event once its run to stop it bouncing when the value goes up to 1 and back to 0.

      ANy thoughts ?

      Pete
      I know you are discussing scripts but if you have the EasyTrigger pi then for detecting when an appliance has finished I use an event with the trigger:
      This device has been in the range [X,Y] for exactly...
      For example my dishwasher drops to 1 or 2 watts for short periods of time during it's cycle, particularly towards the end where it does it two or three times for about a minute each. I use an event with the trigger:
      This device has been in the range [0,3] for exactly 2 minutes
      I set a virtual device to Running with an event that detects power draw above a certain value and then the above event sets it to Finished at the end of the cycle.

      Steve

      Comment


        #4
        OK, this seems to work, it enables and disables the opposing script :-)

        Not elegant ??
        Attached Files
        HS 2.2.0.11

        Comment


          #5
          Originally posted by petez69 View Post
          OK, this seems to work, it enables and disables the opposing script :-)

          Not elegant ??
          If it works then great, there are many ways to accomplish the same thing.

          Just for completeness I have added an image of my typical events for an appliance. I then use the virtual device to trigger all sorts of things including notifications depending on time of day and occupancy, etc.

          Steve
          Attached Files

          Comment


            #6
            Thanks Steve for your input.

            I was playing with virtual devices and it got bigger than Ben Hur :-) I decided I really dont need the devices though in thinking, maybe I will setup a virtual device to show if its on or off :-) Just a status device and have a script change its value....

            Heh heh its all fun. I need to be carefull I dont break stuff, if the dryer wont start I will be in a world of hurt due to "she who must be obeyed" :-)

            CHeers & thanks :-)
            HS 2.2.0.11

            Comment


              #7
              Originally posted by petez69 View Post
              I need to be carefull I dont break stuff, if the dryer wont start I will be in a world of hurt due to "she who must be obeyed" :-)
              It can take a long time to be forgiven for a slight slipup in event logic

              Steve

              Comment


                #8
                Originally posted by SteveMSJ View Post
                It can take a long time to be forgiven for a slight slipup in event logic

                Steve
                Steve

                Credibility takes years to achieve....A 'glitch in the space time continuum" can destroy years of hard work :-)

                The SONOFF device always defaults to the "on" mode so hopefully the worst that can happen is there is no notification. The dryer is downstairs and you just cant hear the beeps ;-)

                Pete
                HS 2.2.0.11

                Comment

                Working...
                X