0.8.3 • Published 4 years ago
@maximva/home-automation v0.8.3
Home Automation Package
The Home Automation Package - HAP for short - has been developed to provide a solid base for developing home automation applications. It is still in the works but as of now it can be used to provide thermostat settings as a JSON string and get a JSON string back with the appropriate action to take for the heating/cooling system in your house. Also, using the HTTPThermostat class a API url can be provided to fetch temperature data.
How to go about installing it
This is a short one:
npm install @maximva/home-automation
Examples
HTTP Thermostat class
import { HTTPThermostat } from '@maximva/home-automation'
import { JSONThermostat } from '@maximva/home-automation'
import {TemperatureConverter } from '@maximva/home-automation'
import { HttpTemperatureSensor } from '@maximva/home-automation'
import httpClient from 'axios'
const settings = {
temperature : 20,
range : 2,
unit : "celsius"
}
const currentTemperature = {
temperature: 21,
unit: "celsius"
}
const temperatureConverter = new TemperatureConverter()
const jsonThermostat = new JsonThermostat(settings, temperatureConverter)
const httpSensor = new HttpTemperatureSensor('http://dummy-sensors.azurewebsites.net/api/sensor/abba5', httpClient)
const httpThermostat = new HTTPThermostat(httpSensor, jsonThermostat)
httpThermostat.getStatus()
.then( response => {
console.log(response)
})
HTTP Temperature Sensor class
import HttpTemperatureSensor from '@maximva/home-automation'
import httpClient from 'axios'
let httpSensor: HttpTemperatureSensor = new HttpTemperatureSensor('http://dummy-sensors.azurewebsites.net/api/sensor/abba5', httpClient)
httpSensor.getTemperature()
.then( response => {
console.log(response)
})
JSON Thermostat class
import { JSONThermostat } from '@maximva/home-automation'
const settings = {
temperature : 20,
range : 2,
unit : "celsius"
}
const currentTemperature = {
temperature: 21,
unit: "celsius"
}
const temperatureConverter = new TemperaturConverter()
const jsonThermostat = new JsonThermostat(settings, temperatureConverter)
console.log(jsonThermostat.update(currentTemperature))
Temperature Converter class
import { TemperatureConverter } from '@maximva/home-automation'
const celsiusTemperature = 20
const temperature_converter = new TemperatureConverter()
console.log(`Temperature in fahrenheit: ${temperature_converter.celsiusToFahrenheit(celsiusTemperature)}`)
License
Have a look here for more information about the license: The Unlicense
Author
Maxim Vanden Abeele - Student at University College Vives, Belgium