The simple challenge was simple, to build a Thermostat with a few basic functionalities.
As a user,
So that I can set the temperature hotter
I want to increase the thermostat's temperature.
As a user,
So that I can set the temperature cooler
I want to reduce the thermostat's temperature.
As a user,
So that I can save power,
I want to be able to switch power saving.
As a user,
So that I can restore factory settings,
I want to be able to reset the thermostat.
As a user,
So I know the energy usage of the thermostat,
I want to be able to ask the thermostat the current energy usage.
First, you would need to clone, change directory and install the dependencies running the following commands:
git clone git@github.com:georn/Thermostat.git
cd Thermostat
npm install
- Then to run it locally run the following command and enter
localhost:3000
on your browser:
npm start
- If you want to run the tests
npm test
The challenge is complete and here is a couple of demos of the application.
Basic Functionality of the Thermostat
It is also connected to a Weather API to get the temperature of different cities!
But there's always room for improvement and also I also would have liked it to look cool!
So, after leaving this code to gain some dust for a few months, I decided to start to refactor it for the sake of practice.
Rather than have the HTML document live by itself, I decided to go and put it on top of an Express.js server to also giving me the opportunity to take away the standalone Jasmine testing frameworks and bringing it as a package and ultimately step a notch on the application code.
The next step is to add styling to the application.
- Thermostat starts at 20 degrees
- The minimum temperature is 10 degrees
- If power saving mode is on, the maximum temperature is 25 degrees
- If power saving mode is off, the maximum temperature is 32 degrees
- Power saving mode is on by default
- Less than 18 degrees is low usage of energy
- Less than 25 degrees is medium usage of energy
This amazing people collaborated to the code, but by that time I wasn't a good git collaborator, so I didn't document it. Thus, it is now when they have their credits.
Here is a list of the technologies used:
- Javascript ES5
- JQuery
- OpenWeather API
- Node.js
- Express.js for a Web Application Framework
- Pug for a Template Engine
- Jasmine for Testing
- Istanbul for test coverage
- Travis CI for Continuous Integration
- Coveralls for web hosted test coverage
An article that helped me during the development of the application.