Ad Widget

Collapse

How to add trigger that fires if mqtt item has value for specific duration?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • admin@hilton
    Junior Member
    • Jun 2022
    • 7

    #1

    How to add trigger that fires if mqtt item has value for specific duration?

    I have an mqtt item `mqtt.get[,"fitness_room/online"]` that is Numeric and only have the values 1 and 0.

    I now want a trigger that fires if the value is 0 for 5 minutes (then the device is offline for more than 5 minutes).
    I tried the following:
    ```
    max(/Fitness Room ESP/mqtt.get[,"fitness_room/online"],5m)=0
    ```
    but this fires even if the value is 0 for just a second. I guess the problem is that there is no other value in the last 5 minutes so 0 is the only value (even if the previous value was 1).
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    How often do you check? Your expressions seems fine, if you check more often that 5m ... it is a rolling 5m window, what is considered, so it should only fire after 5m of 0-es is there.. if you only check once in 10m then yea, it will trigger pretty much right away.

    Comment

    • admin@hilton
      Junior Member
      • Jun 2022
      • 7

      #3
      > How often do you check?

      Do you mean how often I check/pull the value? Since the value of the mqtt key is provided via an active agent I have no control over it. A value is only send if the state changes, so when the devices goes offline or online.​

      Comment

      • admin@hilton
        Junior Member
        • Jun 2022
        • 7

        #4
        I think I could use the following:
        ```
        last(/Fitness Room ESP/mqtt.get[,"fitness_room/online"])=0
        and
        nodata(/Fitness Room ESP/mqtt.get[,"fitness_room/online"],5m)​
        ```

        Comment

        • cyber
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2006
          • 4807

          #5
          Sry, I totally overlooked, that the mqtt thing is not the normal polling thing..

          nodata(/host/item,5m)=1 then. Function has to have some kind of value... 1 or 0 in this case...

          Comment

          • admin@hilton
            Junior Member
            • Jun 2022
            • 7

            #6
            From https://www.zabbix.com/documentation...istory#nodata:
            Returns: 1 - if no data received during the defined period of time; 0 - otherwise.
            So `nodata(...)` and `nodata(...) = 1` are the same.

            Comment

            Working...