This project contain scripts that interact to the database project of ERDL.
Currently, lonoa supports the following sensors:
su lonoa
cd
git clone https://github.com/erdl/lonoa.git <project folder name>
cd <project folder name>
sudo pip3 install -r requirements.txt
CREATE USER lonoa WITH CREATEDB
python3 init_database.py <database name>
psql <database name> -c "INSERT INTO api_authentication(username,password) VALUES ('<apiusername>','<apipassword>')"
psql <database name> -c "\copy sensor_info from <csv filename> header csv"
python3 init_crontab.py
Examples adding new active sensors
adding an egauge purpose
psql <database name> -c "insert into sensor_info(purpose_id, query_string, script_folder, unit, data_sensor_info_mapping, is_active, last_updated_datetime)values(<purpose_id>, '<query_string>', 'egauge', '<unit>', '<data_sensor_info_mapping>', True, ('<YYYY-MM-DD hh:mm>'));"
adding a webctrl purpose
psql <database name> -c "insert into sensor_info(purpose_id, query_string, script_folder, unit, is_active, last_updated_datetime) values(<purpose_id>, '<query_string>', 'webctrl', '<unit>', True, ('<YYYY-MM-DD hh:mm>'));"
adding a hobo purpose
psql <database name> -c "insert into sensor_info(purpose_id, query_string, script_folder, unit, data_sensor_info_mapping, is_active, last_updated_datetime) values(<purpose_id>, '<query_string>', 'hobo', '<unit>', '<data_sensor_info_mapping>', True, ('<YYYY-MM-DD hh:mm>'));"
exporting a table to csv
-psql <database name> -c "\copy <table_name> to <csv filename> header csv"
Examples updating sensor_info
psql <database name> -c "update sensor_info set script_folder='egauge' where query_string like 'egauge%'"
psql <database name> -c "update sensor_info set script_folder='webctrl' where query_string like 'ABSPATH%'"
psql <database name> -c "update sensor_info set data_sensor_info_mapping='<column name>' where query_string like 'egauge%'"
psql <database name> -c "update sensor_info set last_updated_datetime=('2019-07-31 23:59') where script_folder='egauge' or script_folder='webctrl'"
psql <database name> -c "update sensor_info set is_active=True where script_folder='webctrl' or script_folder='egauge'"