npm package: @maximva/home-automation
Description: Home automation package
Author: Maxim Vanden Abeele
Latest version: 0.8.3

# Home Automation Package

![npm badge](https://img.shields.io/npm/v/@maximva/home-automation?color=green)
![ESLint](../../workflows/ESLint/badge.svg?branch=master)
![Markdown Linter](../../workflows/Markdown%20Linter/badge.svg?branch=master)
![Tests](../../workflows/Tests/badge.svg?branch=master)

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:

```bash
npm install @maximva/home-automation
```

## Examples

### HTTP Thermostat class

```typescript
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

```typescript
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

```typescript
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

```typescript
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](https://github.com/vives-software-engineering-2020/home-automation-maximva/blob/master/LICENSE.md)

## Author

Maxim Vanden Abeele - Student at University College Vives, Belgium