Announcement

Collapse
No announcement yet.

Event not firing if value already set

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

  • Event not firing if value already set

    Hello and thank you for your time.

    I am developing a handheld remote that uses mqtt for the button press. The remote will have four buttons.

    If I the current value of the virtual device is for button one and I press button one again the last updated column changes but the event for button one does not fire again.

    I have disabled the "Do not update device last change time
    if device value does not change:" option in the configuration of the virtual device but it still does not work.

    Values of the button are 1 - 4, I have written a work around by adding the value 0 and writing a trigger that when the device value changes above 0 the trigger sets the value back to 0.

    Any ideas.

    Cheers and thank you for this awesome plugin.

  • #2
    Originally posted by the-wal View Post
    Hello and thank you for your time.

    I am developing a handheld remote that uses mqtt for the button press. The remote will have four buttons.

    If I the current value of the virtual device is for button one and I press button one again the last updated column changes but the event for button one does not fire again.

    I have disabled the "Do not update device last change time
    if device value does not change:" option in the configuration of the virtual device but it still does not work.

    Values of the button are 1 - 4, I have written a work around by adding the value 0 and writing a trigger that when the device value changes above 0 the trigger sets the value back to 0.

    Any ideas.

    Cheers and thank you for this awesome plugin.
    If you are using the Virtual Device in an Event as a Trigger, use "This device had its value set to..." instead of "This device changes and becomes...". This will allow a trigger on the device being updated, even if its value does not change.
    Randy Prade
    Aurora, CO
    Prades.net

    PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

    Comment


    • #3
      Thanks for your speedy response. I have the event using "had its value set to" already.

      I am assuming the developer is using hs.SetDeviceValueByRef to set the value of the device, this function has an option to set the value but not trigger any devices.

      https://www.homeseer.com/support/hom...lp/default.htm

      Thanks again

      Comment


      • #4
        Take a look at post #31 at the thread https://forums.homeseer.com/showthre...=194848&page=2. More information is needed to diagnose your specific situation.

        For the mcsMQTT devices the trigger flag is set true and SetDeviceValueByRef is used. If the Payload does not fit into a number then SetDeviceString with the trigger flag set true is used. If it is not a mcsMQTT device then it is CAPI and mcsMQTT does not set either of these.

        Comment


        • #5
          Thanks Michael.

          The virtual devices is created by your plugin, and the payload attribute name is BTN and the value is a number between 1 and 4.

          I upgraded to 3.2.6.1 with no change.

          For now I will have to stick to have an event setting the value back to 0

          Thanks again for your time.

          I looked at the post you pointed me to and it did't help, good to know about the special cases of case-insensitive ON, OFF, OPEN, CLOSE mapping as I am also building a door sensor.

          It has special cases of case-insensitive ON, OFF, OPEN, CLOSE

          Comment


          • #6
            The Button attribute is associated with Topics published by mcsMQTT. It is used to establish the Value-Status-Pairs that are presented in the UI for user control and by HS to know how to use DeviceValue and DeviceString to show a Device Status.

            If the received payload for this topic is a number between 0 and 4 then when the topic is received it should go into the DeviceValue and changes in DeviceValue can be used to trigger events.

            If the received payload is something like Dim0, Dim25, Dim50, Dim100 then these will be treated as DeviceString.

            Just thinking about it now, I could also do a lookup vs. the defined VSP and if the Status of the Value matches the Payload then I could update DeviceValue. This would be a more generic approach that just the four special cases. The user can define any VSP relationships using Device Management page.

            What is your specific case of subscribe vs. publish topic for this device and what payloads are you expecting?

            Comment


            • #7
              I reviewed the code and see that I only set the trigger flag on a SetDeviceValue if there is a change in the value. I changed it in 3.2.7.0 to always trigger even if no change in what is being written to DeviceValue.

              I also looked into searching the VSP for a textual match of payload. I remember now why I did not implement it before. The Status (rendered text associated with a value) was made Write-only in the API so I am not able to search and do a reverse lookup to set DeviceValue based upon a Text payload except in the 4 special cases I defined.

              Comment


              • #8
                Originally posted by Michael McSharry View Post
                The Button attribute is associated with Topics published by mcsMQTT. It is used to establish the Value-Status-Pairs that are presented in the UI for user control and by HS to know how to use DeviceValue and DeviceString to show a Device Status.

                If the received payload for this topic is a number between 0 and 4 then when the topic is received it should go into the DeviceValue and changes in DeviceValue can be used to trigger events.

                If the received payload is something like Dim0, Dim25, Dim50, Dim100 then these will be treated as DeviceString.

                Just thinking about it now, I could also do a lookup vs. the defined VSP and if the Status of the Value matches the Payload then I could update DeviceValue. This would be a more generic approach that just the four special cases. The user can define any VSP relationships using Device Management page.

                What is your specific case of subscribe vs. publish topic for this device and what payloads are you expecting?
                Thanks Michael I will try it when I get home tonight.

                As for my payload I use json with two values.
                {"BTN":1, "Vcc":3.2}

                I use Jon00's grouping page to group both virtual devices into a single grouped device and it looks great.

                I have even retired one of my own plugins and replaced with mqtt using your plugin.

                Thanks again for your awesome work.

                Comment


                • #9
                  Both Payloads of 1 and 3.2 should map directly into DeviceValue. It may be the case that you will use the RegEx field to change 3.2 to 3,2 if your regional setting expect the comma for decimal indicator. The manual has an example of this transformation (\. pattern and , for replace without checkbox).

                  You appear to be getting what you want with the groupings. FYI, mcsMQTT will also group the JSON devices under the Topic as a single group if that is selected on the General Tab for Inbound (Subscription).

                  If you are not getting what you expect then we can figure it out as it is intended to do what you desire.

                  Comment

                  Working...
                  X