Xiaomi Gateway Integration

thanks. turns out that reload_core_config didn’t seem to work and I had to do a complete HA restart. Your code for motion sensor and ringtone/alarm works great!

What this command make?

someone managed to find out the gateway key http://faire-ca-soi-meme.fr/hack/2017/04/24/hack-xiaomi-mi-smarthome-decouverte-de-clef/

Thanks. I’ve also cleaned up code in my repo.
It seems that plug need some time to calculate load power and than push data to gateway.
I’ve added request of current state right after switching on plug. Could you please make a couple of tests and provide debug log.
Test #1. Initial state plug: off, lamp switch: off. Turn on plug, wait a couple of minutes.Turn on lamp switch. Wait a couple of minutes. Switch off plug. Wait couple of minutes.
Test #2. Initial state: plug: off, lamp on. Turn on plug. Wait a couple of minutes. Turn off plug.

It checks that my tv is off, and that the time is between midnight and sunrise. Thats what I use to determine whether motion should turn on the nightlight. If the TV was on, then my assumption is that someone in the house is awake and has already configured the lights to their preference in that room.

FYI, before_sunrise is already midnight --> sunrise :slight_smile: So the after midnight clause is redundant.

once they need the EU certification (lots of waste time and money) plus VAT and taxes … well maybe price is not so nice anymore

maybe… what certification would be needed?
Only the gateway is mains voltage
Afaik zigbee does not need certification in eu (maybe FCC in is though)
CE mark in the eu is mostly self certification - http://www.ce-marking.org/how-obtain.html

I’m sure that actually paying VAT would be the biggest price bump…

1 Like

Hey all. Who’s repo is most up to date now? I’m a bit behind and want to get the ring tone and luminosity sensor support.

TIA!

and I am lost … with all the forks …

You can see the differences between the forks here: https://github.com/lazcad/homeassistant/network

Thanks. Switched to your repo.

The work on this component seems to be very stable by now to be merged into the main HA repo, don’t you guys think?
Since @rave has been away for some time now (I have send a PM to him here and he has not answered), should someone else, like @Danielhiversen submit the component?

4 Likes

In Australia it’s only $AUD1100 and takes a couple of days, though the current model would fail as it needs to have insulated pins…so that if someone doesn’t plug it in properly but enough to complete the circuit and you say drop a piece of metal down against the wall and it manages to fall across the live pins you don’t get friend when you reach for it as the compulsory safety switches aren’t 1000% perfect. Obviously an essential safety measure as it’s a massive problem and has caused millions of deaths. [/sarcasm]

The EU might be more expensive, as it’s even more anally retentive than Australia (quite an accomplishment), but I can’t imagine it’s that much more.

@abmantis I think he said he was going away for a while a bit earlier. As a non-developer my opinion on that is almost worthless compared to any devs but I do think he’s earned the right to have input on when it’s merged and for you to wait a bit longer for his return.

I am not going to add this to the main repo, if rave not ask me to do so.
It is mainly his code, so it up to him to decide when he wants to add it.

3 Likes

Yeah I agree that it should be added by him. I just tough that he might have lost interest on the project. But if he said he was going a way for a while, we should wait.

Hi,

I’m trying to automate a notification to warn when devices are running low on battery. I don’t really want to create a trigger for every device I have… they’re too many:

- alias: Notify when the battery_level is low
  trigger:
    platform: template
    value_template: >
        {% for state in states.binary_sensor %}
            {% if state.attributes.battery_level %}
                {% if state.attributes.battery_level | int > 10 %} 
                    false 
                {%else%}
                    true
                {% endif %}
            {% endif %}
        {% endfor %}     
  action:
    service: notify.slack_general
    data_template:
      message: >
        {% for state in states.binary_sensor %}
            {% if loop.first %}Devices with battery level low: {% endif %}
            {% if state.attributes.battery_level %}
                {% if state.attributes.battery_level | int < 10 %} 
                    {{ state.name }} - {{ state.attributes.battery_level }}%;
                {% endif %}
            {% endif %}
        {% endfor %}

But I first I don’t really like the “work” this makes HA do in the background and it’s not working anyway.
Does anyone have any better idea on how to do it in a better way?

Thanks

I dont have the complete answer but what about setting a condition so it only checks at a certain time every day (if you want it not to be running all the time)

True, could do it every hour or so. I though about that last night, was just checking if there was a perfect way of doing it.

Try this:

{% set num = 0 %}
{% for state in states.binary_sensor %}
    {% if state.attributes.battery_level %}
        {% if state.attributes.battery_level | int < 10 %} 
                {% set num = num + 1|float %}
        {% endif %}
   {% endif %}
        {%- if loop.last%}
           {%- if num > 0 %}
                  True
            {%- else -%}
                   False
            {%- endif %}
       {%- endif %}
{% endfor %}     

You can have it as a condition, and use time for trigger. Please share the final results if you sucess

1 Like