Ship your Ecobee runtime, sensor and weather data to InfluxDB and/or MQTT.
- Register and enable the developer dashboard on your Ecobee account at https://www.ecobee.com/developers/
- Go to https://www.ecobee.com/consumerportal/index.html , navigate to Developer in the right-hand menu, and create an App.
- Create a config.json file similar to config.example.json above. This file should exist where your work_dir is defined.
- Build the project (see Build section).
- Run
ecobee_influx_connector -list-thermostats -config $WORK_DIR/config.jsonat an interactive terminal; it'll provide a PIN. Make sure to you replace $WORK_DIR with your config path. - Go to https://www.ecobee.com/consumerportal/index.html, navigate to My Apps in the right-hand menu, and click Add Application.
- Paste the PIN there and authorize the app.
- Return to the
ecobee_influx_connectorCLI and hit Enter.
You should then be presented with a list of thermostats in your Ecobee account, along with their IDs.
Configuration is specified in a JSON file. Create a file (based on the template config.example.json stored in this repository) and customize it:
api_keyis created above in steps 1 & 2.thermostat_idcan be pulled from step 5 above; it's typically your device's serial number.work_diris where client credentials,config.json, and (yet to be implemented) last-written watermarks are stored.- Use the
influx_*config fields to configure the connector to send data to your InfluxDB. If using tokens for bucket authentication, then leave the user and password config fields empty. - Use the
mqttconfig section to configure the connector to send data to your MQTT broker:enabled: Set totrueto enable MQTT publishingserver: MQTT broker hostname or IP addressport: MQTT broker port (typically 1883 for unencrypted, 8883 for TLS)usernameandpassword: Optional credentials for the MQTT brokertopic_root: Root topic under which all data will be published (e.g., "ecobee")timeout: Timeout in seconds for MQTT publish operations (optional; default:3)
- Use the
write_*config fields to tell the connector which pieces of equipment you use.
Note: At least one output method (InfluxDB or MQTT) must be configured. The connector will exit with an error if neither InfluxDB nor MQTT is properly configured.
A Dockerfile is provided. To build your Docker image, cd into the project directory and run docker build -t ecobee_influx_connector .
A Docker image is also provided that can be configured via environment variables. View it on Docker Hub, or pull it via docker pull cdzombak/ecobee_influx_connector.
To use the Docker container make sure the path to the config.json is provided as a volume with the path /config. This location will also be used to store the refresh token and config.json.
Before building a persistent container, you will want to execute docker run --rm -it -v $HOME/ecobee:/config cdzombak/ecobee_influx_connector -config "/config/config.json" -list-thermostats so that you can get your token cached (/config/ecobee-cred-cache). This will give you a single key you can then use to authenticate with your ecobee api app. After auth you should see the thermostat_ids listed for all your devices.
If you build a persistent container before performing the above, the initial token request will loop and it will be hard to get the cached token.
There is an example docker-compose.yml file above. Make sure to modify the volumes section so that it maps your /config folder to containers /config folder.
Example:
volumes:
- $DOCKERAPPPATH/ecobee_influx_connector:/configExample:
If using the image you built from Dockerfile, use:
docker run -d --name ecobeetest --restart=always -v ./config:/config -it ecobee_influx_connectorIf using the Docker image, use:
docker run -d --name ecobeetest --restart=always -v ./config:/config -it cdzombak/ecobee_influx_connector:latestInstall my Debian repository if you haven't already:
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://dist.cdzombak.net/deb.key | sudo gpg --dearmor -o /etc/apt/keyrings/dist-cdzombak-net.gpg
sudo chmod 0644 /etc/apt/keyrings/dist-cdzombak-net.gpg
echo -e "deb [signed-by=/etc/apt/keyrings/dist-cdzombak-net.gpg] https://dist.cdzombak.net/deb/oss any oss\n" | sudo tee -a /etc/apt/sources.list.d/dist-cdzombak-net.list > /dev/null
sudo apt-get updateThen install ecobee_influx_connector via apt-get:
sudo apt-get install ecobee-influx-connectormake buildTo cross-compile for eg. Linux/amd64:
env GOOS=linux GOARCH=amd64 go build -ldflags="-X main.version=$(./.version.sh)" -o ./ecobee_influx_connector .- Build the
ecobee_influx_connectorbinary or install it per the instructions above. - Copy it to
/usr/local/binor your preferred location. - Create a work directory for the connector. (I put this at
$HOME/.ecobee_influx_connector.) - Run
chmod 700 $YOUR_NEW_WORK_DIR. (For my work directory, I ranchmod 700 $HOME/.ecobee_influx_connector.) - Create a configuration JSON file, per the Configure instructions above. (I put this at
$HOME/.ecobee_influx_connector/config.json.) - Customize
ecobee-influx-connector.servicewith your user/group name and the path to your config file. - Copy that customized
ecobee-influx-connector.serviceto/etc/systemd/system. - Run
chown root:root /etc/systemd/system/ecobee-influx-connector.service. - Run
systemctl daemon-reload && systemctl enable ecobee-influx-connector.service && systemctl start ecobee-influx-connector.service. - Check the service's status with
systemctl status ecobee-influx-connector.service.
When MQTT is enabled, the connector publishes data to the following topic structure:
<topic_root>/<thermostat_id>/<category>/<measurement>
Where:
<topic_root>is the configured root topic (e.g., "ecobee")<thermostat_id>is your thermostat's ID from the configuration<category>is the data category (runtime, sensor, weather)<measurement>is the specific metric being published
Example: If your topic root is "home/sensors" and your thermostat ID is "123456789", then the indoor temperature would be published to: home/sensors/123456789/runtime/temperature_f
The connector does not directly support multiple thermostats. To support this use case, I'd recommend running multiple copies of the connector. Each copy will need its own working directory and config file, but you should be able to use the same API key for each connector instance.
(If deploying using the "systemd on Linux" instructions, give each connector's service file a unique name, like ecobee-influx-connector-1.service, ecobee-influx-connector-2.service, and so on.
Apache 2.0; see LICENSE in this repository.
Chris Dzombak (GitHub: @cdzombak).