Skip to content

Commit

Permalink
Autowatering change and HomeAssistant integration fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Hydrosys4 committed Nov 5, 2022
1 parent 6b46fa5 commit e3530b4
Show file tree
Hide file tree
Showing 75 changed files with 989 additions and 1,053 deletions.
2 changes: 1 addition & 1 deletion HASScompMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def create_config_entity(self, elem_name): # used for the MQTT Discovery
config_payload["device"]= {"model": "Hydrosys4","identifiers": NodeID,"via_device": "H4", "name": NodeID, "manufacturer": "AngeloVa"}
# here the MQTT part
#print("Topic ", topics["config"], " send payload: " , config_payload)
self.MQTT_client.publish(topics["config"],json.dumps(config_payload))
self.MQTT_client.publish(topics["config"],json.dumps(config_payload), True)

data_to_store={"topics" : topics, "config_payload": config_payload}
statusdataDBmod.write_status_data(HASS_entity_config.config_reg,"device", elem_name,data_to_store,permanent=True, storeid="HASSIO_device_config")
Expand Down
4 changes: 2 additions & 2 deletions HASSintegrMQTT.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def subscribe(self, topic):
isok=HASS_Client.ClientObj.connect()
HASS_Client.ClientObj.subscribe(topic, qos=2)

def publish(self, topic, payload):
def publish(self, topic, payload , retained=False):
if self.is_send_state():
isok=HASS_Client.ClientObj.connect()
HASS_Client.ClientObj.publish(topic, payload)
HASS_Client.ClientObj.publish(topic, payload , retained=retained)

def check_loop_and_connect(self):
if self.is_enabled():
Expand Down
Binary file added __pycache__/ActuatorControllermod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/GPIOEXPI2Ccontrol.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/HASScompMatrix.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/HASSintegrMQTT.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/HC12control.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/HC12mod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/HWcontrol.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/Hygro24_I2C.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/MQTTcontrol.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/REGandDBmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/SchedulerMod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/SlowWire.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/actuatordbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/advancedmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/autofertilizerdbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/autofertilizermod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/automationdbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/automationmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/autowateringdbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/autowateringmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/basicSetting.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/camera_pi.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/cameradbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/clockdbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/clockmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/countryinfo.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/databasemod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/debuggingmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/emaildbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/emailmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/fertilizerdbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/filemanagementmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/filestoragemod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/flasksettings.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/hardwaremod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/hx711_AV.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/interruptdbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/interruptmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/jsonFormUtils.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/loggerconfig.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/logindbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/messageboxmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/networkdbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/networkmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/photomod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/selectedplanmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/sensordbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/start.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/statusdataDBmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/sysconfigfilemod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/systemtimeMod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/videocontrolmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/videomod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/wateringdbmod.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file added __pycache__/weatherAPIdbmod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/weatherAPImod.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/wpa_cli_mod.cpython-37.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions automationdbmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
if not filestoragemod.readfiledata(WTDATAFILENAME,WTdata): #read watering setting file
#read from default file
filestoragemod.readfiledata(DEFWTDATAFILENAME,WTdata)
print("Watering writing default calibration data")

filestoragemod.savefiledata(WTDATAFILENAME,WTdata)

# end read IOdata -----
Expand Down Expand Up @@ -129,7 +129,7 @@ def restoredefault():
filestoragemod.deletefile(WTDATAFILENAME)
filestoragemod.readfiledata(DEFWTDATAFILENAME,WTdata)
#print "WT data -----------------------------------> ", WTdata
consitencycheck()
consistencycheck()


def saveWTsetting():
Expand Down
1 change: 1 addition & 0 deletions autowatering/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added autowatering/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
43 changes: 28 additions & 15 deletions autowateringdbmod.py → autowatering/autowateringdbmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Auto watering UI setting storage utilities
"""
from __future__ import print_function

import logging
import os
Expand Down Expand Up @@ -54,6 +53,15 @@ def readfromfile():
global WTdata
filestoragemod.readfiledata(WTDATAFILENAME,WTdata)

# Callback are used to propagate the changes in the configuration to the variables inside the class in the autowateringmod
# make use of the global variable to store the link to the function in the other module.
callbacklist={}
def register_callback(name, callback_func):
print("append the callback ----------------------------")
global callbacklist
callbacklist[name]=callback_func


def consistencycheck():

# this routine align the watering table elements with the Hardware available elements "name" labelled with usedfor "watering"
Expand Down Expand Up @@ -112,9 +120,17 @@ def consistencycheck():

saveWTsetting()

# extra code for the sensor field which should be consistent with sensor names in HW
# make call to update the class instances variables using a callback function
if "UpdateBots" in callbacklist:
callbacklist["UpdateBots"](elementlist,tabletoadd,tabletoremove)
else:
print( " no callback found: UpdateBots " )







def replacewordandsave(oldword,newword):
global WTdata
Expand All @@ -128,7 +144,7 @@ def restoredefault():
filestoragemod.deletefile(WTDATAFILENAME)
filestoragemod.readfiledata(DEFWTDATAFILENAME,WTdata)
#print "WT data -----------------------------------> ", WTdata
consitencycheck()
consistencycheck()


def saveWTsetting():
Expand Down Expand Up @@ -196,17 +212,6 @@ def getrowdata(recordvalue,paramlist,index): #for parameters with array of integ

return datalist

def gettable(index):
paramlist=getparamlist()
#print "paramlist" , paramlist
elementlist=getelementlist()
datalist=[]
for row in elementlist:
rowdatalist=getrowdata(row,paramlist,index)
datalist.append(rowdatalist)
#print datalist
return datalist


def replacerow(element,dicttemp):
searchfield="element"
Expand Down Expand Up @@ -236,9 +241,17 @@ def searchdata(recordkey,recordvalue,keytosearch):
if recordkey in ln:
if ln[recordkey]==recordvalue:
if keytosearch in ln:
return ln[keytosearch]
return ln[keytosearch]

return ""

def recordmatch(recordkey, recordvalue):
for ln in WTdata:
value = ln.get(recordkey, None)
if value == recordvalue:
return True
return False

def isdatapresent(recordkey,recordvalue,keytosearch,recordtofind):
for ln in WTdata:
if recordkey in ln:
Expand Down
Loading

0 comments on commit e3530b4

Please sign in to comment.