As an smartapp example that you can use with My custom Ecobee device, please take a look at the following script:
Enjoy!