Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Front- and Backend rework on Bootstrap 5 and urgent security fixes #19

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7234f04
cleanup files and improve lan mode
ChuckNorrison Oct 2, 2024
e4a7d08
Security fix
ChuckNorrison Oct 7, 2024
5d8c014
Fix typos
ChuckNorrison Oct 7, 2024
c261887
No wifi checks if disabled
ChuckNorrison Oct 7, 2024
08c3553
fix video stream
ChuckNorrison Oct 7, 2024
eb4d47d
fix photo quality
ChuckNorrison Oct 7, 2024
5b59549
Add modal dialogues for images page
ChuckNorrison Oct 7, 2024
9aa32d4
Improve error logging and README
ChuckNorrison Oct 7, 2024
ae0cd1f
Improve error logging, clean up files
ChuckNorrison Oct 7, 2024
ab22b25
fix missing logger in photomod
ChuckNorrison Oct 7, 2024
e0c2b11
Improve error logging, cleanup code
ChuckNorrison Oct 8, 2024
71f9636
fix status variable output mismatch
ChuckNorrison Oct 8, 2024
0c11b0c
fix scheduler in lan mode
ChuckNorrison Oct 8, 2024
34a7c32
Add configurable email server
ChuckNorrison Oct 8, 2024
254ff24
Add color for notifications
ChuckNorrison Oct 8, 2024
77d2c18
Security fix for flask
ChuckNorrison Oct 9, 2024
386daf3
Add Delete all Messages for Notifications
ChuckNorrison Oct 9, 2024
f818f85
Clean up network view
ChuckNorrison Oct 9, 2024
e06e4c2
Add Delete all Data for Sensordata as modal
ChuckNorrison Oct 9, 2024
46797cd
Improve FertilizerPlan
ChuckNorrison Oct 9, 2024
6da6856
Improve Interrupt notifications
ChuckNorrison Oct 9, 2024
8e2b019
Improve layout
ChuckNorrison Oct 9, 2024
efa972d
Update README.md
ChuckNorrison Oct 9, 2024
db05866
Fix sensordata defaults after reboot
ChuckNorrison Oct 11, 2024
7cc8104
Fix disable by accident
ChuckNorrison Oct 13, 2024
e2380e7
Add thumb consistency check and increase thumbnail size
ChuckNorrison Oct 15, 2024
2be7601
GUI rework on bootstrap 5
ChuckNorrison Oct 16, 2024
c92f712
More GUI rework
ChuckNorrison Oct 17, 2024
bda029d
Move Weather API and About to Settings
ChuckNorrison Oct 17, 2024
41b5eba
Finalize GUI rework
ChuckNorrison Oct 21, 2024
8f80930
Extend sensor calibration with subtract and divide
ChuckNorrison Oct 21, 2024
12ca664
Update README.md
ChuckNorrison Oct 21, 2024
9f61b43
Small GUI related improvements
ChuckNorrison Oct 21, 2024
15addbe
Add different card colors for nav pills
ChuckNorrison Oct 21, 2024
a832f1d
Update jqplot to v1.0.9
ChuckNorrison Oct 21, 2024
f6c1c60
GUI improvements
ChuckNorrison Oct 22, 2024
9e7a1cd
Add unseen notifies badge to nav
ChuckNorrison Oct 23, 2024
979bcd4
Improve notify badge with setinterval
ChuckNorrison Oct 23, 2024
d3fbb4f
GUI Bootstrap 5 migration for missing pages
ChuckNorrison Oct 24, 2024
24f1e12
Merge pull request #2 from ChuckNorrison/bootstrap5-gui
ChuckNorrison Oct 24, 2024
8d0539e
Security fix: email credentials
ChuckNorrison Oct 24, 2024
e884aed
Add notifications
ChuckNorrison Oct 24, 2024
936d9e0
Update README.md
ChuckNorrison Oct 24, 2024
1289556
Fix card link colors and notify badge
ChuckNorrison Oct 24, 2024
e9740ca
update and improve ajax request for actuator test
ChuckNorrison Oct 28, 2024
d75e6e2
fix min width for table inputs
ChuckNorrison Oct 28, 2024
1a9a349
New feature logstream
ChuckNorrison Oct 29, 2024
faa9d6c
datepicker in data and date formattings
ChuckNorrison Oct 30, 2024
863ea53
Update photoswipe for image gallery
ChuckNorrison Nov 4, 2024
c53944c
Logstream with rotatingfilehandler
ChuckNorrison Nov 4, 2024
422a5d7
Cleanup static folder
ChuckNorrison Nov 4, 2024
c3fe54b
Cleanup templates
ChuckNorrison Nov 4, 2024
922d704
Code & file cleanup, changelog, version bump v3.46
ChuckNorrison Nov 4, 2024
190acb0
Replace jqplot with chartjs
ChuckNorrison Nov 21, 2024
3dc4da6
Fix notification cleanup
ChuckNorrison Nov 22, 2024
0d81d33
Finalize chartjs implementation
ChuckNorrison Dec 10, 2024
59b745d
Merge pull request #3 from ChuckNorrison/chartjs
ChuckNorrison Dec 10, 2024
11da765
Update issue templates
ChuckNorrison Dec 10, 2024
253bfa7
Add missing chartjs library and remove jqplot
ChuckNorrison Dec 11, 2024
d92069c
Improve Data view
ChuckNorrison Dec 11, 2024
ce77d8b
Update README.md
ChuckNorrison Dec 12, 2024
fc2875d
chartjs upgrade 4.4.7 and chart annotations
ChuckNorrison Dec 12, 2024
aa68e07
unify save buttons
ChuckNorrison Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.pyc
15 changes: 6 additions & 9 deletions GPIOEXPI2Ccontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,13 @@ def CheckRealHWpin(PIN=""):
return False, 0
return False, 0


def GPIO_output(address , PINstr, level ):
isRealPIN,PIN=CheckRealHWpin(PINstr)
if isRealPIN:
if address in MCPDEVICES:
mcp=MCPDEVICES[address]
else:
msg= "Address =" +address+ " not available for this Hardware"
msg= "Address =" + address + " not available for this Hardware"
logger.error(msg)
print(msg)
return False
Expand All @@ -246,19 +245,17 @@ def GPIO_output(address , PINstr, level ):
mcp.output(PIN, mcp.LOW)
else:
mcp.output(PIN, mcp.HIGH)
statusdataDBmod.write_status_data(GPIO_data,address+PINstr,"level",level)
statusdataDBmod.write_status_data(GPIO_data, address + PINstr, "level", level)
logger.info("Set PIN=%s to State=%s", PINstr, str(level))
return True
else:
msg= "PIN=" +PINstr+ " not Valid for this Hardware"
logger.error(msg)
print(msg)
if PINstr != "N/A":
msg= "PIN=" + PINstr + " not Valid for this Hardware (" + address + ")"
logger.error(msg)
print(msg)

return False




def GPIO_setup(address, PINstr, state, pull_up_down=""):
isRealPIN,PIN=CheckRealHWpin(PINstr)
if isRealPIN:
Expand Down
8 changes: 5 additions & 3 deletions HWcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,11 @@ def GPIO_output(PINstr, level):
#print PINstr , " ***********************************************" , level
return True
else:
msg= "PIN=" +PINstr+ " not Valid for this Hardware"
logger.error(msg)
print(msg)
if PINstr != "N/A":
msg= "PIN=" +PINstr+ " not Valid for this Hardware"
logger.error(msg)
print(msg)

return False

def GPIO_output_nostatus(PINstr, level):
Expand Down
Binary file removed HWcontrol.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion Prepare for Release/Release checklist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ HYDROSYSTEM SW LEVEL:
4c) remove all files in database /logfiles/
4d) remove all files in database /static/downlaod/
remove all pictures -> go to 'images' and push deleteall or go to static/hydropicture/
5) bash, ensure the latest bash file is install_hydreosys4.sh
5) bash, ensure the latest bash file is install_hydrosys4.sh


START THE PROGRAM IN UBUNTU:
Expand Down
19 changes: 0 additions & 19 deletions Prepare for Release/Release checklist~

This file was deleted.

46 changes: 30 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,54 @@
# Hydrosystem

The hydrosys4 project aim to create a platform for the raspbery pi 3 which let you easily controls and record sensors data, use actuators through the GPIO and play with analog by using external ADC the supported hardware and wiring can be found in the Documentation folder. The platform is developed in python and is based on web server interface. The system can control the WiFi interface and work either in Access point mode than connected to wifi network. The webserver interface can be adjusted to support several purposes, the current development is a small irrigation system, GIU is made to support planning and conditional irrigation based on temperature and humidity, relays control the valve and pumps, the system also support email notifications, cameras and video. Latest upgrade include possibility to mount camera over servo.
The SW platform is based on a web interface where the webserver is running locally on the raspberry. The SW is designed to be used with smartphone and to be reachable from internet without need of external servers or dynamic DNS.
The basic concept is to develop a platoform for the internet of things which is not centralized, then to avoid extra fees, Static IP fees, Dynamic DNS fees. Every time the IP address is updated the system will send an email with relevant link to itself.
NOTE: The mainstream IoT products relies on central server architecture which binds user to annual fees, the server is also a single point of failure and a poses high security problems.
For the designed applications the supporting hardware platform and sensors are choosen to be inexpensive.
The hydrosys4 project aims to create a platform for the raspberry pi which lets you easily control and record sensors data.

More details can be found on my webpage https://hydrosysblog.wordpress.com/
Use actuators through the GPIO and play with analog by using external ADC the supported hardware and wiring can be found in the Documentation folder.

The platform is developed in python and is based on web server interface. The system can control the WiFi interface and works in Access point mode where to user can connect to.

The webserver interface can be adjusted to support several purposes, the current development is used as automatic irrigation system. The GUI is made to support planning and conditional irrigation based on temperature and humidity, relays control the valve and pumps, the system also supports email notifications, cameras and video stream. Latest upgrade include possibility to mount camera over servo.

The software platform is based on a web interface where the webserver is running locally on the raspberry pi. The software is designed to be used with smartphone and to be reachable from internet without need of external servers or dynamic DNS. Every time the IP address is updated the system will send an email with relevant link as configured.

More details can be found in the wiki on https://github.com/ChuckNorrison/Hydrosys/wiki

![image](https://github.com/user-attachments/assets/f7606bfc-627d-4c95-bc6b-fd139d80d43d)
![image](https://github.com/user-attachments/assets/3f03342b-8098-4ff3-bade-833f5e4cd3d7)
![image](https://github.com/user-attachments/assets/707dab07-13d0-48df-b9d6-4cc5be69a967)

# Installation

For installation please follow the installation guide in the website:
For installation please follow the installation guide from here:

https://hydrosysblog.wordpress.com/configuration/
https://github.com/ChuckNorrison/Hydrosys/wiki/Download-&-Installation

two installation methods are possible:

1) For easy installation it is possible to directly download the SD image.
1) For easy installation it is possible to directly download the SD image from current relase

2) For a more traditional installation it is possible to download a bash installer

```
wget https://github.com/ChuckNorrison/Hydrosys/blob/master/bash/install_hydrosys4.sh

sudo chmod u+x install_hydrosys4.sh

sudo ./install_hydrosys4.sh
```

# Access to the System

The systems run on the RPI3 which will act as access point, wait few seconds after the system is restarted, you will se a new wifi network.
The system runs on a raspberry pi, which will act as access point per default. Wait a few seconds after the system is restarted, you will see a new wifi network.
Once connected to the wifi network, open the webbrowser and type the address indicated in the guide.

https://hydrosysblog.wordpress.com/configuration/

https://github.com/ChuckNorrison/Hydrosys/wiki/Connect-to-the-system-interface

# Login

the login credential are:
Username: admin
Password: default

it is strongly suggested to modify the password.

> Username: admin
>
> Password: default

it is strongly suggested to modify the password.
Binary file removed SchedulerMod.pyc
Binary file not shown.
Binary file removed __pycache__/ActuatorControllermod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/GPIOEXPI2Ccontrol.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/HASScompMatrix.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/HASSintegrMQTT.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/HC12control.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/HC12mod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/HWcontrol.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/Hygro24_I2C.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/MQTTcontrol.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/REGandDBmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/SchedulerMod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/SlowWire.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/actuatordbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/advancedmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/autofertilizerdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/autofertilizermod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/automationdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/automationmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/autowateringdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/autowateringmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/basicSetting.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/camera_pi.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/cameradbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/clockdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/clockmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/countryinfo.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/databasemod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/debuggingmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/emaildbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/emailmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/fertilizerdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/filemanagementmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/filestoragemod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/flasksettings.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/hardwaremod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/hx711_AV.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/interruptdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/interruptmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/jsonFormUtils.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/loggerconfig.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/logindbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/messageboxmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/networkdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/networkmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/photomod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/selectedplanmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/sensordbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/start.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/statusdataDBmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/sysconfigfilemod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/systemtimeMod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/videocontrolmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/videomod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/wateringdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/wateringplansensordbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/weatherAPIdbmod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/weatherAPImod.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/wpa_cli_mod.cpython-37.pyc
Binary file not shown.
Binary file removed actuatordbmod.pyc
Binary file not shown.
Binary file removed advancedmod.pyc
Binary file not shown.
30 changes: 18 additions & 12 deletions autofertilizermod.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,29 @@
# triggerdate, datetime when the doser have been triggered to start
# tobeactivated, doser need to be activated in the next opportunity


def isschedulermode(element):
def getworkmode(element):
recordkey="element"
recordvalue=element
keytosearch="workmode"
workmode=autofertilizerdbmod.searchdata(recordkey,recordvalue,keytosearch)
if workmode=="SceduledTime":
return True
else:
return False

return workmode

def checkactivate(elementwater,durationwater): # requires integer input
result = False
elementlist=fertilizerdbmod.getelementlist()
waterok=False

for doserelement in elementlist: # provided the waterelement, search for corresponding doserelement
linkedwaterelement=autofertilizerdbmod.searchdata("element",doserelement,"waterZone")
if linkedwaterelement==elementwater:
waterok=True
element=doserelement
break

if waterok: # there is a corresponding doser element
minwaterduration=hardwaremod.toint(autofertilizerdbmod.searchdata("element",element,"minactivationsec"),0)
if not isschedulermode(element): #setup is not for scheduled time
workmode = getworkmode(element)
if workmode == "BeforeWatering": #setup is not for scheduled time
print(" Fertilizer " ,element ," set to autowater")
print(" Check Water duration ", durationwater ,">", minwaterduration)
if durationwater>minwaterduration: # watering time above the set threshold
Expand All @@ -57,11 +56,14 @@ def checkactivate(elementwater,durationwater): # requires integer input
durationfer=statusdataDBmod.read_status_data(AUTO_data,element,"duration")
activatedoser(element,durationfer)
time.sleep(durationfer) #this blocks the system (and watering activation) for n seconds ... not best practice
result = True
else:
print(" No pending request to activate ", element)


return result

def activatedoser(element, duration):
print(element, " ",duration, " " , datetime.now())
print(element, " ",duration, " " , datetime.now())
logger.info('Doser Pulse, pulse time for ms = %s', duration)
msg, pulseok = ActuatorControllermod.activateactuator(element,duration)
# msg , pulseok=hardwaremod.makepulse(element,duration)
Expand All @@ -85,13 +87,17 @@ def checkworkmode(element):
return autofertilizerdbmod.searchdata("element",element,"workmode")

def timelist(element):
if isschedulermode(element):
workmode = getworkmode(element)
if workmode == "ScheduledTime":
fertime=autofertilizerdbmod.searchdata("element",element,"time")
print("fertime " , fertime)
timelist=hardwaremod.separatetimestringint(fertime)
else:
elif workmode == "BeforeWatering":
print("non scheduler mode ")
timelist=hardwaremod.separatetimestringint("00:20:00") # get up 0 minutes and check for doseractivation
else:
print("Fertilizer is disabled")

return timelist

if __name__ == '__main__':
Expand Down
41 changes: 29 additions & 12 deletions automationmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sensordbmod
import actuatordbmod
import autofertilizermod
import messageboxmod
import statusdataDBmod
import math
import threading
Expand Down Expand Up @@ -189,7 +190,12 @@ def automationexecute(refsensor,element):
alertcounter=statusdataDBmod.read_status_data(AUTO_data,element,"alertcounter")
if alertcounter<2:
if (mailtype!="none"):
emailmod.sendallmail("alert", textmessage)
emailmod.sendallmail("alert", textmessage)

# Create notification message
dictitem={'title': "Automation Message (Critical)", 'content': textmessage, 'color': "red" }
messageboxmod.SaveMessage(dictitem)

logger.error(textmessage)
statusdataDBmod.write_status_data(AUTO_data,element,"alertcounter",alertcounter+1)

Expand All @@ -202,7 +208,12 @@ def automationexecute(refsensor,element):
alertcounter=statusdataDBmod.read_status_data(AUTO_data,element,"alertcounter")
if alertcounter<2:
if (mailtype!="none"):
emailmod.sendallmail("alert", textmessage)
emailmod.sendallmail("alert", textmessage)

# Create notification message
dictitem={'title': "Automation Message (Critical)", 'content': textmessage, 'color': "red" }
messageboxmod.SaveMessage(dictitem)

logger.error(textmessage)
statusdataDBmod.write_status_data(AUTO_data,element,"alertcounter",alertcounter+1)

Expand All @@ -211,31 +222,37 @@ def automationexecute(refsensor,element):

def CheckActivateNotify(element,waitingtime,value,mailtype,sensor,sensorvalue):
global AUTO_data
# check if time between watering events is larger that the waiting time (minutes)
# check if time between watering events is larger than the waiting time (minutes)
lastactiontime=statusdataDBmod.read_status_data(AUTO_data,element,"lastactiontime")
print(' Previous action: ' , lastactiontime , ' Now: ', datetime.utcnow())
timedifference=sensordbmod.timediffinminutes(lastactiontime,datetime.utcnow())
print('Time interval between actions', timedifference ,'. threshold', waitingtime)
logger.info('Time interval between Actions %d threshold %d', timedifference,waitingtime)
logger.info('Time interval between Actions %d threshold %d', timedifference,waitingtime)

if timedifference>=waitingtime: # sufficient time between actions
print(" Sufficient waiting time")
logger.info('Sufficient waiting time')
# action
logger.info('Sufficient waiting time')
# action
print("Implement Actuator Value ", value)
logger.info('Procedure to start actuator %s, for value = %s', element, value)
logger.info('Procedure to start actuator %s, for value = %s', element, value)
msg , isok=activateactuator(element, value)


textmessage="INFO: " + sensor + " value " + str(sensorvalue) + ", activating:" + element + " with Value " + str(value)

# invia mail, considered as info, not as alert
if (mailtype!="warningonly")and(mailtype!="none"):
textmessage="INFO: " + sensor + " value " + str(sensorvalue) + ", activating:" + element + " with Value " + str(value)
if ( mailtype!="warningonly" ) and ( mailtype!="none" ):
emailmod.sendallmail("alert", textmessage)

# Create notification message
dictitem={'title': "Automation Message (Info)", 'content': textmessage, 'color': "primary" }
messageboxmod.SaveMessage(dictitem)

if isok:
statusdataDBmod.write_status_data(AUTO_data,element,"lastactiontime",datetime.utcnow())
statusdataDBmod.write_status_data(AUTO_data,element,"actionvalue",value)

else:
logger.info('Need to wait more time')

logger.info('Need to wait more time')


def activateactuator(target, value): # return true in case the state change: activation is >0 or a different position from prevoius position.
Expand Down
2 changes: 1 addition & 1 deletion autowatering/autowateringmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def message(msg, status: StatusManager, console=True, log=True, logseverity = "
if mail:
Messaging.writemail(msg, status, mailtype)
if note:
dictitem={'title': "System Message (Alert) - Autowatering", 'content': msg }
dictitem={'title': "System Message (Alert) - Autowatering", 'content': msg, 'color': "blue" }
messageboxmod.SaveMessage(dictitem)


Expand Down
6 changes: 0 additions & 6 deletions bash/guide~

This file was deleted.

Loading