Giter Club home page Giter Club logo

evohome-async's Introduction

evohome-async

Python client to asynchronously access the Total Connect Comfort RESTful API.

It is intended to be a faithful port of https://github.com/watchforstock/evohome-client, but async-aware. That is, it exposes a superset of the evohome-client schema (same namespace, same JSON), but with some notable differences between the two (see below).

It provides support for Honeywell/Resideo TCC-based systems, such as Evohome, Round Thermostat, VisonPro and others:

This client requires the aiohttp library. If you prefer a non-async client, evohome-client uses requests instead.

Please contact me (e.g. open an issue) if you would like to help extending the functionality of evohome-async to include cooling, as support for such is minimal currently.

CLI for schedules

If you download the git repo you can use a basic CLI for backup/restore of schedules (incl. DHW, if any), for example:

python client.py -u [email protected] -p password get-schedules --loc-idx 2 > schedules.json

... and to restore:

python client.py -u [email protected] -p password set-schedules --loc-idx 2 -f schedules.json

To avoid exceeding the vendor's API rate limit, you can cache the access tokens via the --cache-tokens switch.

Beware that the above switch will save your tokens to .evo-cache.tmp: this presents a security concern.

Differences from non-async version

The difference between the evohomeasync and evohomeclient libraries have been kept to the minimum, and it is planned for exisiting docs to be useful. Thus, it should be relatively easy to port your code over to this async library should you wish.

The non-async documentation (from evohomeclient) is available at http://evohome-client.readthedocs.org/en/latest/

Technical differences

Some additional functionality has been added to the methods that wrap the vendor APIs (e.g. restore schedules by name, as an alternative to by id). Note that this library is not able to expose more core functionality than it's non-async cousin (i.e. they both use the same vendor API).

Note that since 0.4.0, some attributes have been renamed, and a few have been deprecated altogether (when required, an informative exception will be thrown).

In both cases (evohomeclient2 and evohomeclient):

  • requires aiohttp instead of requests:
  • added a new instantiation argument, session to allow the client to utilize the consumer's aiohttp session
   self._session = kwargs.get('session', aiohttp.ClientSession(
       timeout=aiohttp.ClientTimeout(total=30)
   ))

For the newer evohome API (evohomeclient2):

  • import evohomeasync2 instead of import evohomeclient2
  • must invoke await client.login() after instntiating EvohomeClient
  • gerneric Exceptions have changed... requests.ConnectionError becomes: aiohttp.ClientConnectionError requests.HTTPError becomes aiohttp.ClientResponseError
  • but in most case, exceptions are no longer generic (since 0.4.0)... RateLimitExceeded, and AuthenticationFailed (among others)

For the older evohome API (evohomeclient):

  • import evohomeasync instead of import evohomeclient
  • Exceptions change similar to the above

Other minor changes:

  • some attrs/methods have been renamed (invoking the old name will advise the new name)
  • Hotwater.zoneId is deprecated (can use .dhwId, or _id)
  • ZoneBase.zone_type is deprecated (use .TYPE))
  • some sentinel values are now None

evohome-async's People

Contributors

andrew-blake avatar jzwack avatar nomis avatar onkelbeh avatar peterbaxter avatar sander76 avatar watchforstock avatar zxdavb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

evohome-async's Issues

Battery status

Would it be possible to read the battery status per device?

schedule backup: object of type 'NoneType' has no len()

Hello,

i just wanted your nice python script to set schedules..therofore i wanted an example what is it look like currently:

During handling of the above exception, another exception occurred:

after running the command:

client.zone_schedules_backup('filename.json')

i get:

  File "<stdin>", line 1, in <module>
  File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\evohomeasync2\__init__.py", line 301, in zone_schedules_backup
    return self._get_single_heating_system().zone_schedules_backup(filename)
  File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\evohomeasync2\__init__.py", line 196, in _get_single_heating_system
    if len(self.locations) != 1:
TypeError: object of type 'NoneType' has no len()

Multiple Evohome wiki. Version number not being added to manifest.json - prevents starting

Hi there,
Apologies if I'm doing this wrong - I'm brand new to HA. Very many thanks for the idiot-proof guide to getting this working.
I followed this process for the first time a few days ago, and just followed it again after the recent Core update. On both occasions the version number was not added to the manifest.json file and that subsequently prevented the integration from starting.

Screenshot attached below showing the part of the process. I have not yet found an idiot-proof guide to sed to allow me to un-pick why this might be. When I amend the file manually the integration will then start fine.

Thanks again for making this accessible to massive amateurs like me :)

ACDSeeQVUltimate13_cP86a4ymjF

Home Assistant: Multiple Evohome Locations WIKI not working

@zxdavb

I followed all the steps in the "Home Assistant: Multiple Evohome Locations" WIKI you posted but still I not am able to add a secondary integration of evohome, if I go to "Developer Tools > Check Configuration" I still receive the following error message

"integration error: ‘evohome_1’ - not found.

it is the same error as before when i tryed to add integration to my /config/custom_components through "file editor" and "samba share add-on" (copy and create using windows PC)

Cooling within evoHome

I have an evoHome setup with multiple zones and a heat pump with the ability to cool.

Im not able to cool within the home assistant. I can only choose heat or off.

Am i missing something? If i change the settings to cooling on the evohome. The temperature rises on the display and on evohome. In my case evoahome still thinks we are heating but it does work. So of i lower the temperature within home assistant the heat pump starts to cool.

I would love the ability to change to cooling on heating with home assistant.

Created a script for creating/updating the "multiple evohome locations" in custom_components. Can you add it to the wiki?

Hi @zxdavb !

Thanks for helping me out earlier this evening.
I have created a shellscript that handles all the steps of "Hass: Multiple Evohome Locations".
It supports creating, as well as updating the integration automatically.

Could you add this to the wiki?
https://github.com/zxdavb/evohome-async/wiki/Hass:-Multiple-Evohome-Locations#step-6-finally-enable-the-new-integration

#!/bin/bash
#Script name: update_evohome_locations.sh
#Purpose: Create/Update your multiple evohome locations in the folder custom_components/
#Based on the wiki: https://github.com/zxdavb/evohome-async/wiki/Hass:-Multiple-Evohome-Locations

#This script is tested on Home Assistant OS.
#The script should be placed in this location and run from there: /config/custom_components/
#Run the script when you want to install multiple locations, and every time you have updated the HA core.
#How many extra copies of the integration do you want?
INSTANCES=1

HA_VERSION=`ha core info | grep "version:" | cut -d' ' -f2`

#These only need to be executed once
if [ ! -d "core" ] 
then
  git clone --filter=blob:none --sparse https://github.com/home-assistant/core
  git -C core sparse-checkout add homeassistant/components/evohome
fi

#Update git core folder with correct HA version
echo "Updating git core folder to current HA version..."
git -C core fetch --all
git -C core checkout $HA_VERSION

#Delete all old evohome folders
echo "Removing all evohome_x folders..."
rm -rf evohome_*

#Create all new evohome instances
for i in $(seq $INSTANCES)
do
  echo "Creating evohome_$i/" 
 
  #copy the evohome folder
  cp -r core/homeassistant/components/evohome evohome_$i

  #Update the files within the integration with proper values
  echo "Updating files in evohome_$i/"
  sed -i "/domain/ s/evohome/evohome_$i/" evohome_$i/manifest.json
  sed -i '/{/a \ \ "version": "0.0.1",' evohome_$i/manifest.json
  sed -i "/DOMAIN/ s/evohome/evohome_$i/" evohome_$i/const.py
done

Multiple Locations: `Config error: 'location_idx' = 1, but the valid range is ...`

Hi, Thanks for doing the work on developing this solution. I followed the instruction carefully, including the check items, but it seems something failed. I'm running HA in a Docker container on a Synology NAS with a macvlan IP address. I logged in as root to the container using Portainer's container console to execute the various instructions. Below are the error logs, summary and detailed. I've also attached an extract from my configuration.yaml and the session. Any help much appreciated.

Summary

Setup failed for custom integration 'evohome_1': Integration failed to initialize.
10:23:37 PM – (ERROR) setup.py
Config error: 'location_idx' = 1, but the valid range is 0-0. Unable to continue. Fix any configuration errors and restart HA
10:23:37 PM – (ERROR) evohome_1 (custom integration)

configuration.yaml redacted extract

evohome:
  username: "username1"
  password: "password1"
  location_idx: 0

evohome_1:
  username: "username2"
  password: "password2" [Includes special characters &#%+]
  location_idx: 1

Checking the custom_component changes:

67ab0b7e9d3b:/config/custom_components/evohome_1# **cat manifest.json**
{
  "version": "0.0.1",
  "domain": "evohome_1",
  "name": "Honeywell Total Connect Comfort (Europe)",
  "codeowners": ["@zxdavb"],
  "documentation": "https://www.home-assistant.io/integrations/evohome",
  "iot_class": "cloud_polling",
  "loggers": ["evohomeasync", "evohomeasync2"],
  "requirements": ["evohome-async==0.4.6"]
}

67ab0b7e9d3b:/config/custom_components/evohome_1# **cat const.py | grep 'DOMAIN'**
DOMAIN = "evohome_1"
STORAGE_KEY = DOMAIN

More than 1 location - help please!

I am a complete noob to this so I apologise in advance.
I have two Evohome installations on my TCC account and I want to capture the data from them separately. I don't need to control anything, just gather the status of each element.

I have managed to get Watchforstock's evohomeclient1 code to run and it returns the data for the first installation. I cannot make it 'see' the second installation. I have tried the evohomeclient2 code and it throws an exception for having other than a single installation. I have tried zxdavb's evohome-async code and get a different error. I have fumbled around trying to fix it myself for days. I would really appreciate some pointers to making it work.
I have attached screengrabs from the debugger.
evohomeclient1
evohomeclient2
evohomeasync2

Thanks for reading.

HACS compliant

Please make this HACS compliant, like 'evohome_cc'.
The integration cannot be added to HA as a HACS Custom repository:
"Repository structure for master is not compliant"

Adding a second evohome location creates error during setup

I have added a second evohome location exactly following the steps in the wiki.
I have two separate accounts on the Total Connect website.
I am running Home Assistant 2023.12.3

I get the following error:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 332, in _async_setup_component
result = await task
^^^^^^^^^^
File "/config/custom_components/customevohome3/init.py", line 265, in async_setup
await broker.save_auth_tokens()
File "/config/custom_components/customevohome3/init.py", line 445, in save_auth_tokens
user_id = self.client_v1.user_data["userInfo"]["userID"] # type: ignore[index]
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'userInfo'

In this case the error is in setting up the custom component (the evohome component loads as it should). But sometimes I get the same error in setting up the evohome component itself (but then the custom component loads successfully). I have been running the main and custom approach for a few years without any issues. The problem first appeared in HA 2023.12.1 (not 100% sure).

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.