Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plugin that adds water tank info to the home page
#1
I am writing a plugin that collects water tank info via mqtt. I need to display that info using a progressbar-like icon on the homepage. Is there a way a plugin can inject html to the homepage?
Reply
#2
There is a way to add plugin data to the footer.

For some reason the example code that shows how to do it was removed by mistake from the proto.py file in the plugins folder.

You can get the example by re-installing the proto plugin from the plugin manager and enabling it to see it in action.
The example shows an increasing count but you can add pretty much anything to the display.

The example code starts at line 40

The timeline example will show up if stations 1 or 2 are being run by a program.

Dan
<p><br></p>
Reply
#3
(2023 Oct 25, 08:03 PM)dan Wrote: There is a way to add plugin data to the footer.

For some reason the example code that shows how to do it was removed by mistake from the proto.py file in the plugins folder.

You can get the example by re-installing the proto plugin from the plugin manager and enabling it to see it in action.
The example shows an increasing count but you can add pretty much anything to the display.

The example code starts at line 40

The timeline example will show up if stations 1 or 2 are being run by a program.

Dan

Thanks Dan, I will check it out.
Reply
#4
Hi Dan, I am making progress with my plugin. Here is the githab link in case you want to check it out https://github.com/ahatzikonstantinou/SI...ank_plugin.

1. At the moment I am writing code that must detect if any programs are currently running and possibly stop them if the level of water in the water-tank has dropped below a critical level. How do I get the program (or programs) that are currently running?

2. Another piece of code that runs in the background, needs to check if any station is on (i.e. valve is open) when a water-level sensor reports a drop of the water-level. If no valve is open then either there is a leak at the water-tank or pipes, or someone is stealing water from the water-tank. Either way, the code sends a notification and an email. How should I check if a valve is on?
Reply
#5
(2023 Nov 14, 12:20 PM)ahat Wrote: Hi Dan, I am making progress with my plugin. Here is the githab link in case you want to check it out https://github.com/ahatzikonstantinou/SI...ank_plugin.

1. At the moment I am writing code that must detect if any programs are currently running and possibly stop them if the level of water in the water-tank has dropped below a critical level. How do I get the program (or programs) that are currently running?

2. Another piece of code that runs in the background, needs to check if any station is on (i.e. valve is open) when a water-level sensor reports a drop of the water-level. If no valve is open then either there is a leak at the water-tank or pipes, or someone is stealing water from the water-tank. Either way, the code sends a notification and an email. How should I check if a valve is on?
Great to hear that you are making progress. I will take a look.

Take a look at the gv_reference.pdf file for the control variables you need:
https://raw.githubusercontent.com/wiki/D...erence.pdf

"gv.pon" holds the number of the program that is currently running.
"gv.srvals" holds the station(s) that is/are on.

You can also use the GET command [SIP url]/sn in the browser to see the current "gv.srvals"

You may also find "gv.ps" and "gv.rs" useful.

Dan
<p><br></p>
Reply
#6
(2023 Nov 14, 03:33 PM)dan Wrote:
(2023 Nov 14, 12:20 PM)ahat Wrote: Hi Dan, I am making progress with my plugin. Here is the githab link in case you want to check it out https://github.com/ahatzikonstantinou/SI...ank_plugin.

1. At the moment I am writing code that must detect if any programs are currently running and possibly stop them if the level of water in the water-tank has dropped below a critical level. How do I get the program (or programs) that are currently running?

2. Another piece of code that runs in the background, needs to check if any station is on (i.e. valve is open) when a water-level sensor reports a drop of the water-level. If no valve is open then either there is a leak at the water-tank or pipes, or someone is stealing water from the water-tank. Either way, the code sends a notification and an email. How should I check if a valve is on?
Great to hear that you are making progress. I will take a look.

Take a look at the gv_reference.pdf file for the control variables you need:
https://raw.githubusercontent.com/wiki/D...erence.pdf

"gv.pon" holds the number of the program that is currently running.
"gv.srvals" holds the station(s) that is/are on.

You can also use the GET command [SIP url]/sn in the browser to see the current "gv.srvals"

You may also find "gv.ps" and "gv.rs" useful.

Dan

Thanks Dan
Reply
#7
Hey Dan, I added to my plugin the capability to run/enable/disable programs when a water tank reaches a user-specified water level.
I would also like to add the capability to run a station for a specific amount of time or until a sensor reports that the water in the tank has reached a specific level. The scenario I have in mind is if my water tank gets filled by a pump, I would set a station to be the pump, and when the water gets to a certain low level, run the station i.e. the pump until the water in the tank rises to a certain high level.
So my question is how can I programmatically run and stop a station?
Reply
#8
I am guessing you would like to run the pump station even though an irrigation station might already be running.

The new node-red plugin has this capability. You can borrow the code from the plugin which is included with the latest rev of SIP or you can install it from the plugin manager page.

The code you need will be in the "station_on_off" function starting at line ~380 to 393.

Let me know if you have questions about it.

By the way I have taken a quick look at your plugin. I really like the way you handle various tank types.
What kind of water level sensor are you using?

Dan
<p><br></p>
Reply
#9
Apologies for the delayed answer Dan.
I saw that if I run a program everything already running gets cancelled which is exactly what I expect to happen if the water level goes to a limit and emergency action is taken. I also added the capability to run individual stations which will not affect any other already running stations. If my plugin starts a station that is already running I just reset its timer, so that it runs a full cycle from the start.
I am building my own sensor which is a simple ESP8266 nodemcu v1 controller with a HC-SR04 ultrasound sensor. Precision is questionable but good enough for monitoring the level water in a tank. The code for my sensor is in https://github.com/ahatzikonstantinou/WaterTankSensor in case you want to take a look.
One shortcoming of my design, which I realized only a few days ago, is that my plugin listens only to a single mqtt topic and all sensors are supposed to send mqtt messages of the same format for water level measurements. Maybe that should be more flexible and allow per sensor specification.

Please take a look and tell me what you think.

One last thing remaining, is the translations to other languages. I am not sure how to go about it. I haven't worked with gettext before, but from what I read I need to create a new domain for my plugin's messages. But if I load that domain at my plugin's startup then I think I would be cancelling the SIP_messages domain. I guess I will need to experiment with that.
Reply
#10
Hey Dan, merry Christmas.
I just wanted to let you know that I also created a plugin for https://www.waveshare.com/wiki/RPi_Relay_Board_(B)
This is the board that I used for my latest irrigation project. I just copied the relay_board plugin and only changed the pins that control the relays on the board.
My plugin is at https://github.com/ahatzikonstantinou/SI...ard_plugin
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)