Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting double plugin in plugin list and LOADING.... on homepage
#1
Dan,
 
    I'm writing a plugin that uses weewx weather station to emulate the rain sensor function. With a bit of mods to helpers, gpio_pins, and sip I can pass the output of the plugin to the "rain_sensor" value in helpers, no tracebacks. However, when I print out the plugins.__all__ variable it only shows 1 instance of my plugin in the list. But on the homepage dropdown there are 2 in the list and the stations all show "LOADING......"  I'm using version 4.1.51.

   I  disable my plugin and just let the fake_gpio library control the rain_sensor it randomly changes between 1 and 0, stations, all load and homepage functions as expected. I'm sure I'm creating some kind of loop. in sip.py the tweak I made was to assign plugins.__all__ to a global that I could pass to helpers.py so that I can see if the plugin is loaded to ensure that the rain_sensor variable is being set in the check_rain() subroutine. That all seems to work fine. Just don't understand the problem I've created with the plugin to cause the problem.

Thanks,

  Bryan

Update: Nevermind. Just had to use a gv.sd and add an new global value for the wx_rain_sensor value to pass between plugin and helpers and issue went away.
Reply
#2
Hi Bryan,

Glad you got it working!

The only problem with tweaking the core program code is that you will need to make the same changes again if you upgrade SIP to a newer version.

You might be able to avoid that problem by using git to commit or stash your changes locally and then using git pull to do the update.

Dan
<p><br></p>
Reply
#3
Dan,

     Your correct. I saw the new 5.0 release and decided to upgrade to that. So now I'm rethinking how I do it. As a newbie, I have not used Git in the past. But will look at that.  At one point in the past you indicated that I could fake the rain_sensed using gv.sd[u"rst"] but I could not figure out how to make that work.

     Re-evalutating things it almost looks simpler to load a different version of check_rain module from the rain sensor emulation plugin that I'm writing versus the one from helpers. That limits the changes to sip.py and the plugin. I just do a detect if plugin loaded to set this up.

     There are also a couple of gpio emulator packages out there that use a GUI to emulate state of gpio pins. I plan to take a look at that as well, that would eliminate the need to change code if I can integrate it into the plugin.

 
Thanks,

    Bryan
Reply
#4
(2023 Sep 05, 01:36 PM)tutqiunnh Wrote: Dan,

     Your correct. I saw the new 5.0 release and decided to upgrade to that. So now I'm rethinking how I do it. As a newbie, I have not used Git in the past. But will look at that.  At one point in the past you indicated that I could fake the rain_sensed using gv.sd[u"rst"] but I could not figure out how to make that work.

     Re-evalutating things it almost looks simpler to load a different version of check_rain module from the rain sensor emulation plugin that I'm writing versus the one from helpers. That limits the changes to sip.py and the plugin. I just do a detect if plugin loaded to set this up.

     There are also a couple of gpio emulator packages out there that use a GUI to emulate state of gpio pins. I plan to take a look at that as well, that would eliminate the need to change code if I can integrate it into the plugin.

 
Thanks,

    Bryan

Bryan,
Keep us posted on your progress especially the use of the gpio emulator.

Thanks.
Dan
<p><br></p>
Reply
#5
Dan,
 
   Unfortunately, a the emulators only work in the python environment where GPIO are replaced with "fake" GPIO requiring me to change gpio_pins.py.

 However, I was able to get it working with 2 simple changes.
      1) Added a new global to gv.py called "wx_rs" to pass the result of the weather station rain sensor output to SIP.
      2) Change the except NameError: (line 265) in the check_rain module  of helpers.py to replace the "pass" with:
                         plugin_list = [item[0] for item in gv.plugin_menu]
                         if "Weewx Rain Sensor" in plugin_list :
                                   rain_sensor = gv.sd["wx_rs"]
                         else :
                                   pass

If the sensor plugin is in the active plugin menu sets the rain_sensor variable to the global from the plugin, if not just does the same as before when no gpio are present for rain sensor.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)