Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Submitting a new plugin
#1
I want to submit a new plugin (ssd1305) based on ssd1306 but it handles the adafruit SD1305 4567 132x64 (4 row oled display).
I also want to submit some changes/fixes to the SSD1306 plugin and a few changes to sip.py and a few other modules.

I haven't used git in a while but I think I know how to submit a request for a pull.
But there appears to be a different sequence for submitting plugins.
Reply
#2
Hi Randy,

The procedure for plugin pull requests is about the same as for SIP updates but the plugins are in a separate GitHub repo:
https://github.com/Dan-in-CA/sip_plugins

A couple of things to note:
The SIP plugin manager uses the README.md file in the repo to list plugins that can be installed.
The *.manifest file for each plugin lists the files that need to be installed and their locations under the SIP directory.

Let me know if you need further instructions.

Dan
<p><br></p>
Reply
#3
Do you know how to contact the person that wrote the SSD1306 plugin?  I would like to know which exact device (OLED or other) he tested with, so I can verify my changes didn't break his device.  I have the Adafruit 4567 (https://www.adafruit.com/product/4567) wich uses the SSD1305 controller and just bought the 3531 (https://learn.adafruit.com/adafruit-128x...i/overview) which uses the SSD1306, but it may not be the one he tested with.
Reply
#4
(2023 Jan 21, 12:35 AM)RandyBryant Wrote: Do you know how to contact the person that wrote the SSD1306 plugin?  I would like to know which exact device (OLED or other) he tested with, so I can verify my changes didn't break his device.  I have the Adafruit 4567 (https://www.adafruit.com/product/4567) wich uses the SSD1305 controller and just bought the 3531 (https://learn.adafruit.com/adafruit-128x...i/overview) which uses the SSD1306, but it may not be the one he tested with.

The plugin was contributed by this user:
https://nosack.com/sipforum/user-890.html
You could try sending him a private message from this forum.

On another matter, you mentioned that you would like to submit some updates to the core SIP code. That would be fine but please submit any pull requests for the P3-only (Python3 only) branch. That will be replacing the current master branch in the near future.

Dan
<p><br></p>
Reply
#5
I will change to the P3 branch as requested.

Another question.  I think I have found a small bug having to do with the keypad plugin (and possibly other plugins).
Certain changes that it makes to the global variables, do not appear in the Gui unless I refresh the Gui.
Other changes do show up, but not until the the next status update (which is fine).

Seems something is missing when a plugin makes certain changes, seems that the plugin needs to tell SIP to update the GUI, or the next status update fails to report certain changes.

In particular, the "en" (enabled) status is changed by the keypad, but does not show up in the Gui until one does a refresh.

Thanks!
Randy
Reply
#6
Hi Randy,

The problem of certain changes not showing up in the UI until a page refresh is due to the fact that the changes happen on the server (raspberry pi) side and are not pushed to the browser until a refresh is done.

I have been looking into a way for the server to cause a page refresh on the browser but I have not found a simple solution. If you have any ideas on how to accomplish this I would be very interested.

Dan
<p><br></p>
Reply
#7
(2023 Jan 26, 03:18 PM)dan Wrote: Hi Randy,

The problem of certain changes not showing up in the UI until a page refresh is due to the fact that the changes happen on the server (raspberry pi) side and are not pushed to the browser until a refresh is done.

I have been looking into a way for the server to cause a page refresh on the browser but I have not found a simple solution. If you have any ideas on how to accomplish this I would be very interested.

Dan

I have limited WEB programming experience, but I'll investigate.

What causes the station updates when the keypad starts a program run?  The run times/status shows up with out doing a refresh.

Randy
Reply
#8
(2023 Jan 26, 03:56 PM)RandyBryant Wrote:
(2023 Jan 26, 03:18 PM)dan Wrote: Hi Randy,

The problem of certain changes not showing up in the UI until a page refresh is due to the fact that the changes happen on the server (raspberry pi) side and are not pushed to the browser until a refresh is done.

I have been looking into a way for the server to cause a page refresh on the browser but I have not found a simple solution. If you have any ideas on how to accomplish this I would be very interested.

Dan

I have limited WEB programming experience, but I'll investigate.

What causes the station updates when the keypad starts a program run?  The run times/status shows up with out doing a refresh.

Randy

The way the stations are updated when a program is running is that the home page requests a status update from the server once a second (templates/home.html line ~76). It gets an update from the api_status class in webpages.py (line ~645) which sends a JSON formatted list of status data. JavaScript on the home page updates the display.

You can see the status data at <SIP url>/api/status

I have been tinkering with HTML Server-Sent Events (SSE) to force a page refresh on the browser. One big problem is that if a plugin changes the value of a SIP variable there is no easy way to detect the change unless the plugin notifies the core program.

Dan
<p><br></p>
Reply
#9
(2023 Jan 27, 03:55 PM)dan Wrote:
(2023 Jan 26, 03:56 PM)RandyBryant Wrote:
(2023 Jan 26, 03:18 PM)dan Wrote: Hi Randy,

The problem of certain changes not showing up in the UI until a page refresh is due to the fact that the changes happen on the server (raspberry pi) side and are not pushed to the browser until a refresh is done.

I have been looking into a way for the server to cause a page refresh on the browser but I have not found a simple solution. If you have any ideas on how to accomplish this I would be very interested.

Dan

I have limited WEB programming experience, but I'll investigate.

What causes the station updates when the keypad starts a program run?  The run times/status shows up with out doing a refresh.

Randy

The way the stations are updated when a program is running is that the home page requests a status update from the server once a second (templates/home.html line ~76). It gets an update from the api_status class in webpages.py (line ~645) which sends a JSON formatted list of status data. JavaScript on the home page updates the display.

You can see the status data at <SIP url>/api/status

I have been tinkering with HTML Server-Sent Events (SSE) to force a page refresh on the browser. One big problem is that if a plugin changes the value of a SIP variable there is no easy way to detect the change unless the plugin notifies the core program.

Dan

I have a little headway in try to understand the WEB interface and status updates.

Turns out the following code return not only the station running info, but a few system status items too:

class api_status(ProtectedPage):
    """Simple Status API"""

    def GET(self):
        #print("api_status GET")
        statuslist = []
        status = {
            "systemName": gv.sd["name"],
            "systemStatus": gv.sd["en"],
            "waterLevel": gv.sd["wl"],
            "rainDelay": gv.sd["rd"],
            "mode": gv.sd["mm"]
        }
.
.
.
                                    status["status"] = "waiting"
                                    status["reason"] = "program"
                                    status["programName"] = pname
                                    status["remaining"] = rem
                    else:
                        status["reason"] = "system_off"
                    statuslist.append(status)
        web.header("Content-Type", "application/json")
        #print("    returning '{}'".format(statuslist))
        return json.dumps(statuslist)

When the keypad runs a station this status return to a /api/status request, returns the system info too.  It just doesn't get updated by the Gui.  I don't understand how the program data causes the home.html to repaint the program info:

    function statusTimer() {
        jQuery.getJSON("/api/status", updateStatus)
    }

Is the request, and:

    function updateStatus(status) {
        let display, updateInterval = 5000;

        console.debug("SIP home.html: status.length = " + status.length);
        for (let s=0; s<status.length; s++) {
            let station = status[s];
            let classes = "noNewline stationStatus station_" + station.status;

            if (s == 0) {
                let system = status[s];
                console.debug("SIP home.html: system status = " + system.systemStatus);
                console.debug("              system name = " +  system.systemName);
                console.debug("              water level = " +  system.waterLevel);
                console.debug("              rain delay = " +    system.rainDelay);
                console.debug("              mode = " +          system.mode);
            }
            else {
                console.debug("SIP home.html: station " + s + "; status = " + station.status);

                switch (station.reason) {
                    case "program" :
                        let minutes = Math.floor(station.remaining / 60);
                        let seconds = Math.floor(station.remaining - 60*minutes);
                        if (minutes < 10) {minutes = "0"+minutes;}
                        if (seconds < 10) {seconds = "0"+seconds;}
,.
.
.

            jQuery("td#status" + station.station)
                .text(display)
                .removeClass()
                .addClass(classes);
        }

        setTimeout(statusTimer,updateInterval);

        if (updateInterval > 1000) {
            displayProgram();
        }

Updates the program/station part of the Gui.

So how do I get it to also repaint the other information?
Reply
#10
(2023 Jan 28, 12:31 AM)RandyBryant Wrote:
(2023 Jan 27, 03:55 PM)dan Wrote:
(2023 Jan 26, 03:56 PM)RandyBryant Wrote:
(2023 Jan 26, 03:18 PM)dan Wrote: Hi Randy,

The problem of certain changes not showing up in the UI until a page refresh is due to the fact that the changes happen on the server (raspberry pi) side and are not pushed to the browser until a refresh is done.

I have been looking into a way for the server to cause a page refresh on the browser but I have not found a simple solution. If you have any ideas on how to accomplish this I would be very interested.

Dan

I have limited WEB programming experience, but I'll investigate.

What causes the station updates when the keypad starts a program run?  The run times/status shows up with out doing a refresh.

Randy

The way the stations are updated when a program is running is that the home page requests a status update from the server once a second (templates/home.html line ~76). It gets an update from the api_status class in webpages.py (line ~645) which sends a JSON formatted list of status data. JavaScript on the home page updates the display.

You can see the status data at <SIP url>/api/status

I have been tinkering with HTML Server-Sent Events (SSE) to force a page refresh on the browser. One big problem is that if a plugin changes the value of a SIP variable there is no easy way to detect the change unless the plugin notifies the core program.

Dan

I have a little headway in try to understand the WEB interface and status updates.

Turns out the following code return not only the station running info, but a few system status items too:

class api_status(ProtectedPage):
    """Simple Status API"""

    def GET(self):
        #print("api_status GET")
        statuslist = []
        status = {
            "systemName": gv.sd["name"],
            "systemStatus": gv.sd["en"],
            "waterLevel": gv.sd["wl"],
            "rainDelay": gv.sd["rd"],
            "mode": gv.sd["mm"]
        }
.
.
.
                                    status["status"] = "waiting"
                                    status["reason"] = "program"
                                    status["programName"] = pname
                                    status["remaining"] = rem
                    else:
                        status["reason"] = "system_off"
                    statuslist.append(status)
        web.header("Content-Type", "application/json")
        #print("    returning '{}'".format(statuslist))
        return json.dumps(statuslist)

When the keypad runs a station this status return to a /api/status request, returns the system info too.  It just doesn't get updated by the Gui.  I don't understand how the program data causes the home.html to repaint the program info:

    function statusTimer() {
        jQuery.getJSON("/api/status", updateStatus)
    }

Is the request, and:

    function updateStatus(status) {
        let display, updateInterval = 5000;

        console.debug("SIP home.html: status.length = " + status.length);
        for (let s=0; s<status.length; s++) {
            let station = status[s];
            let classes = "noNewline stationStatus station_" + station.status;

            if (s == 0) {
                let system = status[s];
                console.debug("SIP home.html: system status = " + system.systemStatus);
                console.debug("              system name = " +  system.systemName);
                console.debug("              water level = " +  system.waterLevel);
                console.debug("              rain delay = " +    system.rainDelay);
                console.debug("              mode = " +          system.mode);
            }
            else {
                console.debug("SIP home.html: station " + s + "; status = " + station.status);

                switch (station.reason) {
                    case "program" :
                        let minutes = Math.floor(station.remaining / 60);
                        let seconds = Math.floor(station.remaining - 60*minutes);
                        if (minutes < 10) {minutes = "0"+minutes;}
                        if (seconds < 10) {seconds = "0"+seconds;}
,.
.
.

            jQuery("td#status" + station.station)
                .text(display)
                .removeClass()
                .addClass(classes);
        }

        setTimeout(statusTimer,updateInterval);

        if (updateInterval > 1000) {
            displayProgram();
        }

Updates the program/station part of the Gui.

So how do I get it to also repaint the other information?

Updating part of a page can be done with JavaScript but in some cases it is necessary to refresh the entire page.
In home.html line ~179 there is some code to do that:
Code:
        function refreshPage() {
            window.location = "/";
            }
I should point out that the "$" symbol is often used for jQuery but in SIP (web.py) templates that symbol is used for embedded Python code:
https://webpy.readthedocs.io/en/latest/templating.html
<p><br></p>
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)