/ha-cc-cometblue

HomeAssistant Custom Component for CometBlue Thermostat

Primary LanguagePython

Home Assistant Custom Components

CometBlue

HomeAssistant Custom Component for CometBlue/Xavax/Sygonix Bluetooth Thermostats. Based on work of mirko located on Github

Requirements

What works

Feature Get Set
Mode ✔️ ✔️
Childlock ✔️ ✔️
Target Temperature ✔️ ✔️
Current Temperature ✔️ ✔️
Open Window Detection ✖️ ✖️
Holiday ✖️ ✖️
Battery Level ✔️
Low Battery ✔️
Model ✔️
Manufacturer Name ✔️
Firmware Rev. ✔️
Software Rev. ✔️

Installation

Warning: If you are using venv for running hass as I do, You will probably want to shoot your brain out of your head during installation steps 😉 . Just like I did when I was creating this installation procedure.

There are several steps that you will have to execute as pi/root user on the other hand some steps are better executed as homeassistant user in venv (if you are using venv, of course). Such commands will be preceeded by string (homeassistant)$. Otherwise execute commands as pi/root.

  1. Installation of cometblue Python library You should install git if you didn't already.

    $ apt install git -y
    (homeassistant)$ cd /tmp
    (homeassistant)$ git clone https://github.com/xrucka/cometblue.git
    (homeassistant)$ cd cometblue
  2. Follow original installation procedure at: https://github.com/xrucka/cometblue#installation

  3. Install Dbus and some depencies for PyGObject if you didn't already

    $ apt install python3-dbus libglib2.0-dev libgirepository1.0-dev libcairo2-dev

    Dbus will be installed globally but in case you are running hass in venv you will need to copy dbus folder and some other files to venv site-packages location

    $ locate dbus
    ...
    /usr/lib/python3/dist-packages/_dbus_bindings.cpython-35m-arm-linux-gnueabihf.so
    /usr/lib/python3/dist-packages/_dbus_glib_bindings.cpython-35m-arm-linux-gnueabihf.so
    /usr/lib/python3/dist-packages/dbus
    ...

    Copy at least theese two files and one folder to /srv/homeassistant/lib/python3.5/site-packages/ and change ownership to homeassistant user

    Or you can just use --system-site-packages switch when you are creating venv. If you have venv already created and you want to use system site packages, you can always remove the file no-global-site-packages.txt from your venv location. More info in venv docs. Thanks to @danielkucera to point that out.

    cp -r /usr/lib/python3/dist-packages/{dbus,_dbus_bindings.cpython-35m-arm-linux-gnueabihf.so,_dbus_glib_bindings.cpython-35m-arm-linux-gnueabihf.so} /srv/homeassistant/lib/python3.5/site-packages/
  4. Install PyGObject

    (homeassistant)$ pip3 install pygobject
  5. If you are using venv in you HA installation you have to allow homeassistant user to use bluetooth dbus so add this:

    <policy user="homeassistant">
        <allow send_destination="org.bluez"/>
    </policy>

    to config file /etc/dbus-1/system.d/bluetooth.conf

    But you should add it before default deny section.

      <policy context="default">
        <deny send_destination="org.bluez"/>
      </policy>

    Restart bluetooth.service

    $ systemctl restart bluetooth.service
  6. Checkout latest version of cometblue module to your HA config path. If you followed HA recomendations it could be done by this command:

    (homeassistant)$ cd /home/homeassistant/.homeassistant/custom_components/
    (homeassistant)$ git clone https://github.com/Hy3n4/ha-cc-cometblue cometblue

    At this moment you have to change ownership of downloaded files!

  7. Copy dbus folder from it's original location (this issue is discussed here)

  8. Create HA config file

    platform: cometblue
    devices:
      living_room_cb:
        mac: 00:00:00:00:00:00
  9. Check config within Home Assistant and restart HA

Links

https://github.com/xrucka/cometblue

TODO

This readme file ;) Posibly make it a supported part of HA??

Troubleshooting

If you encounter any problem you should look into hass logfile located in config dir. If there is no useful information turn on debugging in hass config.

logger:
  default: warning
  logs:
    homeassistant.components.climate: debug
    custom_components.climate.cometblue: debug
    cometblue.device: debug

Notes

Special thanks to mirko for his work on Github