Xiaomi Robot Vacuum Binding

now the first command also does not work anymore

very strange …

16:11:14.486 [INFO ] [marthome.event.ItemStateChangedEvent] - XAIR_commandchannel changed from get_prop[“power”,“mode”,“humidity”,“aqi”,“bright”] to null16:11:21.981 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Locating action for channel actions#commands:get_prop[“power”,“mode”,“humidity”,“aqi”,“bright”]
16:11:21.990 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Channel Id actions#commands not in mapping. Available:
16:11:22.001 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: mode : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@14460c
16:11:22.006 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: brightness : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@128f475
16:11:22.011 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: buzzer : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@1a288aa
16:11:22.013 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Received response for 035CAFE2 type: GET_PROPERTY, result: [null,null,null,null,null], fullresponse: {"result":[null,null,null,null,null],"id":9}
16:11:22.016 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: led : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@8f37d1
16:11:22.027 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: power : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@6b266a
16:11:22.055 [INFO ] [marthome.event.ItemStateChangedEvent] - XAIR_commandchannel changed from null to {"result":[null,null,null,null,null],"id":9}
16:11:22.060 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'XAIR_commandchannel' received command get_prop[“power”,“mode”,“humidity”,“aqi”,“bright”]
16:11:22.086 [INFO ] [marthome.event.ItemStateChangedEvent] - XAIR_commandchannel changed from {"result":[null,null,null,null,null],"id":9} to get_prop[“power”,“mode”,“humidity”,“aqi”,“bright”]

strange indeed.
it looks like the quotes are different in the 2 times. The time without responses has 'opening & closing quotes’
the time where proper response is there it seems ‘straight’ quotes

good observation… straight quotes work …
still log shows no trace of 30s cyclic calls

16:32:08.249 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Command added to Queue {"id":12,"method":"get_prop","params":["led","act_det","buzzer","f1_hour","filter1_life"]} -> 192.168.1.73 (Device: 035CAFE2 token: 92CB1EE585A1B10982EA2A71DC23F26D Queue: 1)
16:32:08.303 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Locating action for channel actions#commands:get_prop["led","act_det","buzzer","f1_hour","filter1_life"]
16:32:08.310 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Channel Id actions#commands not in mapping. Available:
16:32:08.309 [DEBUG] [ing.miio.handler.MiIoAbstractHandler] - Received response for 035CAFE2 type: GET_PROPERTY, result: ["off",null,"off",3500,98], fullresponse: {"result":["off",null,"off",3500,98],"id":12}
16:32:08.327 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: mode : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@14460c
16:32:08.339 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Error while handing message {"result":["off",null,"off",3500,98],"id":12}
java.lang.UnsupportedOperationException: JsonNull
	at com.google.gson.JsonElement.getAsString(JsonElement.java:191) [23:com.google.gson:2.3.1]
	at org.openhab.binding.miio.handler.MiIoBasicHandler.updateProperties(MiIoBasicHandler.java:331) [237:org.openhab.binding.miio:2.2.0.201709170737]
	at org.openhab.binding.miio.handler.MiIoBasicHandler.onMessageReceived(MiIoBasicHandler.java:349) [237:org.openhab.binding.miio:2.2.0.201709170737]
	at org.openhab.binding.miio.internal.transport.MiIoAsyncCommunication$MessageSenderThread.run(MiIoAsyncCommunication.java:209) [237:org.openhab.binding.miio:2.2.0.201709170737]
16:32:08.349 [INFO ] [marthome.event.ItemStateChangedEvent] - XAIR_commandchannel changed from get_prop["led","act_det","buzzer","f1_hour","filter1_life"] to {"result":["off",null,"off",3500,98],"id":12}
16:32:08.352 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: brightness : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@128f475
16:32:08.371 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: buzzer : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@1a288aa
16:32:08.381 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: led : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@8f37d1
16:32:08.391 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - entries: power : org.openhab.binding.miio.internal.basic.MiIoDeviceAction@6b266a
16:32:08.407 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'XAIR_commandchannel' received command get_prop["led","act_det","buzzer","f1_hour","filter1_life"]
16:32:08.437 [INFO ] [marthome.event.ItemStateChangedEvent] - XAIR_commandchannel changed from {"result":["off",null,"off",3500,98],"id":12} to get_prop["led","act_det","buzzer","f1_hour","filter1_life"]

will try again when the update is here with better null handling

I pushed an update that removes the channels that seem unsupported.
Likewise I change the code a bit to avoid the polling job to be killed.
3rd update I made was improve the json null handling

should be available in the market place in a minute or 20.

does that exception tell you something?

still no periodic updates in debug log

17:21:27.212 [DEBUG] [inding.miio.handler.MiIoBasicHandler] - Current thing channels added: 8
17:21:27.289 [INFO ] [smarthome.event.ThingUpdatedEvent   ] - Thing 'miio:basic:035CAFE2' has been updated.
Exception in thread "SIGWINCH handler" java.lang.UnsupportedOperationException
	at org.jline.terminal.impl.NativeSignalHandler.handle(NativeSignalHandler.java:24)
	at org.apache.karaf.shell.impl.console.JLineTerminal.handle(JLineTerminal.java:280)
	at org.jline.terminal.impl.AbstractTerminal.raise(AbstractTerminal.java:65)
	at org.jline.terminal.impl.PosixSysTerminal.lambda$handle$1(PosixSysTerminal.java:65)
	at org.jline.utils.Signals.lambda$register$1(Signals.java:51)
	at com.sun.proxy.$Proxy57.handle(Unknown Source)
	at sun.misc.Signal$1.run(Signal.java:212)
	at java.lang.Thread.run(Thread.java:745)

No, it doesn’t tell me anything. Havn’t seen anything like it.
Is that coming from the latest build???

I reinstalled … and only 8 channels were created to I assumed its the new build

however bundle:list looks like its not
238 │ Active │ 80 │ 2.2.0.201709171502 │ Xiaomi Mi IO Binding

well maybe it is… when its an UTC timestamp

so … then yes… the exception happened after latest build and readding the thing

however not reproducable when again readding it now

I think value should calculated base on power on time x Fan speed,
similar to Filter Remaining days or Filter Remaining percent, in fact,
xaiomi didn’t physically detect filter status, it’s all depends on software calc

Hi,

thanks for providing the new version! I tested the support for iOS encrypted tokens successfully. Works as expected!

The only thing I noticed: The discovery finds my robot as “miio:generic:03D9BF2A”. I can’t use the discovered thing, but have to manually configure the thing as "miio:vacuum:03D9BF2A“, to make it work. This was already the case in the last version of the plugin.

Do you think, Token discovery will work again one day, so that the robot can be put into operation without ever connecting it to the xiaomi cloud?

Thanks again for the effort! Works great!

Best regards
Stefan

Hello @sradi,
Indeed your vacuum is discovered as generic thing. When you enter your token, it will change to the vacuum. This is because before the token is there the device can’t be queried for its type.
When the token is provided, I change the thing to the correct type.

The token retrieval should still work if you don’t want to connect to the cloud. Just reset your vacuum. Connect to its wifi hotspot with oh. Than run discovery. It will find the token.
Than issue the wifi network commands to have the vacuum connecting to your normal wifi network again.

Hello @marcel_verpaalen,

Thanks for the clarification!

I have OH running on a raspberrypi 2, connected to LAN via ethernet cable. Do I need to plug in a Wifi dongle and connect the rasppi to the robot’s hotspot? I tried that with the last version of your plugin, but the discovery didn’t find any device.
Do you have an idea, what I might have done wrong?

Thanks!!!
Stefan

Hello @marcel_verpaalen!

Thank you so much for your plugin! Thanks to the recent update regarding the encrypted iOS token I could finally get my robot vacuum online. Yet strange is that I discovered 2 things after installing the plugin.
1 Generic Xiaomi Device
1 robovacuum

After I entered the token in the respective thing, both became online in PaperUI but none of the things reacts to any of the commands. Any advice?

Yes, this is because there are 2 different methods currently to discover devices. The one method is aware of the type (in your case vacuum), but not all the miio devices support it.
The 2nd way all devices support, but the type only is known after the token is provided and the type can be requested with the info command (generic)

You need to enable one of them, not both. The end result is the same. I suggest to take the vacuum one.

I did not yet manage to avoid 2 entries. The oh framework is not working as I expect from the documentation, or it is a bug. Anyway, in the longer future I’m sure it can be avoided, for now, just ignore the 2nd discovery result.

Thanks for your reply! However, even if I even ignore one of the things the remaining vacuum doesn’t respond to any of the commands. Suggestions?

In the rest api I see that the items take the action commands properly, only the vacuum does not respond.

@NoOneAtAll What is the exact status after waiting a minute? Does it still say online or is it than offline-configuration error.
In the latter case, still something is wrong with the token.

You best log on to OH, set the debug level for the binding to debug, and than you can see if the device is responding yes or no. Please don’t have your phone or other app access the vacuum at the same time, as that may prevent OH to connect.
It may take a minute or 2 (2 -3 refreshes) before the vacuum starts responding. This is some sort of protection to duplicate message id’s

If you don’t see anything obvious, pls send your log in PM and i can see if anything obvious is there.
If

Sorry, but I am only configuring OH through PaperUI, Rest API or HabMin. Can‘t find an option to set the binding level to debug. On the other side, I can confirm, that the robot stays online all the time.

To see the log (needed to understand what is going on) use these commands in the OH console

log:set debug org.openhab.binding.miio
log:display org.openhab.binding.miio