GithubHelp home page GithubHelp logo

homeassistant-aqara's Introduction

homeassistant-aqara

Home-Assistant implementation for the Xiaomi (Aqara) gateway Supported sensors:

  • Temperature / Humidity - reports if temperature change reaches 0.5 ° C or the humidity change reaches 6%.
  • Magnet (Door / Window)
  • Motion
  • Button Switch(Each switch was shown as three individual virtual switches: ONE_CLICK, DOUBLE_CLICK and LONG_PRESS. Those virtual switches should be better used as automation triggers only)
  • Power Plug
  • Aqara Wall Switch

INSTALLATION

  1. Install Home-Assistant,
  2. Enable the developer mode of the gateway.
  1. Download and place aqara.py files in the home-assistant folder like this:

    • .homeassistant/custom_components/aqara.py
    • .homeassistant/custom_components/sensor/aqara.py
    • .homeassistant/custom_components/binary_sensor/aqara.py
  2. Add the new platform in the configuration.yaml: lowercase is important, multiple gateways is not supported by now.

     aqara:
       gateway_password: yourgatewaypassword
  3. restart the home assistant service, note that it may take several minutes to install the pyCrypto dependency during the first start.

CUSTOMIZATION

Since until now there is no way to retrieve the configured names from the gateway, Home-Assistant will display each sensor like that:

  • sensor.temperature_SENSORID
  • sensor.humidity_SENSORID
  • binary_sensor.magnet_SENSORID
  • binary_sensor.motion_SENSORID
  • etc.

To make it readable again, create a customize.yaml file in the home-assistant folder. You can use step 7 https://goo.gl/gEVIrn to identify the sensors.

  • Example

     sensor.temperature_158d0000fa3793:
       friendly_name: Living-Room T
     sensor.humidity_158d0000fa3793:
       friendly_name: Living-Room H
       icon: mdi:water-percent
    
     sensor.temperature_158d000108164f:
       friendly_name: Bedroom 1 T
     sensor.humidity_158d000108164f:
       friendly_name: Bedroom 1 H
       icon: mdi:water-percent
    
       ... etc.
  1. Add a line in the configuration.yaml:

homeassistant:

Name of the location where Home Assistant is running

name: Home ... time_zone: Europe/Paris customize: !include customize.yaml ```

Magnet Automation example

  • Example configuration.yaml
binary_sensor:
  - platform: template
    sensors:
      door:
        friendly_name: Frontdoor
        value_template: "{{ states.binary_sensor.magnet_158d0001179ae9.state == 'open' }}"
        sensor_class: opening
        entity_id:
            - binary_sensor.magnet_158d0001179ae9

automation:
 - alias: FrontDoorClosed
   trigger:
     platform: state
     entity_id: binary_sensor.door
     to: 'off'
   action:
     service: notify.TelegramNotifier
     data:
      message: Door closed
 - alias: FrontDoorOpened
   trigger:
     platform: state
     entity_id: binary_sensor.door
     to: 'on'
   action:
     service: notify.TelegramNotifier
     data:
      message: Door opened

TODO

  • multiple gateway support
  • include some options in the configuration file : IP, refresh frequency, etc.
  • generate a yaml file with discovered devices
  • integrate wireless switch, cube, gateway itself (turn on light / radio / etc.)

homeassistant-aqara's People

Contributors

bastshoes avatar crisone avatar fooxy avatar sublimepotato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

homeassistant-aqara's Issues

Own gateway functions

Hi,

Good job on this, thank you, it is working perfectly with my door and temperature sensors. A motion and switch is on the way now, will test them when they arrive.
Any news on the own gateway functions, like the light, wake clock and others?

Thanks!

Trigger problem with friendly_name

Hello,

Even though the trigger is successful for the non-friendly_named sensor as shown below in the log screenshot, the system is not able to associate it with the binary_sensor block definition.

I'm actually able to see that the auto named sensor (magnet 158d000110c38d) changing its icon on the UI but the Frontdoor icon is staying the same.

What is wrong here? :)

http://i.imgur.com/vmkRvIc.png

`binary_sensor:

  • platform: template
    sensors:
    door:
    friendly_name: Frontdoor
    value_template: "{{ states.binary_sensor.magnet_158d000110c38d.state == 'open' }}"
    sensor_class: opening
    entity_id:
    - binary_sensor.magnet_158d000110c38d

automation:

  • alias: FrontDoorClosed
    trigger:
    platform: state
    entity_id: binary_sensor.door
    to: 'off'
    action:
    service: persistent_notification.create
    data:
    message: "Balcony is closed"
    title: "Balcony is closed"
  • alias: FrontDoorOpened
    trigger:
    platform: state
    entity_id: binary_sensor.door
    to: 'on'
    action:
    service: persistent_notification.create
    data:
    message: "Balcony is open"
    title: "Balcony is open"`

Seems to be broken on HASS 0.39

Is it me or aqara is now broken on HASS 0.39 ?
Had to revert to 0.38.4...


ERROR:homeassistant.loader:Error loading custom_components.aqara. Make sure all dependencies are installed
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/homeassistant/loader.py", line 141, in get_component
module = importlib.import_module(path)
File "/usr/lib/python3.4/importlib/init.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 2254, in _gcd_import
File "", line 2237, in _find_and_load
File "", line 2226, in _find_and_load_unlocked
File "", line 1200, in _load_unlocked
File "", line 1129, in _exec
File "", line 1471, in exec_module
File "", line 321, in _call_with_frames_removed
File "/root/.homeassistant/custom_components/aqara.py", line 1, in
from homeassistant.components.discovery import load_platform
ImportError: cannot import name 'load_platform'
ERROR:homeassistant.loader:Unable to find component aqara

Info about magnet sensor and motion sensor

Hello,

First of all i want to say thanks for this developemtn about xioami smart home and their sensor.

Now i write to you because i have some doubts about magnet and motions sensors in home assistant.

How do you define them like binary.sensor or like sensor? I ask this, because i want integrate in homekit by home assistant homebridge, but in website, talks about binary sensor and in your example in github, you explain to define the xiaomi system like a sensor, but in automation talk about binary sensor.

Other thing using your custome component, is possible to link alarm HA with xioami alarm gateway?

thanks

Power Plug

Hi,
what about power plug integration ?

Regards
Alessandro

OSError: [Errno 98] Address already in use

17-01-09 12:56:40 homeassistant.bootstrap: Error during setup of component aqara
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/bootstrap.py", line 151, in _async_setup_component
None, component.setup, hass, config)
File "/usr/lib/python3.4/asyncio/futures.py", line 388, in iter
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
value = future.result()
File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
raise self._exception
File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/aqara.py", line 36, in setup
gateway.initGateway()
File "/home/homeassistant/.homeassistant/deps/pyAqara/gateway.py", line 50, in initGateway
self.socket = self._prepare_socket()
File "/home/homeassistant/.homeassistant/deps/pyAqara/gateway.py", line 144, in _prepare_socket
sock.bind(("0.0.0.0", self.MULTICAST_PORT))
OSError: [Errno 98] Address already in use

Temperature locks on 100 deg if sensor has no network

Hi,

the temperature reading locks on 100 deg if the sensor has no network, making the history graphs look very ugly.
This is happening on my house because of random power outages.
Maybe, the sensor should register the last value, what do you think?

Thanks,
Francisco

Updates?

Hi @fooxy any plans on updates. Would like too use wireless switches etc.

Error during setup of component aqara

I got this error...


16-12-21 16:23:14 homeassistant.bootstrap: Error during setup of component aqara
Traceback (most recent call last):
File "/home/homeassistant/.homeassistant/custom_components/aqara.py", line 23, in setup
gateway.initGateway()
File "/home/homeassistant/.homeassistant/deps/pyAqara/gateway.py", line 50, in initGateway
self.socket = self._prepare_socket()
File "/home/homeassistant/.homeassistant/deps/pyAqara/gateway.py", line 118, in _prepare_socket
sock.bind(("0.0.0.0", self.MULTICAST_PORT))
OSError: [Errno 98] Address already in use

Different interface

There is a way to include the IP in configuration? Because the Gateway is in another interface (I create an hotspot Wi-Fi with hostapd and dnsmasq) and HASS can't find it.
It give me a error configuration.

Motion sensor only trigger once

In my installation the binary motion sensor started as off and on the first motion detected it changed to on but then it never changes back again so I can only get one motion detected and then no more.

I added the lines

    @property
    def force_update(self):
        """Return True if state updates should be forced.
        If True, a state change will be triggered anytime the state property is
        updated, not just when the value changes.
        """
        return True

to the binary sensor code to be able to automate on motions even though the home assistant state never actually changes.

Is the behaviour to not go back to off intended?

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.