Coder Social home page Coder Social logo

kotlin-ecobee-parser's Introduction

Ecobee report parser

This is a very simple and minimalistic (my first try with kotlin) of an ecobee report data parser.

Ecobee provides a detailed report of your thermostat to be downloaded via it’s portal. The report is a CSV file including readings from all your thermostat plus your sensors.

The report layout however is not very friendly to parse via conventional methods. The first 4 lines have some header information

#,Thermostat,identifier,XXXXXXXXXX
#,Thermostat,name,Main Floor
#,Start,date,2017-02-01
#,End,date,2017-02-28

And then a CSV header information with 19 columns for the thermostat plus 2 extra columns for each sensor you have.

This implementation of a parser will parse the file and extract information and regardless of how many sensors you have it will always generate a SensorData object with the following properties:

SensorData(type=temperature, name=outdoor, timestamp=Sun Nov 19 23:20:00 EST 2017, value=38.4, thermostatId=XXXXXXXXX)

It generates the following type of events:

  • temperature

  • motion

  • humidity

  • wind_speed

  • desired_heat - Heat setting on the thermostat at that time

  • desired_cool - Cool setting on the thermostat at that time

  • cool - HVAC running time

  • heat - Furnace (1s stage only) running time

It will use the sensor name to define where the reading came from, using outdoor as a value for outdoor readings.

Here’s a sample of data it will generate after you feed one report to it.

SensorData(type=motion, name=Upstairs, timestamp=Sun Nov 19 23:20:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=outdoor, timestamp=Sun Nov 19 23:20:00 EST 2017, value=38.4, thermostatId=XXXXXXXXXX)
SensorData(type=wind_speed, name=outdoor, timestamp=Sun Nov 19 23:20:00 EST 2017, value=8.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=Kids Bedroom 1, timestamp=Sun Nov 19 23:20:00 EST 2017, value=68.9, thermostatId=XXXXXXXXXX)
SensorData(type=motion, name=Kids Bedroom 1, timestamp=Sun Nov 19 23:20:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=Bedroom, timestamp=Sun Nov 19 23:20:00 EST 2017, value=67.1, thermostatId=XXXXXXXXXX)
SensorData(type=motion, name=Bedroom, timestamp=Sun Nov 19 23:20:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=Family Room, timestamp=Sun Nov 19 23:20:00 EST 2017, value=70.5, thermostatId=XXXXXXXXXX)
SensorData(type=motion, name=Family Room, timestamp=Sun Nov 19 23:20:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=desired_cool, name=Upstairs, timestamp=Sun Nov 19 23:25:00 EST 2017, value=74.0, thermostatId=XXXXXXXXXX)
SensorData(type=desired_heat, name=Upstairs, timestamp=Sun Nov 19 23:25:00 EST 2017, value=68.0, thermostatId=XXXXXXXXXX)
SensorData(type=humidity, name=Upstairs, timestamp=Sun Nov 19 23:25:00 EST 2017, value=38.0, thermostatId=XXXXXXXXXX)
SensorData(type=cool, name=Upstairs, timestamp=Sun Nov 19 23:25:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=heat, name=Upstairs, timestamp=Sun Nov 19 23:25:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=Upstairs, timestamp=Sun Nov 19 23:25:00 EST 2017, value=69.0, thermostatId=XXXXXXXXXX)
SensorData(type=motion, name=Upstairs, timestamp=Sun Nov 19 23:25:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=outdoor, timestamp=Sun Nov 19 23:25:00 EST 2017, value=38.4, thermostatId=XXXXXXXXXX)
SensorData(type=wind_speed, name=outdoor, timestamp=Sun Nov 19 23:25:00 EST 2017, value=8.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=Kids Bedroom 1, timestamp=Sun Nov 19 23:25:00 EST 2017, value=68.9, thermostatId=XXXXXXXXXX)
SensorData(type=motion, name=Kids Bedroom 1, timestamp=Sun Nov 19 23:25:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=Bedroom, timestamp=Sun Nov 19 23:25:00 EST 2017, value=67.1, thermostatId=XXXXXXXXXX)
SensorData(type=motion, name=Bedroom, timestamp=Sun Nov 19 23:25:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=temperature, name=Family Room, timestamp=Sun Nov 19 23:25:00 EST 2017, value=70.5, thermostatId=XXXXXXXXXX)
SensorData(type=motion, name=Family Room, timestamp=Sun Nov 19 23:25:00 EST 2017, value=0.0, thermostatId=XXXXXXXXXX)
SensorData(type=desired_cool, name=Upstairs, timestamp=Sun Nov 19 23:30:00 EST 2017, value=74.0, thermostatId=XXXXXXXXXX)
SensorData(type=desired_heat, name=Upstairs, timestamp=Sun Nov 19 23:30:00 EST 2017, value=68.0, thermostatId=XXXXXXXXXX)

Using it

The main class is EcobeeParser, you just need to provide an InputStream to it. It has an iterator() function that allows you to use it with a Sequence, this way, whatever you intend to do with the data (index, send via kafka) it’s a matter of your choice.

val parser = EcobeeParser(FileInputStream(File("../pathToFile")))
Sequence { parser.iterator() }.forEach { println(it) }

kotlin-ecobee-parser's People

Contributors

viniciusccarvalho avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.