Skip to content

The central software which orchestrates all the hardware nodes and provides an API for the client access.

License

Notifications You must be signed in to change notification settings

KEECO-HomeAutomation/keeco-hub

Repository files navigation

keeco-hub

ci bucket trello

The central software which orchestrates all the hardware nodes and provides an API for the client access.

NPM Scripts

  • npm start : start the application in development mode, with automatic reloading (see caveats in CONTRIBUTING.md)
  • npm run build : Compile the code with babel (output directory: build)
  • npm test : Run all the tests
  • npm run test:coverage : Run all the tests and generate coverage reports
  • npm run lint : Lint your code. It will also error out on format errors
  • npm run format : Format every .js file using Prettier.

Using docker

We have a docker container which has all the dependencies installed for the hub. You can use it, if you want an easy, plug'n'play solution.

Run the stable container with:

docker run -dit --name keeco_hub --restart always -v keeco_hub_conf:/opt/keeco-hub/config -p 5000:5000 -p 1883:1883 -p 5353:5353 keeco/keeco-hub

Run the development container with:

docker run --rm -it -v keeco_hub_dev_conf:/opt/keeco-hub/config -p 5000:5000 -p 1883:1883 -p 5353:5353 keeco/keeco-hub:dev

The ports used:

  • 5000 for graphQL API
  • 1883 for MQTT
  • 5353 for mDNS. If you don't need it, you can leave it out.

We use a persistent volume managed by docker (keeco_hub_conf), but you can use a local binding as well.

Which is which

  • src/index.js : The entrypoint of the hub. It just initializes every module.
  • src/aedes : The home of the MQTT server
  • src/apollo : The home of the GraphQL server
    • index.js : Sets up the server
    • schema : Contains the GQL schema
      • index.js : Merges all the typeDefs and resolvers
      • Query : The base query which is extended
        • schema.graphql : The main schema
        • resolvers.js : The main resolvers
      • ... (so on for the rest of the directories)
  • src/sqlite : The home of the SQLite instance
    • index.js : Sets up the database
    • populate.js : Populates the empty database on the first start
    • structure.js : Contains the structure of the SQLite database
  • src/connector : The home of the class that connects and controlls all the different data stores and APIs
    • index.js : The base class which imports all the modules
    • The rest of the files are modules of the connector
  • src/utils : Contains utility functions

Auto provisioning

Provision JSONs should be passed to the MQTT server as the username. Password is omitted in this case.

Example provision JSON:

{
	"uuid": "5e35d62e-a832-41fe-9660-3768c427addc",
	"name": "KEECO Switch",
	"endpoints": [
		{
			"name": "relayPin1",
			"output": true,
			"range": "0,1"
		},
		{
			"name": "relayPin2",
			"output": true,
			"range": "0,1"
		}
	],
	"templates": [
		{
			"name": "switch",
			"mappings": [
				{
					"name": "on",
					"endpoint": "relayPin1"
				}
			]
		},
		{
			"name": "switch",
			"mappings": [
				{
					"name": "on",
					"endpoint": "relayPin2"
				}
			]
		}
	]
}

Provision JSON fields:

  • uuid : Mandatory field. Should be universally unique
  • name : The node can name itself. This can be changed later by the user. Optional
  • endpoints : Array of endpoints
    • name : The name of the pin. Should be unique per node
    • output : Set to true if the pin is an output pin. Optional. If omitted defaults to false
    • range : The node can define what values is it accepting/will it produce. Examples: 0:15, .002:.4, 1,2,3. See more. Optional
  • templates : Array of templates. The templates are which tell the server how to work with a node. Required, but can be an empty array
    • name : Name of the template. Should match one of the names listed in src/apollo/schema/nodes/TemplateData.graphql. For example the template name for TemplateDataSwitch should be switch. Case sensitive
    • mappings : Mappings for the template
      • name : The name of the pin that should be present for the selected template. Case sensitive
      • endpoint : The name of the endpoint that is mapped to the template pin

About

The central software which orchestrates all the hardware nodes and provides an API for the client access.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published