Announcement

Collapse
No announcement yet.

I struggle to understand how to use Triggers in HS4

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

    #16
    Originally posted by Bernold View Post
    alexbk66: That issue on GitHub is closed, but it ends with you going to check. I wonder if the issue needs to be reopened.
    I don't think I tested - if it takes more than a year...

    Comment


      #17
      Originally posted by alexbk66 View Post

      I don't think I tested - if it takes more than a year...
      Thanks for your reply. That makes sense. Think I'll give it another try though.

      Comment


        #18
        Originally posted by Bernold View Post
        alexbk66: That issue on GitHub is closed, but it ends with you going to check. I wonder if the issue needs to be reopened. I'm relatively new to triggers, so I'm not sure it's just me. What I do know is that I avoided IsFullyConfigured(). I believe I used GetPrettyString() instead as a workaround, to lower the amount of calls. Which is madness. If anyone can confirm, the issue should just be reopened for better performance.

        Here is what I see when I add Console.WriteLine(DateTime.Now) to IsFullyConfigured() in the Sample Plugin CS as a test:
        - Create an event and pick Sample Trigger as a trigger: called 3 times within the same second
        - Pick any of its 4 subtriggers: 3 calls
        - Save the trigger: 4 calls(!)
        - Opening the Events page: 1 call(?)
        - Reopening the specific event: 3 calls
        Definitely go look at the github issues. The 'dips' into each plugin's actions/triggers is really more than I would have expected.
        HS4Pro on a Raspberry Pi4
        54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
        Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

        HSTouch Clients: 1 Android

        Comment


          #19
          I implemented the AbstractTrigger class and also implemented the method IsTriggerTrue method. I am able to configure the trigger from the Events page. But the trigger is not fired. Do I need to fire it manually from my plugin code?

          Comment


            #20
            Originally posted by hembhagat View Post
            Do I need to fire it manually from my plugin code?
            Yes, call hs.TriggerFire()

            Click image for larger version

Name:	Screenshot 2022-12-01 010357.png
Views:	81
Size:	24.8 KB
ID:	1577981

            Comment


              #21
              alexbk66 Can you guide me on how to fire a trigger from the plugin? Because I am really confused with this.

              My requirement is, I have implemented the IsTriggerTrue method to check whether the Trigger should be fired. Now I want it to just fire when the condition is true. What do I need to do in the plugin to achieve this? I don't want any user interaction for firing the trigger. That is no Button/UI Control to fire the trigger. Whenever the IsTriggerTrue returns true I need the trigger to be fired.

              Comment


                #22
                Please read docs https://homeseer.github.io/Plugin-SD...iggerType.html

                Also there's a sample plugin https://github.com/HomeSeer/Sample-Plugin-CS

                TriggerTrue() is "Called by HomeSeer when a trigger needs to be evaluated as a condition" - meaning that this is only called when there's some "main" trigger setup, then HS checks this trigger is used as condition (i.e. AND) and if its condition is met. But "bool isCondition" argument is confusing because my understanding is that it's only called for condition anyway.

                Comment

                Working...
                X