Water change indicator

I want to add an indicator to my garden dashboard that shows when I need to do a full water flush/cleaning. I think that it would be cool to have a count down graph or something like that.

I looked through the triggers and conditional statements and not sure of the easiest way to build one of these? Set a trigger duration for 3600 sec/hr x 24hr/day x 10 days in between flushes and then throw and toggle an output? Or a combination of this and a conditional statement?

Has anyone done something like this?


This can be accomplished with only a Dashboard Widget or a combination of a Dashboard Widget and Function. Within these options, there are a few different ways to do this. I’ll go through what immediately comes to mind, from easiest to most complex:

  1. A widget that has simple javascript that displays a countdown timer based on a future time/date you set with a custom option. This doesn’t allow for things like email notification because it’s all javascript based and will only show you the countdown on the dashboard when the dashboard page is open in a browser. See the Mycodo/mycodo/widgets/examples/custom_widget_example_endpoint.py for using endpoints with widgets, or check out Mycodo/mycodo/widgets/widget_indicator.py for how purely javascript can be implements to display information on the widget.

  2. Widgets can now run their own processes when the dashboard is not open, which allows you to have a timer counting down in the widget thread running in the daemon. So, you could use widget javascript to querry the daemon for the latest countdown time, and when the countdown completes in the daemon thread, you could run additional Python code, such as sending you an email notification or any other action you come up with. See Mycodo/mycodo/widgets/widget_python_code.py for how to execute Python code at a regular interval and display a return string on the widget.

  3. Widgets and Functions can act in unison, where the widget can get status updates from Functions. The Function can count down and also perform additional acts like email notification, etc. at the end of the countdown, and the widget can query the Function for a response string that it displays on the dashboard. See Mycodo/mycodo/widgets/widget_function_status.py and Mycodo/mycodo/function/examples/custom_function_simple_loop_with_status.py for how the Widget and Function can interact.

If these are in the example directory, you will need to import the module on the Configure → Custom Widget and Custom Function pages. I’ve been thinking about having all example modules included automatically as an imported module so users can add and play with them in Mycodo without going through the import process, and have them clearly labeled “Example Module” or similar when they’re in the Widget or Function dropdown menu for adding a widget/function.