„README.md“ ändern
This commit is contained in:
parent
879a5629b6
commit
cd9aedbd04
33
README.md
33
README.md
@ -57,14 +57,6 @@ apt-get install jq
|
||||
apt-get install mariadb-server
|
||||
```
|
||||
```
|
||||
CREATE DATABASE nuki;
|
||||
#set language to german permanently
|
||||
SET GLOBAL lc_time_names = 'de_DE';
|
||||
CREATE USER 'nuki'@'%' IDENTIFIED BY 'YourPassword';
|
||||
GRANT ALL PRIVILEGES ON nuki.* TO 'nuki'@'%' WITH GRANT OPTION;
|
||||
|
||||
USE nuki;
|
||||
|
||||
/*this table is a merge of /smartlock/; /smartlock/config/ and /smartlock/advanced/config/*/
|
||||
CREATE TABLE IF NOT EXISTS Smartlock
|
||||
(
|
||||
@ -72,9 +64,9 @@ CREATE TABLE IF NOT EXISTS Smartlock
|
||||
`adminPinState` TINYINT NOT NULL,
|
||||
`advertisingMode` TINYINT NOT NULL,
|
||||
`authId` VARCHAR(24),
|
||||
`autoLockTimeout` TINYINT NOT NULL,
|
||||
`automaticBatteryTypeDetection` BOOLEAN NOT NULL,
|
||||
`autoLockTimeout` SMALLINT NOT NULL,
|
||||
`autoUnlatch` BOOLEAN NOT NULL,
|
||||
`automaticBatteryTypeDetection` BOOLEAN NOT NULL,
|
||||
`batteryCritical` BOOLEAN NOT NULL,
|
||||
`batteryType` TINYINT NOT NULL,
|
||||
`buttonEnabled` BOOLEAN NOT NULL,
|
||||
@ -88,16 +80,17 @@ CREATE TABLE IF NOT EXISTS Smartlock
|
||||
`fobAction2` TINYINT NOT NULL,
|
||||
`fobAction3` TINYINT NOT NULL,
|
||||
`fobPaired` BOOLEAN NOT NULL,
|
||||
`keypadPaired` BOOLEAN NOT NULL,
|
||||
`lastAction` TINYINT NOT NULL,
|
||||
`latitude` FLOAT NOT NULL,
|
||||
`ledBrightness` TINYINT NOT NULL,
|
||||
`ledEnabled` BOOLEAN NOT NULL,
|
||||
`lngTimeout` TINYINT NOT NULL,
|
||||
`lngTimeout` SMALLINT NOT NULL,
|
||||
`lockedPositionOffsetDegrees` SMALLINT NOT NULL,
|
||||
`longitude` FLOAT NOT NULL,
|
||||
`mainName` VARCHAR(255),
|
||||
`mode` TINYINT NOT NULL,
|
||||
`name` VARCHAR(255),
|
||||
`operationId` VARCHAR(255),
|
||||
`pairingEnabled` BOOLEAN NOT NULL,
|
||||
`serverState` TINYINT NOT NULL,
|
||||
`singleButtonPressAction` TINYINT NOT NULL,
|
||||
@ -109,9 +102,9 @@ CREATE TABLE IF NOT EXISTS Smartlock
|
||||
`totalDegrees` SMALLINT NOT NULL,
|
||||
`trigger` TINYINT NOT NULL,
|
||||
`type` TINYINT NOT NULL,
|
||||
`unlatchDuration` TINYINT NOT NULL,
|
||||
`unlatchDuration` SMALLINT NOT NULL,
|
||||
`unlockedPositionOffsetDegrees` SMALLINT NOT NULL,
|
||||
`unlockedToLockedTransitionOffsetDegrees` TINYINT NOT NULL,
|
||||
`unlockedToLockedTransitionOffsetDegrees` SMALLINT NOT NULL,
|
||||
`updateDate` DATETIME NOT NULL
|
||||
);
|
||||
|
||||
@ -137,7 +130,7 @@ CREATE TABLE IF NOT EXISTS SmartlockAuth
|
||||
`enabled` BOOLEAN NOT NULL,
|
||||
`id` VARCHAR(24) NOT NULL PRIMARY KEY, /*primary key = unique!*/
|
||||
`lastActiveDate` DATETIME NOT NULL,
|
||||
`lockCount` TINYINT NOT NULL,
|
||||
`lockCount` SMALLINT NOT NULL,
|
||||
`name` VARCHAR(255),
|
||||
`remoteAllowed` BOOLEAN NOT NULL,
|
||||
`smartlockId` VARCHAR(9) NOT NULL,
|
||||
@ -254,9 +247,9 @@ while [ true ]; do
|
||||
mysql -u$DB_USER -p$DB_PASS $DB_NAME -e"TRUNCATE TABLE SmartlockAuth; LOAD DATA LOCAL INFILE '"$FILE_BASE"_SmartlockAuth.csv' INTO TABLE SmartlockAuth FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' IGNORE 1 LINES;"
|
||||
|
||||
eval "curl -X GET $CURL_HEADER $BASE_URL/smartlock -o "$FILE_BASE"_Smartlock.json"
|
||||
jq -r ".[]|[{smartlockId}+{accountId}+{type}+{authId}+({\"mainName\":.name}|del(.name))+{favorite}+{firmwareVersion}+{serverState}+{adminPinState}+{creationDate}+{updateDate}+(.config|.+{operationId})+(.advancedConfig|.+{operationId})+.state]|$JQ_CSV" "$FILE_BASE"_Smartlock.json > "$FILE_BASE"_Smartlock.csv
|
||||
sed -i 's/,true,/,1,/g' "$FILE_BASE"_Smartlock.csv
|
||||
sed -i 's/,false,/,0,/g' "$FILE_BASE"_Smartlock.csv
|
||||
jq -r ".[]|[{smartlockId}+{accountId}+{type}+{authId}+({\"mainName\":.name}|del(.name))+{favorite}+{firmwareVersion}+{serverState}+{adminPinState}+{creationDate}+{updateDate}+.config+.advancedConfig+.state]|$JQ_CSV" "$FILE_BASE"_Smartlock.json > "$FILE_BASE"_Smartlock.csv
|
||||
sed -i 's/true/1/g' "$FILE_BASE"_Smartlock.csv
|
||||
sed -i 's/false/0/g' "$FILE_BASE"_Smartlock.csv
|
||||
mysql -u$DB_USER -p$DB_PASS $DB_NAME -e"TRUNCATE TABLE Smartlock; LOAD DATA LOCAL INFILE '"$FILE_BASE"_Smartlock.csv' INTO TABLE Smartlock FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' IGNORE 1 LINES;"
|
||||
|
||||
sleep 30
|
||||
@ -464,7 +457,7 @@ exit 0
|
||||
## 6. Download Grafana Dashboard
|
||||
https://grafana.com/dashboards/7628/ or https://leyghis.fablabchemnitz.de:8444/MarioVoigt/Nukiana/src/branch/master/Grafana/Nuki%20Smartlock%20+%20Bridge%20%28Internals%29.json
|
||||
|
||||
## 7. Left open ToDo's
|
||||
## 7. Remaining ToDo's
|
||||
* bash scripts
|
||||
* maybe add pid files / design them as services for "sudo service ... stop|start|restart"
|
||||
* translation
|
||||
@ -480,6 +473,8 @@ https://grafana.com/dashboards/7628/ or https://leyghis.fablabchemnitz.de:8444/M
|
||||
* Bridge provides timestamp but no timezoneOffset → SQL statements were written to use the timezoneOffset of Smartlock instead → works, but dirty
|
||||
* replace TRUNCATE statements with "INSERT ON DUPLICATE KEY UPDATE" to leave old data but import new data
|
||||
* to implement:
|
||||
* make us of fields `keypadPaired` and `lastAction`
|
||||
* build up some check script to make proof of correct count of columns and column order of the csv files
|
||||
* collect data with time history:
|
||||
* history of firmware changes
|
||||
* history of rssi values
|
||||
|
Loading…
Reference in New Issue
Block a user