GithubHelp home page GithubHelp logo

bilan / connectlife-api-connector Goto Github PK

View Code? Open in Web Editor NEW
55.0 8.0 13.0 192 KB

Connectlife API proxy / MQTT Home Assistant integration

Dockerfile 0.59% PHP 75.11% JavaScript 0.02% Blade 22.44% Shell 1.84%

connectlife-api-connector's Introduction

Connectlife API proxy / MQTT Home Assistant integration

aarch64-shield amd64-shield armv6-shield armv7-shield i386-shield

The add-on utilizes the API acquired through reverse engineering from the Connectlife mobile app to control AC devices and integrates seamlessly with Home Assistant through MQTT, leveraging its discovery feature.

The reason for the add-on was the lack of official support for device integration.

I welcome pull requests, bug reports, and feature requests. Please feel free to submit them in the issues section.

Install in Home Assistant with Supervisor

ha_badge

  1. Make sure your Connectlife appliances are online.
  2. In Supervisor, navidate to the Add-on Store.
  3. From the overflow menu, select "Repositories".
  4. Add https://github.com/bilan/home-assistant-addons/.
  5. Wait for Add-on to appear or click "Reload" in the same overflow menu.
  6. Install / build thhe add-on.
  7. Turn on the add-on watchdog - Connectlife API is not stable and sometimes times out.
  8. In the Configuration section, fill in the necessary fields. If you leave the fields blank, the add-on will attempt to fetch MQTT credentials from the Supervisor API.

Run as independent docker container without HA/Supervisor

Build image

docker build . --build-arg='BUILD_FROM=alpine:3.20' -t ha-connectlife-addon

Run HTTP API and MQTT client both

docker run -it \
-p 8000:8000 \
-e CONNECTLIFE_LOGIN=connectlife-login-email \
-e CONNECTLIFE_PASSWORD=your-password \
-e LOG_LEVEL=info \
-e MQTT_HOST=host \
-e MQTT_USER=login  \
-e MQTT_PASSWORD=mqtt-pass  \
-e MQTT_PORT=1883 \
-e MQTT_SSL=false \
-e DEVICES_CONFIG='{"117":{"t_work_mode":["fan only","heat","cool","dry","auto"],"t_fan_speed":{"0":"auto","5":"super low","6":"low","7":"medium","8":"high","9":"super high"},"t_swing_direction":["straight","right","both sides","swing","left"],"t_swing_angle":{"0":"swing","2":"bottom 1\/6 ","3":"bottom 2\/6","4":"bottom 3\/6","5":"top 4\/6","6":"top 5\/6","7":"top 6\/6"}}}' \
ha-connectlife-addon /bin/ash -c '/usr/bin/supervisord -c /home/app/docker-files/supervisord.conf'

HTTP API only

docker run -it \
-p 8000:8000 \
-e CONNECTLIFE_LOGIN=connectlife-login-email \
-e CONNECTLIFE_PASSWORD=your-password \
-e LOG_LEVEL=info \
ha-connectlife-addon /bin/ash -c 'php artisan serve --port=8000 --host=0.0.0.0'

MQTT client only

docker run -it \
-e CONNECTLIFE_LOGIN=connectlife-login-email \
-e CONNECTLIFE_PASSWORD=your-password \
-e LOG_LEVEL=info \
-e MQTT_HOST=host \
-e MQTT_USER=login  \
-e MQTT_PASSWORD=mqtt-pass  \
-e MQTT_PORT=1883 \
-e MQTT_SSL=false \
-e DEVICES_CONFIG='{"117":{"t_work_mode":["fan only","heat","cool","dry","auto"],"t_fan_speed":{"0":"auto","5":"super low","6":"low","7":"medium","8":"high","9":"super high"},"t_swing_direction":["straight","right","both sides","swing","left"],"t_swing_angle":{"0":"swing","2":"bottom 1\/6 ","3":"bottom 2\/6","4":"bottom 3\/6","5":"top 4\/6","6":"top 5\/6","7":"top 6\/6"}}}' \
ha-connectlife-addon /bin/ash -c 'php artisan app:mqtt-loop'

API endpoints

  • GET /api/devices

    example: curl -v http://0.0.0.0:8000/api/devices

  • POST /api/devices/{DEVICE_ID}

    example: curl -v http://0.0.0.0:8000/api/devices/pu12345 -d '{"t_temp":32}' -H "Content-Type: application/json"

Air Conditioner properties

Values for my personal split air conditioner (deviceFeatureCode 117, deviceTypeCode 009)

Property Description Type Example
t_power on / off uint 0 - off, 1 - on
t_temp temperature uint 21
t_beep buzzer uint 0, 1
t_work_mode mode uint 3
t_tms ?
t_swing_direction horizontal swing
t_swing_angle vertical swing
t_temp_type temp unit string "0" - fahr, "1" - celsius
t_fan_speed fan speed uint 0
t_fan_mute silence mode uint 0, 1
t_super fast mode uint 0,1
t_eco eco mode uint 0,1

t_work_mode

  • 0 - fan only
  • 1 - heat
  • 2 - cool
  • 3 - dry
  • 4 - auto

t_fan_speed

  • 0 - auto
  • 5 - super low
  • 6 - low
  • 7 - medium
  • 8 - high
  • 9 - super high

t_swing_direction

  • 0 - straight
  • 1 - right
  • 2 - both sides
  • 3 - swing
  • 4 - left

t_swing_angle

  • 0 - swing
  • 2 -> 7 - from bottom to top

Useful links

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.