Announcement

Collapse
No announcement yet.

Event Executed Twice

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

    Event Executed Twice

    I have created 4 virtual devices (using the Arduino plugin) to control awnings, i.e. open, close, stop/favorite, and program. Each has two states on(100) and off(0). When I want to open the awning I set the open device to 100. An event is then resetting it back to 0. The reason I did not create a device with 4 states is because Alexa only understands on/off or dim but cannot distinguish between different states. In addition, if somebody uses the remote control HS gets out of sync with the state anyways as there is no feedback from the shade.

    The problem I am having is that my event gets triggered twice. That happens both if I trigger the even manually or when I go to device management and set one of the 4 devices to on. How can I prevent the event from being triggered twice?

    Below is the screenshot of the event as well as the logs when I have both the If and Or If statement and when I have the If statement only. *1 shows that the event was executed only once. *2 and *3 shows where the event is executed twice. I can kind of see why the event is executed twice. For instance when I trigger the event manually it sets the virtual device to the on state and that then triggers the event a second time because of the OR IF statement. However, there has to be a way to prevent this from happening when the source of the event and the target are the same.

    IF only:
    Sent to com port No:5 = 1 O 6 0 ,Output Set Command
    *1 Sent to com port No:5 = 1 O 6 100 ,Output Set Command
    Board 1, Device Ref = 772, API Input 2, Value = 3, String = 3
    Board 1, Device Ref = 772, API Input 2, Value = -3, String = -3
    Board 1, Device Ref = 774, API Input 4, Value = 3103

    IF and OR IF:
    Sent to com port No:5 = 1 O 6 0 ,Output Set Command
    Sent to com port No:5 = 1 O 6 0 ,Output Set Command
    Board 1, Device Ref = 772, API Input 2, Value = 3, String = 3
    Board 1, Device Ref = 774, API Input 4, Value = 3108
    Board 1, Device Ref = 772, API Input 2, Value = -3, String = -3
    Board 1, Device Ref = 772, API Input 2, Value = 3, String = 3
    *2 Sent to com port No:5 = 1 O 6 100 ,Output Set Command
    Board 1, Device Ref = 774, API Input 4, Value = 3107
    Board 1, Device Ref = 772, API Input 2, Value = -3, String = -3
    *2 Sent to com port No:5 = 1 O 6 100 ,Output Set Command
    *3 Event Trigger "Blinds Awning 2 - Stop/Favorite"
    *3 Event Trigger "Blinds Awning 2 - Stop/Favorite"

    Event Blinds Awning 2 - Stop/Favorite triggered by the event page 'Run' button.


    Click image for larger version

Name:	AwningEvent.gif
Views:	159
Size:	11.3 KB
ID:	1251369

    #2
    Have you tried setting a 'Do not retrigger' time for the event?
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    Comment


      #3
      Michael, I have tried that. Now the scenario of receiving two events (the *3 in my previous post) disappeared. However, the plugin for whatever reason still sends two commands. As can be seen below, I now only have 1x *3. However, still to commands (*1 & *2) are being sent. That seems to indicate that it could be a plugin issue but then why was the command not sent 4x when two events happened?! Further, when I disable my event that resets the virtual device then only one command is being sent. It's confusing.

      Sent to com port No:5 = 1 O 6 0 ,Output Set Command
      Board 1, Device Ref = 772, API Input 2, Value = 3, String = 3
      Board 1, Device Ref = 774, API Input 4, Value = 3130
      Board 1, Device Ref = 772, API Input 2, Value = -3, String = -3
      *1 Sent to com port No:5 = 1 O 6 100 ,Output Set Command
      Board 1, Device Ref = 772, API Input 2, Value = 3, String = 3
      *2 Sent to com port No:5 = 1 O 6 100 ,Output Set Command
      Board 1, Device Ref = 774, API Input 4, Value = 3129
      Board 1, Device Ref = 772, API Input 2, Value = -3, String = -3
      *3 Event Trigger "Blinds Awning 2 - Stop/Favorite"
      Data Received:Alive 1

      Comment


        #4
        Sounds like it's a question for the PI author. In any case, a self-referencing event is something I would not recommend.
        Mike____________________________________________________________ __________________
        HS3 Pro Edition 3.0.0.548, NUC i3

        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

        Comment


          #5
          Originally posted by mulu View Post
          I have created 4 virtual devices (using the Arduino plugin) to control awnings, i.e. open, close, stop/favorite, and program. Each has two states on(100) and off(0). When I want to open the awning I set the open device to 100. An event is then resetting it back to 0. The reason I did not create a device with 4 states is because Alexa only understands on/off or dim but cannot distinguish between different states. In addition, if somebody uses the remote control HS gets out of sync with the state anyways as there is no feedback from the shade.

          The problem I am having is that my event gets triggered twice. That happens both if I trigger the even manually or when I go to device management and set one of the 4 devices to on. How can I prevent the event from being triggered twice?

          Below is the screenshot of the event as well as the logs when I have both the If and Or If statement and when I have the If statement only. *1 shows that the event was executed only once. *2 and *3 shows where the event is executed twice. I can kind of see why the event is executed twice. For instance when I trigger the event manually it sets the virtual device to the on state and that then triggers the event a second time because of the OR IF statement. However, there has to be a way to prevent this from happening when the source of the event and the target are the same.


          Click image for larger version

Name:	AwningEvent.gif
Views:	159
Size:	11.3 KB
ID:	1251369
          There is not a problem with the plug-in since disabling this event stops the problem.

          First of all, you do not need two triggers when one is a manual trigger. When an event is manually triggered from another event, the run button in the event management or called by Echo o GH, the Trigger is always ignored. Second, the event is triggered by a change in the same device as it is setting. Why are you setting the device to the same value as what triggers the event? I’m guessing you are trying to have the event serve two purposes, but I need to know more about the events that are manually triggering this one. I suggest the smarter approach would be to remove the manual trigger and the setting of the awning to stop/favorite from this event. Then have the event that calls this one instead set the awning to stop/favorite. Then this event would just return it to reset after a second.

          Post a screenshot of any events that manually trigger this event so I can get a better idea of what you are doing.
          HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

          Comment


            #6
            From your original post, it would be completely expected that the event by triggered twice. Its actually running twice, first by your manual activation (first IF link) then in the event you set Downstairs Awning Share to Stop, that then triggers the or/if case since that is the trigger. Since you then set that to Reset a second later, its almost guaranteed that by the next run the Stop will be a change so hence the event runs again. So HS seems to be doing exactly what you asked it to do. As others suggested, I'd split this out to multiple events or (if you are comfortable) personally a small script would be easier as you can deal with all the edge cases you mentioned much easier if you can write if/then/else code...

            Comment


              #7
              I have removed the manual event and things still "work". Apparently, I am misunderstanding manual events. I thought that was required to run one event from another event (unconditionally) but "Run Another Event" is already doing this unconditionally unless I set "Run Only If Other Event Conditions are TRUE", at least that is how it appears to me now. So now I have the following (showing the 'Close' event)

              Click image for larger version

Name:	Awning2Close.gif
Views:	142
Size:	8.4 KB
ID:	1251660
              As for rprade's request for screenshots, there really isn't anything (yet) but here is more information what I try to achieve:

              * Use Alexa's routines. Here I can simply set the virtual "Downstairs Outside Awning 2 Close" to "Close". In this case the "Then Set Device Downstairs Outside Awning 2 Close to Close" isn't necessary.
              * Use HSTouch. Same as above for Alexa routines.
              * Close the awning at a certain time, here 7:00pm. In this case I need the "
              Then Set Device Downstairs Outside Awning 2 Close to Close"
              * Close the awning based on other events (I don't have anything like that yet as I try to get it to work first...). Here I also need the "Then Set Device Downstairs Outside Awning 2 Close to Close"

              I guess I could break them up into two events, one for setting the device to "Close" and one to "Reset" but isn't there a way I can do this all in the same event?

              Comment


                #8
                Originally posted by mulu View Post
                I guess I could break them up into two events, one for setting the device to "Close" and one to "Reset" but isn't there a way I can do this all in the same event?[/SIZE][/FONT][/COLOR][/LEFT]
                Sure. Just don't use an action of the event as a trigger for the same event. (Change the Alexa command?)
                Mike____________________________________________________________ __________________
                HS3 Pro Edition 3.0.0.548, NUC i3

                HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                Comment


                  #9
                  A manually triggered event can ONLY be triggered manually. Any other Event trigger will be ignored if an Event is manually run - by any method. Conditions in a manually run Event are ignored in all cases except when expressly stipulated in a calling Event.

                  Why try to combine it in a single Event when 2 will work? Here is the problem with the rewritten Event above. Assuming the Downstairs Outside Awning ihas a value of "Reset". At 7:00PM the Event will trigger and run. The first step is to set Downstairs Outside Awning 2 to "Close". This will trigger the Event again, causing it to run twice (and create two Delayed Device Actions". That is the reason I suggested to use other events to set the Device to "Close", then create a cleanup event that will toggle the device back to "Reset" after one second. If you are using the device with HSTouch or Echo, they will set it to "Close", triggering the cleanup Event setting it back to "Reset" after a second. A second Event to set it to "Close" at 7:00PM could be created.

                  There is absolutely no compelling reason to avoid creating a second Event. If you think about it logically there are two steps. The first is to set the Arduino pin to "Close". This can be done by voice control, through the Device Manager or HSTouch or be controlled by an Event. There is no need for an event to control the pin as it can be done directly. There is a separate function required to return the pin to "Reset" after 1 second. This Event should run autonomously, no matter what device has set it to Close. I would prefer another method which would avoid creating a delayed event and simply turn the device back off if it has been On for more than two seconds. I do this on a number of devices I want to return to a default state.

                  Click image for larger version  Name:	capture.png Views:	1 Size:	23.9 KB ID:	1251667

                  Alternately with the Arduino standard sketch you can set the output time to 2 seconds and then "one flash" the output as I do for my Arduino pins that reset my Z-Nets like this. Then there is no need to return the pin with another Event.

                  Click image for larger version  Name:	capture1.png Views:	1 Size:	68.5 KB ID:	1251668

                  You could also build that into the API sketch.
                  HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

                  Comment


                    #10
                    Well, I wanted to combine setting the virtual device and then immediately resetting it in order to reduce the number of events and to combine those actions for one device in one event. In any case, apparently that was not a good approach and I see the flawed logic. One thing that confused me is that even when I saw just one event log entry I still did see two commands from the plugin. After creating two events, one for triggering the virtual device and one for resetting it I don't see the two commands from the plugin anymore. Now I just need to figure out why the awning still doesn't work.

                    As for the manually triggered event, I am still confused. What does "manually" means? When I manually (using my mouse) and click on the "Run" button on the HomeSeer event page? Or does that include running an event from another event and not checking the box "Run Only If Other Event Conditions are TRUE"? How about triggering an event from Alexa? Is that a manually triggered event or will this only execute events if other conditions are met?

                    Comment


                      #11
                      As I wrote above Event Triggers are ALWAYS ignored when an Event is run. It doesn't matter if the Event is run from the Event Management page, from another Event, from HSTouch or voice command.

                      The only reason to use "This Event is Manually Triggered" as a Trigger is if you only want the Event to be manually triggered.

                      "Run Only If Other Event Conditions are TRUE" as its name implies only applies to Conditions.
                      HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

                      Comment


                        #12
                        Originally posted by mulu View Post
                        As for the manually triggered event, I am still confused. What does "manually" means? When I manually (using my mouse) and click on the "Run" button on the HomeSeer event page? Or does that include running an event from another event and not checking the box "Run Only If Other Event Conditions are TRUE"? How about triggering an event from Alexa? Is that a manually triggered event or will this only execute events if other conditions are met?
                        In my experience, when discussing their area of expertise, people tend to use words in ways that are distinct from common language usage. It's often called jargon.

                        The "manual" trigger falls squarely into that category. The only reason to use "Manually triggered" as the [non] trigger for an event is if the event is not intended to run based on a specific, predefined trigger, but only when initiated as an action of another event, some other external mechanism (voice activation, HSTouch, etc.), or by the '>' symbol on the event itself. I agree that it is not a name that provides an intuitive understanding of its function, mostly because it is difficult to name something based on what it is not. (I've tried - unsuccessfully, so far - to come up with a name I like any better.)

                        Adding to the confusion is the fact that there are multiple ways to "Manually" trigger an event (that is, not use a predefined trigger). All but one of those ways always ignore the event conditions. Only when an event is run as an action of another HS event is there an option to evaluate the conditions. (My preference would be to reverse that default, but that's a separate issue.)

                        I'm not sure any of that helps, but maybe it will.
                        Mike____________________________________________________________ __________________
                        HS3 Pro Edition 3.0.0.548, NUC i3

                        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                        Comment


                          #13
                          Ah, I think I finally understand. So if you have an event with some triggers, there is absolutely no point in using "This Event is Manually Triggered". That's because even if you don't have "This Event is Manually Triggered", you can still 'manually' trigger that event from other events, Alexa, HS, etc. Basically, that option is only there for the situation where you have an event that will ALWAYS be triggered manually, i.e. it has no other conditions/triggers at all. Since you can't leave the IF field empty, they give you that "This Even Is Manually Triggered" option.

                          Comment


                            #14
                            Originally posted by mulu View Post
                            Ah, I think I finally understand. So if you have an event with some triggers, there is absolutely no point in using "This Event is Manually Triggered". That's because even if you don't have "This Event is Manually Triggered", you can still 'manually' trigger that event from other events, Alexa, HS, etc. Basically, that option is only there for the situation where you have an event that will ALWAYS be triggered manually, i.e. it has no other conditions/triggers at all. Since you can't leave the IF field empty, they give you that "This Even Is Manually Triggered" option.
                            One correction: You can still have Conditions in an Event using that trigger, but they will only be honored when calling from another Event with “Run only if other event conditions are true”. They are not honored under any other circumstances.

                            HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

                            Comment


                              #15
                              rprade, indeed, that makes sense. Wow, it took an embarrassing long time to figure out what this manually triggered event is....

                              Comment

                              Working...
                              X