Ecobee Status Monitor

Table of Contents

Problem

Home Assistant would report that there was a problem connecting to the Ecobee servers when a change was made to the thermostat from Home Assistant. Home Assistant does not (in May 2021) have the ability to check the status of the Ecobee API. It only just makes calls to the API.

Back to Top

Solution

Since Ecobee had a couple of issues within the last couple of weeks when I attempted to make changes to the thermostat, I decided to build an automation that would update an indicator in Home Assistant to whether the Ecobee API status page was showing that everything is operational.

If the "All Systems Operational" message is not shown on the Ecobee status page, then the Ecobee API Status indicator in Home Assistant is set to false. From there, automations can be triggered based on the state of the API. If the previously stated message is shown on the page, then the Home Assistant sensor will show true.

Back to Top

Technology

This application was written with .NET Core 3.1 and Selenium WebDriver.

Using Webdriver, it goes to the Ecobee API Status website and checks the text on the page. Then it updates the local Home Assistant instance based on whether it is true or false. This automation runs once per 10 minutes, but can be configured to run at other intervals.

Back to Top

Installation

Copy The Files

Within VS Code, I have a task that does the deployment for me. That task does a build with release configuration and ssh file copy to the server that the code will be running from with a single command. You can see the tasks.json file to see how this is done.

System Service

To have the application run on startup, I have configured it to run as a system service. To do this, you will need to do the following.

iamadmin@media:~/ecobeestatus$ sudo cp almostengr.ecobeestatus.service /lib/systemd/system
iamadmin@media:~/ecobeestatus$ sudo systemctl daemon-reload 
iamadmin@media:~/ecobeestatus$ sudo systemctl enable almostengr.ecobeestatus.service 
Created symlink /etc/systemd/system/multi-user.target.wants/almostengr.ecobeestatus.service → /lib/systemd/system/almostengr.ecobeestatus.service.
iamadmin@media:~/ecobeestatus$ sudo systemctl start almostengr.ecobeestatus.service 

Last step is to confirm that the process is running.

iamadmin@media:~/ecobeestatus$ sudo systemctl status almostengr.ecobeestatus.service 
● almostengr.ecobeestatus.service - Ecobee Status Monitor by almostengr
     Loaded: loaded (/lib/systemd/system/almostengr.ecobeestatus.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-05-04 06:48:20 CDT; 12s ago
       Docs: https://thealmostengineer.com/ecobeestatus
   Main PID: 223570 (Almostengr.Ecob)
      Tasks: 10 (limit: 38350)
     Memory: 35.2M
     CGroup: /system.slice/almostengr.ecobeestatus.service
             └─223570 /home/iamadmin/ecobeestatus/Almostengr.EcobeeStatus

May 04 06:48:20 media systemd[1]: Started Ecobee Status Monitor by almostengr.

appsettings.json

Provided with the code is the appsettings.template.json file. This file has all of the properties in it that are needed to run, but you have to enter the corresponding values for your installation.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AppSettings": {
    "HomeAssistant": {
      "Url": "<HA IP address>",
      "Token": "<HA token>"
    },
    "EcobeeStatusUrl": "https://status.ecobee.com"
  }
}
  • "HA IP Address" - this value should have the web address (with http or https included) to access your Home Assistant instance.
  • "HA token" - this value needs to be replaced with the long-time token from Home Assistant. This token can be generated by logging into Home Assistant and going to your user profile.

The other properties in the file do not need to be changed. If you would like additional logging to be done, then you can change the corresponding logging settings.

Back to Top

Uninstall

To remove the application as a service, run the commands below.

iamadmin@media:~/ecobeestatus$ sudo systemctl disable almostengr.ecobeestatus
iamadmin@media:~/ecobeestatus$ sudo systemctl stop almostengr.ecobeestatus
iamadmin@media:~/ecobeestatus$ sudo systemctl status almostengr.ecobeestatus
iamadmin@media:~/ecobeestatus$ sudo rm /lib/systemd/system/almostengr.ecobeestatus

Once you have ran the above commands, then you can remove the application files from the directory that you installed them in.

Back to Top

Troubleshooting

Incorrect Path in Service File

I did encounter an error when setting up the system service. The problem was that the path that I had entered in the service file was incorrect. As a result, the daemon could not call the program to start.

Below is the output that you will see if you have this error. The solution is to stop the service from running, fix the path in the service file, and then start the service again.

iamadmin@media:~/ecobeestatus$ sudo systemctl status almostengr.ecobeestatus.service 
● almostengr.ecobeestatus.service - Ecobee Status Monitor by almostengr
     Loaded: loaded (/lib/systemd/system/almostengr.ecobeestatus.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2021-05-04 06:46:10 CDT; 3s ago
       Docs: https://thealmostengineer.com/ecobeestatus
    Process: 223446 ExecStart=/home/iamadmin/ecobeestatus (code=exited, status=203/EXEC)
   Main PID: 223446 (code=exited, status=203/EXEC)

May 04 06:46:10 media systemd[1]: almostengr.ecobeestatus.service: Scheduled restart job, restart counter is at 5.
May 04 06:46:10 media systemd[1]: Stopped Ecobee Status Monitor by almostengr.
May 04 06:46:10 media systemd[1]: almostengr.ecobeestatus.service: Start request repeated too quickly.
May 04 06:46:10 media systemd[1]: almostengr.ecobeestatus.service: Failed with result 'exit-code'.
May 04 06:46:10 media systemd[1]: Failed to start Ecobee Status Monitor by almostengr.

Back to Top

Back To Top