Announcement

Collapse
No announcement yet.

Daily rain sensor not reseting to zero at midnight

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

    Daily rain sensor not reseting to zero at midnight

    I noticed my daily rain fall (S68) is no longer resetting to zero at midnight. Instead it's stuck at prior day's value, until the sensor detects rain again.

    Here is my setup:

    mcsSprinklers: v2.22.0.4, stand alone version, running in Windows.

    Oregon Scientific rain sensor, connected to HS3 via RFXCOM plugin. The plugin creates a daily rain fall virtual device in HS, which measures total rain fall for the day and it resets to zero at midnight. The daily rain fall value from HS is sent through mcsMQTT to mcsSprinilers.

    Every time when sensor detects rain, HS device should change, and it is correctly updated in mcsSprinlers (S68).

    At midnight, daily rain fall will reset to zero in HS, but S68 in mcsSprinklers (and its corresponding time stamp) stays at last value instead of resetting to zero.

    I remember mcsSprinklers restart everyday at midnight. Is it possible when rain sensor reset to zero at midnight, mcsSprinklers is also in the middle of restarting, so the MQTT message gets lost?

    The same setup worked as expected last season, the only changes I can remember are updating mcsMQTT plugin and mcsSprinklers.

    #2
    If you are using daily rainfall sensor then mcsSprinklers should be setup for the daily option. This will tell mcsSprinklers to use the sensor as-is. If you used the raw sensor from Oregon Scientific then mcsSprinkleres would be setup for total option and then at each midnight would reset the daily to 0 and do the calculation to accumulate the daily result. The preferred method is to use the daily amount being reported via HS3. Even if an update is missed, it would be corrected on the next mqtt message.

    Comment


      #3
      I am using daily rainfall in HS3. I verified it is working properly in HS. It's reset to zero everyday at midnight.

      Click image for larger version

Name:	rain.gif
Views:	92
Size:	39.5 KB
ID:	1546797

      In mcsSprinilers I also already selected "Daily total" in "weather setup".

      Click image for larger version

Name:	sprinklers.gif
Views:	97
Size:	33.3 KB
ID:	1546795

      At midnight, when HS3 reset daily rainfall to zero, mcsSprinklers S68 doesn't get that message. It also appears that mcsMQTT doesn't send another message unless daily rainfall sensor in HS3 changes. So if it doesn't rain today, yesterday rainfall gets copied over for today in mcsSprinklers.

      Click image for larger version

Name:	S68.gif
Views:	83
Size:	41.9 KB
ID:	1546796

      Click image for larger version

Name:	history.gif
Views:	87
Size:	51.3 KB
ID:	1546798

      Comment


        #4
        Take a look at the Edit tab for your virtual device. It should have a callback on Value Set Event. This way every time the HS device is updated it will send a MQTT message.

        Click image for larger version

Name:	0.png
Views:	90
Size:	7.6 KB
ID:	1546814

        Comment


          #5
          In mcsMQTT plugin I already have both "Value Change Event" and "Value Set Event" checked. Do I need to uncheck "Value Change Event"?

          Click image for larger version

Name:	mqtt.gif
Views:	98
Size:	102.3 KB
ID:	1546852

          Comment


            #6
            Having both checked is what you want. Look at mcsMQTT Debug. There are HSEvent lines and see how often device 269 is being updated by RFXCOM. My guess is that it only updates on a change of value rather than each time the rain sensor provides a transmission. If this is the case then you ran run a periodic event that sets 269. For example &hs.SetDeviceValueByRef(269,hs.DeviceValue(269),true) to generate the HSEvent triggers. Every 30 minutes should be fine.

            Comment


              #7
              A more elegant approach to dealing with communications when the client may not be in a state where it can receive data is to use the Retain flag in the MQTT published message. This is a setting on the Edit tab of mcsMQTT. The MQTT Broker will hold the last value received from mcsMQTT and whenever a subscribed client, such as mcsSprinklers, transitions to online the Broker will send the message.

              Comment


                #8
                I setup an event to update rain sensor a few minutes after midnight as you suggested (only change I made was using hs.Device.ValueEx so reading doesn’t get rounded to integer). It has been working as expected.

                I do like the more elegant approach of Retail flag in MQTT. I found that flag on both Edit tab and General tab. Does the Retail flag on General tab control default setting for all messages? Is there a downside of making this the default behavior for all messages vs only setting it for the rain sensor?


                Sent from my iPad using Tapatalk

                Comment


                  #9
                  One downside is that each time the client reconnects to the MQTT Broker it will receive a flood of all the messages that client has subscribed and have been marked as Retain. The second is situations where the message is used as an event trigger. This means the event will be triggered each time the client reconnects. The third is that messages that you no longer desire to see such as those having been obsoleted will show up again. This is unless you remote the Retain flag from the Broker. This can be done from the General tab of mcsMQTT in a manner similar to done to remove obsolete.

                  Comment


                    #10
                    Michael, I enabled "retain at broker" on the rain sensor on mcsMQTT edit page, but left setting on general page at "not retain". When daily rainfall resets to zero at midnight in HS, on most days, S68 in mcsSprinklers resets to zero as well, but there are still occasions S68 is stuck at previous days value. The device value in HS always resets to zero at midnight, so that is not the cause of the problem. Any suggestions how I can debug this?

                    Comment


                      #11
                      mcsSprinklers debug contains the updates such as below. UpdateSensorReading should be called each time the input source has available a new reading when the one-minute polling of sensor data occurs. mcsSprinklers new hour/new day starts at 7 minutes past the actual hour. This was done so sensor data has a chance to stabilize from the source and race conditions are minimized. I would expect mcsSprinkles to see a new day at 12:07.

                      Code:
                      6/9/2022 7:13:28 AM 637903556086058280 | mcsSprinklers Debug | SaveDeviceToDB S68, Name=Rain Sensor, LastChange=6/9/2022 7:13:28 AM
                      6/9/2022 7:13:28 AM 637903556086060090 | mcsSprinklers Debug | UpdateSensorReading Field=Rain, Value=4
                      To avoid timing issues and sensitivity to communications you can setup the rain sensor the same way I do it on my system where I let mcsSprinklers receive the raw data from the sensor and it will do the total to daily conversions.

                      Click image for larger version

Name:	1.png
Views:	78
Size:	10.4 KB
ID:	1551393

                      Click image for larger version

Name:	0.png
Views:	67
Size:	42.3 KB
ID:	1551394

                      Comment

                      Working...
                      X