diff --git a/database/demo-cn/myems_system_db.sql b/database/demo-cn/myems_system_db.sql index 924a60a3..616675b7 100644 --- a/database/demo-cn/myems_system_db.sql +++ b/database/demo-cn/myems_system_db.sql @@ -395,7 +395,6 @@ USE `myems_system_db`; INSERT INTO `myems_system_db`.`tbl_gateways` (`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`) VALUES -(1, '网关1', 'dc681934-5053-4660-98ed-266c54227231', '983427af-1c35-42ba-8b4d-288675550225', null), (2, '网关2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null); COMMIT; diff --git a/database/demo-de/myems_system_db.sql b/database/demo-de/myems_system_db.sql index b586a7a3..f722281c 100644 --- a/database/demo-de/myems_system_db.sql +++ b/database/demo-de/myems_system_db.sql @@ -396,7 +396,6 @@ USE `myems_system_db`; INSERT INTO `myems_system_db`.`tbl_gateways` (`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`) VALUES -(1, 'MyEMS Gateway 1', 'dc681934-5053-4660-98ed-266c54227231', '983427af-1c35-42ba-8b4d-288675550225', null), (2, 'MyEMS Gateway 2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null); COMMIT; diff --git a/database/demo-en/myems_system_db.sql b/database/demo-en/myems_system_db.sql index 605b8ab3..ca9ab144 100644 --- a/database/demo-en/myems_system_db.sql +++ b/database/demo-en/myems_system_db.sql @@ -396,7 +396,6 @@ USE `myems_system_db`; INSERT INTO `myems_system_db`.`tbl_gateways` (`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`) VALUES -(1, 'MyEMS Gateway 1', 'dc681934-5053-4660-98ed-266c54227231', '983427af-1c35-42ba-8b4d-288675550225', null), (2, 'MyEMS Gateway 2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null); COMMIT; diff --git a/database/install/myems_system_db.sql b/database/install/myems_system_db.sql index 6b5b955b..615ae0de 100644 --- a/database/install/myems_system_db.sql +++ b/database/install/myems_system_db.sql @@ -359,10 +359,25 @@ CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_gateways` ( `name` VARCHAR(255) NOT NULL, `uuid` CHAR(36) NOT NULL, `token` CHAR(36) NOT NULL, - `last_seen_datetime_utc` DATETIME NULL COMMENT 'The last seen date time in UTC via PING, TELNET or Heatbeat', + `last_seen_datetime_utc` DATETIME NULL COMMENT 'The last seen date time in UTC via PING, TELNET or Heartbeat', PRIMARY KEY (`id`)); CREATE INDEX `tbl_gateways_index_1` ON `myems_system_db`.`tbl_gateways` (`name`); + +-- --------------------------------------------------------------------------------------------------------------------- +-- Default Data for table `myems_system_db`.`tbl_gateways` +-- This gateway's token is used by myems-modbus-tcp service +-- --------------------------------------------------------------------------------------------------------------------- +START TRANSACTION; +USE `myems_system_db`; + +INSERT INTO `myems_system_db`.`tbl_gateways` +(`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`) +VALUES +(1, 'Gateway1', 'dc681938-5053-8660-98ed-266c58227231', '983427af-1c35-42ba-8b4d-288675550225', null); + +COMMIT; + -- --------------------------------------------------------------------------------------------------------------------- -- Table `myems_system_db`.`tbl_knowledge_files` -- --------------------------------------------------------------------------------------------------------------------- diff --git a/database/upgrade/upgrade1.3.4.sql b/database/upgrade/upgrade1.3.4.sql new file mode 100644 index 00000000..4237ea33 --- /dev/null +++ b/database/upgrade/upgrade1.3.4.sql @@ -0,0 +1,21 @@ +-- PLEASE CHECK YOUR DATABASE TABLE myems_system_db.tbl_gateway, +-- If the tbl_gateways is empty +-- then run the statement below to insert the default gateway data +-- else please ignore and only run the update version number statement. + +-- --------------------------------------------------------------------------------------------------------------------- +-- Default Data for table `myems_system_db`.`tbl_gateways` +-- This gateway's token is used by myems-modbus-tcp service +-- --------------------------------------------------------------------------------------------------------------------- +START TRANSACTION; +USE `myems_system_db`; + +INSERT INTO `myems_system_db`.`tbl_gateways` +(`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`) +VALUES +(1, 'MyEMS Gateway 1', 'dc681938-5053-8660-98ed-266c58227231', '983427af-1c35-42ba-8b4d-288675550225', null); + +COMMIT; + +-- UPDATE VERSION NUMBER +UPDATE myems_system_db.tbl_versions SET version='1.3.4', release_date='2021-11-06' WHERE id=1; diff --git a/myems-modbus-tcp/config.py b/myems-modbus-tcp/config.py index bfe85e2f..2b2586f5 100644 --- a/myems-modbus-tcp/config.py +++ b/myems-modbus-tcp/config.py @@ -14,8 +14,8 @@ MYEMS_HISTORICAL_DB_USER = config('MYEMS_HISTORICAL_DB_USER', default='root') MYEMS_HISTORICAL_DB_PASSWORD = config('MYEMS_HISTORICAL_DB_PASSWORD', default='!MyEMS1') INTERVAL_IN_SECONDS = config('INTERVAL_IN_SECONDS', default=600, cast=int) -GATEWAY_ID = config('GATEWAY_ID', cast=int) -GATEWAY_TOKEN = config('GATEWAY_TOKEN') +GATEWAY_ID = config('GATEWAY_ID', default=1, cast=int) +GATEWAY_TOKEN = config('GATEWAY_TOKEN', default='983427af-1c35-42ba-8b4d-288675550225') myems_system_db = { 'host': MYEMS_SYSTEM_DB_HOST, diff --git a/myems-modbus-tcp/example.env b/myems-modbus-tcp/example.env index 8fc9a034..22ac9fe1 100644 --- a/myems-modbus-tcp/example.env +++ b/myems-modbus-tcp/example.env @@ -18,4 +18,4 @@ INTERVAL_IN_SECONDS=600 # Get the gateway ID and token from MyEMS Admin # This is used for getting data sources associated with the gateway GATEWAY_ID=1 -GATEWAY_TOKEN=AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA \ No newline at end of file +GATEWAY_TOKEN=983427af-1c35-42ba-8b4d-288675550225 \ No newline at end of file