Mi(Xiaomi) Smart home bindings?

Hi!
I do not understand, from where do the units at the outlet come from?
mi.items:

Switch box_power           "On/Off [%s]"       <switch>    { channel="mihome:sensor_plug:id:power" }
Switch box_inuse           "inuse [%s]"        <switch>    { channel="mihome:sensor_plug:id:inUse" }
Number box_provided_power  "Provided Power"    <time>      { channel="mihome:sensor_plug:id:loadPower" }
Number box_power_consumed  "Power consumed"    <time>      { channel="mihome:sensor_plug:id:powerConsumed" }

mi.sitemap:

    Frame {
        Switch  item=box_power
        Switch  item=box_inuse
        Text    item=box_provided_power
        Text    item=box_power_consumed
    }

2

box_provided_power- should not be - current (A)?
Thanks!

You are confusing the concepts of power (W) and current (A). What is shown is power which had the correct unit, likewise for the consumption kWh which is the energy consumed.

Hello!
I have some strange problem. I tryed to connect gateway to the openhab 2 and it’s look like connected. I saw gateway and switches in the inbox - but after that my mi home app lost connection to the gateway. And I still can’t connect it again. I restarted it more that 10 times. It connects to mi home andoird app. I specify wifi, it connect to wifi and nothing more. Just “connection timed out”. Did anybody face this problem?
Thanks.
P.S. Looks like it’s not openhab issue. When I connect gateway to mobile internet it connected without problem, so it’s look like microtik/firewall or other network issue.
P.P.S. Sorry for bad english.

Thank you! I was confused by the fact that there are watts and kilowatts. Now I realized that Watts is the current power. And what do the kilowatts show (power_consumed), more precisely for what period of time?
There is no such value in the android application.

But my main question was different:

I did not specify the units of measure neither in the elements nor in the site map (Are circled on screenshots.), but they are. I’m wondering, from where? How it works?
Thanks!

I would guess that the kilowatt hours consumed energy count from the time the device is paired to the network and counting continuously until the maximum value of the internal number format is reached.
I would guess that you can reset the value by removing and re adding the device to the network.

Where the units come from internally in openhab I don’t know

Hello guys,
I just installed some xiaomi zigbee wall plug (without neutral wire) and it only work sometimes. Rules are triggered, status is changed, but light does not turn. Here is the items file

Group All
Group gLights           <light>         (All)
Group gOutdoorLight     <outdoorlight>  (gLights)

// Xiaomi Gateway
Switch XMGateway_LightSwitch "Gateway Light []" <light> { channel="mihome:gateway:7811dcb226c5:brightness" }
Dimmer XMGateway_Brightness "Gateway Brightness [%d %%]" <dimmablelight> [ "Lighting" ] { channel="mihome:gateway:7811dcb226c5:brightness" }
Color XMGateway_Color "Color" <rgb> { channel="mihome:gateway:7811dcb226c5:color" }
Dimmer XMGateway_ColorTemperature <heating> { channel="mihome:gateway:7811dcb226c5:colorTemperature" }
Number XMGateway_AmbientLight <sun> { channel="mihome:gateway:7811dcb226c5:illumination" }
Number XMGateway_Sound "Play Sound" <soundvolume-0> { channel="mihome:gateway:7811dcb226c5:sound" }
Switch XMGateway_SoundSwitch <soundvolume_mute> { channel="mihome:gateway:7811dcb226c5:enableSound" }
Dimmer XMGateway_SoundVolume "Volume [%d %%]" <soundvolume> { channel="mihome:gateway:7811dcb226c5:volume" }

// Xiaomi Aqara Mains Powered Wall Switch 1
Switch Light_outdoor_1 "Lampu Belakang" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral1:158d0001f503dc:ch1" }

// Xiaomi Aqara Mains Powered Wall Switch 2
Switch Light_outdoor_2 "Lorong garasi" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral2:158d0001f4fb29:ch1" }
Switch Light_outdoor_3 "Belakang pantry" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral2:158d0001f4fb29:ch2" }
// Xiaomi Aqara Mains Powered Wall Switch 2
Switch Light_outdoor_4 "Taman depan" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral2:158d0001f4d6a1:ch1" }
Switch Light_outdoor_5 "Outdoor Light5" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral2:158d0001f4d6a1:ch2" }
// Xiaomi Aqara Mains Powered Wall Switch 2
Switch Light_outdoor_6 "Depan pagar" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral2:158d0001f4fb55:ch1" }
Switch Light_outdoor_7 "LED pagar samping" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral2:158d0001f4fb55:ch2" }
// Xiaomi Aqara Mains Powered Wall Switch 2
Switch Light_outdoor_8 "Teras depan" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral2:158d0001f4c141:ch1" }
Switch Light_outdoor_9 "Depan garasi" <light> (gOutdoorLight) [ "Lighting" ] { channel="mihome:ctrl_neutral2:158d0001f4c141:ch2" }

and this is the log of working state and not working state. I define working by the existence of line like this that actually change the lamp state.

mihome_ctrl_neutral2_158d0001f4c141_ch1 changed from OFF to ON

2018-03-06 18:19:00.014 [vent.ChannelTriggeredEvent] - astro:sun:plus10:nauticDusk#event triggered START

2018-03-06 18:19:00.030 [vent.ChannelTriggeredEvent] - astro:sun:minus15:astroDusk#event triggered START

2018-03-06 18:19:00.038 [vent.ChannelTriggeredEvent] - astro:sun:minus15:nauticDusk#event triggered END

2018-03-06 18:19:00.046 [vent.ChannelTriggeredEvent] - astro:sun:plus10:civilDusk#event triggered END

2018-03-06 18:24:00.006 [vent.ChannelTriggeredEvent] - astro:sun:minus10:astroDusk#event triggered START

2018-03-06 18:24:00.010 [vent.ChannelTriggeredEvent] - astro:sun:minus10:nauticDusk#event triggered END

2018-03-06 18:24:00.544 [vent.ItemStateChangedEvent] - Light_outdoor_8 changed from ON to OFF

2018-03-06 18:24:00.558 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4c141_ch1 changed from ON to OFF

2018-03-06 18:24:05.301 [vent.ItemStateChangedEvent] - Light_outdoor_8 changed from OFF to ON

2018-03-06 18:24:05.310 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4c141_ch1 changed from OFF to ON

2018-03-06 18:27:49.218 [vent.ItemStateChangedEvent] - Light_outdoor_8 changed from ON to OFF

2018-03-06 18:27:49.224 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4c141_ch1 changed from ON to OFF

2018-03-06 18:27:51.947 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4c141_ch1 changed from OFF to ON

2018-03-06 18:27:51.951 [vent.ItemStateChangedEvent] - Light_outdoor_8 changed from OFF to ON

2018-03-06 18:32:01.483 [vent.ItemStateChangedEvent] - Light_outdoor_3 changed from ON to OFF

2018-03-06 18:32:01.488 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4fb29_ch2 changed from ON to OFF

2018-03-06 18:32:12.898 [vent.ItemStateChangedEvent] - Light_outdoor_3 changed from OFF to ON

2018-03-06 18:32:12.917 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4fb29_ch2 changed from OFF to ON

2018-03-06 18:32:36.390 [vent.ItemStateChangedEvent] - Light_outdoor_1 changed from ON to OFF

2018-03-06 18:32:36.394 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral1_158d0001f503dc_ch1 changed from ON to OFF

2018-03-06 18:34:00.017 [vent.ChannelTriggeredEvent] - astro:sun:home:astroDusk#event triggered START

2018-03-06 18:34:00.028 [vent.ChannelTriggeredEvent] - astro:sun:home:nauticDusk#event triggered END

2018-03-06 18:34:38.438 [vent.ItemStateChangedEvent] - Light_outdoor_3 changed from ON to OFF

2018-03-06 18:34:38.443 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4fb29_ch2 changed from ON to OFF

2018-03-06 18:34:40.595 [vent.ItemStateChangedEvent] - Light_outdoor_3 changed from OFF to ON

2018-03-06 18:34:40.604 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4fb29_ch2 changed from OFF to ON

2018-03-06 18:37:42.767 [vent.ItemStateChangedEvent] - Light_outdoor_7 changed from ON to OFF

2018-03-06 18:37:42.772 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4fb55_ch2 changed from ON to OFF

2018-03-06 18:37:43.742 [vent.ItemStateChangedEvent] - Light_outdoor_7 changed from OFF to ON

2018-03-06 18:37:43.754 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral2_158d0001f4fb55_ch2 changed from OFF to ON

2018-03-06 18:38:57.399 [vent.ItemStateChangedEvent] - Light_outdoor_1 changed from OFF to ON

2018-03-06 18:38:57.407 [vent.ItemStateChangedEvent] - mihome_ctrl_neutral1_158d0001f503dc_ch1 changed from OFF to ON

2018-03-06 18:43:00.008 [vent.ChannelTriggeredEvent] - astro:sun:minus15:astroDusk#event triggered END

2018-03-06 18:43:00.015 [vent.ChannelTriggeredEvent] - astro:sun:minus15:eveningNight#event triggered START

2018-03-06 18:43:00.020 [vent.ChannelTriggeredEvent] - astro:sun:minus15:night#event triggered START

2018-03-06 18:44:00.007 [vent.ChannelTriggeredEvent] - astro:sun:plus10:nauticDusk#event triggered END

2018-03-06 18:44:00.019 [vent.ChannelTriggeredEvent] - astro:sun:plus10:astroDusk#event triggered START

2018-03-06 18:48:00.016 [vent.ChannelTriggeredEvent] - astro:sun:minus10:eveningNight#event triggered START

2018-03-06 18:48:00.030 [vent.ChannelTriggeredEvent] - astro:sun:minus10:astroDusk#event triggered END

2018-03-06 18:48:00.038 [vent.ChannelTriggeredEvent] - astro:sun:minus10:night#event triggered START

2018-03-06 18:58:00.009 [vent.ChannelTriggeredEvent] - astro:sun:home:eveningNight#event triggered START

2018-03-06 18:58:00.018 [vent.ChannelTriggeredEvent] - astro:sun:home:astroDusk#event triggered END

2018-03-06 18:58:00.024 [vent.ChannelTriggeredEvent] - astro:sun:home:night#event triggered START

2018-03-06 19:08:00.020 [vent.ChannelTriggeredEvent] - astro:sun:plus10:night#event triggered START

2018-03-06 19:08:00.028 [vent.ChannelTriggeredEvent] - astro:sun:plus10:astroDusk#event triggered END

2018-03-06 19:08:00.032 [vent.ChannelTriggeredEvent] - astro:sun:plus10:eveningNight#event triggered START

2018-03-06 19:21:59.318 [ome.event.ItemCommandEvent] - Item 'Light_outdoor_5' received command OFF

2018-03-06 19:21:59.330 [vent.ItemStateChangedEvent] - Light_outdoor_5 changed from ON to OFF

2018-03-06 19:22:04.914 [ome.event.ItemCommandEvent] - Item 'Light_outdoor_8' received command OFF

2018-03-06 19:22:04.932 [vent.ItemStateChangedEvent] - Light_outdoor_8 changed from ON to OFF

2018-03-06 19:22:08.688 [ome.event.ItemCommandEvent] - Item 'Light_outdoor_7' received command OFF

2018-03-06 19:22:08.698 [vent.ItemStateChangedEvent] - Light_outdoor_7 changed from ON to OFF

2018-03-06 19:22:12.433 [ome.event.ItemCommandEvent] - Item 'Aircon_SF_Masterbed_power' received command ON

2018-03-06 19:22:12.503 [vent.ItemStateChangedEvent] - Aircon_SF_Masterbed_power changed from NULL to ON

2018-03-06 19:22:18.645 [ome.event.ItemCommandEvent] - Item 'BroadlinkRM3_SF_Master' received command Aircon_SF_Masterbed_power_ON

2018-03-06 19:22:23.588 [ome.event.ItemCommandEvent] - Item 'Aircon_SF_Masterbed_power' received command OFF

2018-03-06 19:22:23.600 [vent.ItemStateChangedEvent] - Aircon_SF_Masterbed_power changed from ON to OFF

2018-03-06 19:22:23.614 [ome.event.ItemCommandEvent] - Item 'BroadlinkRM3_SF_Master' received command Aircon_SF_Masterbed_power_OFF

2018-03-06 19:22:32.844 [ome.event.ItemCommandEvent] - Item 'Aircon_SF_Masterbed_fan' received command low

2018-03-06 19:22:32.877 [vent.ItemStateChangedEvent] - Aircon_SF_Masterbed_fan changed from medium to low

2018-03-06 19:22:32.921 [vent.ItemStateChangedEvent] - Aircon_SF_Masterbed_power changed from OFF to ON

2018-03-06 19:22:32.926 [ome.event.ItemCommandEvent] - Item 'BroadlinkRM3_SF_Master' received command 18low1

2018-03-06 19:22:37.035 [ome.event.ItemCommandEvent] - Item 'Aircon_SF_Masterbed_power' received command OFF

2018-03-06 19:22:37.047 [vent.ItemStateChangedEvent] - Aircon_SF_Masterbed_power changed from ON to OFF

2018-03-06 19:22:37.062 [ome.event.ItemCommandEvent] - Item 'BroadlinkRM3_SF_Master' received command Aircon_SF_Masterbed_power_OFF

2018-03-06 19:22:43.918 [ome.event.ItemCommandEvent] - Item 'Aircon_SF_Masterbed_swing' received command 1

2018-03-06 19:22:43.968 [vent.ItemStateChangedEvent] - Aircon_SF_Masterbed_power changed from OFF to ON

2018-03-06 19:22:43.974 [ome.event.ItemCommandEvent] - Item 'BroadlinkRM3_SF_Master' received command 18low1

2018-03-06 19:22:46.117 [ome.event.ItemCommandEvent] - Item 'Aircon_SF_Masterbed_power' received command OFF

2018-03-06 19:22:46.127 [vent.ItemStateChangedEvent] - Aircon_SF_Masterbed_power changed from ON to OFF

2018-03-06 19:22:46.136 [ome.event.ItemCommandEvent] - Item 'BroadlinkRM3_SF_Master' received command Aircon_SF_Masterbed_power_OFF

2018-03-06 19:38:31.368 [hingStatusInfoChangedEvent] - 'broadlink:rm3:34-ea-34-40-a4-18' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Could not control device at IP address 192.168.123.57

2018-03-06 19:39:01.375 [hingStatusInfoChangedEvent] - 'broadlink:rm3:34-ea-34-40-a4-18' changed from OFFLINE (COMMUNICATION_ERROR): Could not control device at IP address 192.168.123.57 to ONLINE

2018-03-06 21:19:00.029 [vent.ChannelTriggeredEvent] - astro:moon:home:rise#event triggered START

==> /var/log/openhab2/openhab.log <==

2018-03-07 10:36:59.206 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'xm.things' is either empty or cannot be parsed correctly!

==> /var/log/openhab2/events.log <==

2018-03-08 13:06:57.805 [ome.event.ItemCommandEvent] - Item 'Light_outdoor_7' received command ON

2018-03-08 13:06:57.828 [vent.ItemStateChangedEvent] - Light_outdoor_7 changed from OFF to ON

2018-03-08 13:07:05.802 [ome.event.ItemCommandEvent] - Item 'Light_outdoor_7' received command OFF

2018-03-08 13:07:05.833 [vent.ItemStateChangedEvent] - Light_outdoor_7 changed from ON to OFF

Nothing is changed between working and not working state. What is the possible cause of this? Thanks in advance

Hi, I am new here in the community. I got a Xiaomi gateway, have multiple door contacts, multiple motion sensors and smart switches. all the round Versions (non aqara). I also have a few humidity/temperature sensors working.

My issue is, I get everything working in Openhab but with some limitations.
First of all I am on gateway firmware 1.3.1_140.0143, the next offered firmware in the app is 1.3.1_141.0143. I am not able to upgrade it. I tried different wifi channels, different phones (iOS/Android), reset the gateway more than once, tried different wifis… nothing. It always start the download/update process and then fails in the end while the gateway turns off. Very frustrating. i dont know if I really need that update for the full functionality on openhab.

In the Xiaomi app I can control still everything but the point is to get it completly running in openhab. The Gateway cannot be controlled by openhab, no colors, sounds, nothing. But it shows online and all sub devices are connected and online. The problem is, my door switches and motion sensors are working fine, besides that the door contacts go in undef after like two minutes in status open (I fixed that quick and dirty with a rule), but dont show me the battery level values. That would be an important feature for me in my alarm system. Has that to do with the failing gateway updates? Or do I need to get any of the manual files set up (sitemaps, rules, items…) I wrote my own rules for interacting with my Osram switches etc. Sitemaps or Items i didn’t manually set up. I use the PaperUi Binding.

Has anybody any suggestions for me? I am not a developer though, just getting started with openhab. Thanks in advance!

I don’t know if it is related directly, but I also had a case at the start of my project where openHab could see my smart plug, and see its status, but couldn’t control it.
If I remember correctly, it was a bug, that I fixed by manually adding an updated version of the Xiaomi binding. Can’t remember where I got it, I’m sure someone else here can assist. In the meantime I’ll see if I can find it.

I noticed my Gateways are on version 1.4.1_153.

I will ask a stupid question, just to make sure. You did remember to activate the developer mode on your Xiaomi app for the Gateways? Then copied the code to the bridge-gateway on PaperUI?
If I remember correctly, you can’t control the gateways if you don’t activate developer mode (among other things).

The developer mode is activated. I also copied the code to the corresponding field im paperui. I tried to change that code multiple times. No success in controlling the gateway features.

Hey @WeirdlyChosen!
Did you notice, that you have two items for the same channel?
mihome_ctrl_neutral2_158d0001f4c141_ch1 is one item, Light_outdoor_8 is another.
They are both connected to the channel mihome:ctrl_neutral2:158d0001f4c141:ch1

Please enable the debug log and check if you are able to write commands to the switches and that your developer key works.
If the key is not correct, then in the debug log you get the answer from the gateway, telling you the key is wrong :slight_smile:

It seems like the devices are reporting correctly but OH is not able to write the command to them.
You are right, if you send the command to Light_outdoor_8, mihome_ctrl_neutral2_158d0001f4c141_ch1 should be changed too - Light_outdoor_8 changes just because of the command itself.

I don’t know if it is related directly, but I also had a case at the start of my project where openHab could see my smart plug, and see its status, but couldn’t control it.
If I remember correctly, it was a bug, that I fixed by manually adding an updated version of the Xiaomi binding. Can’t remember where I got it, I’m sure someone else here can assist. In the meantime I’ll see if I can find it.

I installed the latest binding available from paper UI on March 6, 2018, so I guess the bug is already gone when I install the binding, not sure about installing binding without paperUI, only tried to do that for not official binding, Broadlink binding.

I will ask a stupid question, just to make sure. You did remember to activate the developer mode on your Xiaomi app for the Gateways? Then copied the code to the bridge-gateway on PaperUI?
If I remember correctly, you can’t control the gateways if you don’t activate developer mode (among other things).

Yes, it is already activated, and I already able to turn it off and on, but only sometimes.

Did you notice, that you have two items for the same channel?
mihome_ctrl_neutral2_158d0001f4c141_ch1 is one item, Light_outdoor_8 is another.
They are both connected to the channel mihome:ctrl_neutral2:158d0001f4c141:ch1

Hello @dimalo, yes I noticed that I have two items. One from paperUI, and one from xiaomi.items for better management.
Can you please tell me what entries should I write to org.ops4j.pax.logging.cfg to get xiaomi binding logs?

I am a beginner here so probably asking a stupid question.

I got “Smart Home Gateway” (a round shaped thing with LEDs, speaker, and it provides zigbee gateway), however I cannot add it to OpenHAB as there is no way to specify the IP of the gateway. I was able to add “Smart Home Bridge” instead (typed in the IP and the key), got all my sensors.

However there is no “Smart Home Gateway” functionality on that bridge - no illumination, no speaker. If I add the gateway manually, it remains “offline” (understandable).

Is there any way to get illumination and speaker working from that Gateway device? Thanks

upd: although the gateway detects all the sensors, etc, most of them do not work - for example, “smart socket plug” does not respond to the “power” switch and all door/window sensors do not show battery level (but wireless switch does).

not sure you can enable debug logging there.
please dig a bit in the forum…
for example: https://community.openhab.org/t/logging-under-oh2-karaf

If you write you are able to write but only sometimes. perhaps the distance is too far, so that the connection is bad sometimes? or you have many devices? you can then just buy another gateway and distribute the devices on two gateways. the binding works great with multiple gateways…

hey @aik:
please make sure you have the latest firmware on the gateway via mihome app. Also make sure you have the gateway v3 - this one is reported to work the best.
the binding should give you the bridge and the gateway. OH internally, the bridge is for further devices connected to the gateway, the gateway thing itself is for controlling the gateway’s light and so on.

I understand if we can log from karaf, but somehow the combination of openhab:habopen when SSHing on port 8101 is rejected.
Also I do not know what is the bundle, is there any way to know what is the bundle of each addons?

hey @dimalo, it is v3 gateway, updated but the “smart home gateway” just does not take ip address in the config, only “smart home bridge” does but the bridge is way simpler that the gateway. Adding the gateway manually does not work - it remains offline.

My openhab2 is 2.2.0-1, does this have necessary xiaomi support?

upd: installed from testing - 2.3.0~20180310161859-1 - still no gateway support :-/

try openhab-cli console if you are on linux.

@aik
Then I’m guessing your network setup prevents the binding from being correctley configured. please check if you are able to receive multicast traffic.
for you it would also be interesting to enable enhanced logging for the binding trying to understand where the problem is.

@dimalo:
multicast is enabled everywhere I can see, the Mi gateway receives its IP over DHCP from the orangepi box which is running the opehnab2, the openhab2 server is in the same network as the xiaomi gateway.

I can enable logging but I wonder what I should be doing to get the setup working as expected so it would make sense to record the log to see what went wrong. Literally, I deleted all xiaomi devices, restarted the service, enable all DEBUG events, went to “inbox” and tried scanning Xiaomi binding - and it found nothing. The log is there: https://pastebin.com/YbshEnya
This does not give me a clue of what to expect really, what should have happened? Or I still have to add the bridge manually (as it is the only thing which takes an IP) and the gateway should pop up altogether with all the switches and sensors?

upd: in parallel I am also playing with domoticz, that thing does not autofind the gateway but I can add by IP+key (just like openhab does for “xiaomi bridge”) and then I can control all the sensors + sounds + lights, i.e. everything the gateway provides - these additional capabilities come as discovered switches. OpenHAB does something differently but what…

Try disabling firewall. Xiaomi MiHome Gateway not responding (Solved)

@kyomar tried that, no difference. Can you please give a hint how it is supposed to work?

Hi,

upon gearbest shopping i stumbled over the Xiaomi Thermostat Accuracy Temperature Humidity Monitor:

It seems to be basically the temperature sensor with a LCD display for displaying current temperature and humidity.

Does someone have some experience with it already? Is it supported by the binding?

Regards
Simon