[SOLVED] Xiaomi O'WS Temperature Electric Towel Rack MJ120 can't control it with OH

Hi everyone
I try to control O’WS Temperature Electric Towel Rack MJ120 aka ows.towel_w.mj1x0 via OH3, but with no luck :pensive:
So, I know that Binding doesn’t support this device and I started to write my own json to miio folder (it worked for me with Mijia C1-80)
Found docs https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:towel-rack:0000A09A:ows-mj1x0:1
Converted part of it into json:

{
  "deviceMapping": {
    "id": [
      "ows.towel_w.mj1x0"
    ],
    "propertyMethod": "get_properties",
    "maxProperties": 2,
    "channels": [
      {
        "property": "manufacturer",
        "siid": 1,
        "piid": 1,
        "friendlyName": "Device Information-Device Manufacturer",
        "channel": "Manufacturer",
        "channelType": "miot_string",
        "type": "String",
        "refresh": true,
        "actions": []
      },
      {
        "property": "model",
        "siid": 1,
        "piid": 2,
        "friendlyName": "Device Information-Device Model",
        "channel": "Model",
        "channelType": "miot_string",
        "type": "String",
        "refresh": true,
        "actions": []
      },
      {
        "property": "serial-number",
        "siid": 1,
        "piid": 3,
        "friendlyName": "Device Information-Device Serial Number",
        "channel": "SerialNumber",
        "channelType": "miot_string",
        "type": "String",
        "refresh": true,
        "actions": []
      },
      {
        "property": "firmware-revision",
        "siid": 1,
        "piid": 4,
        "friendlyName": "Device Information-Current Firmware Version",
        "channel": "FirmwareRevision",
        "channelType": "miot_string",
        "type": "String",
        "refresh": true,
        "actions": []
      },
      {
        "property": "on",
        "siid": 2,
        "piid": 1,
        "friendlyName": "Towel Rack",
        "channel": "On",
        "channelType": "miot_bool",
        "type": "Switch",
        "refresh": true,
        "actions": [
          {
            "command": "set_power",
            "parameterType": "ONOFFBOOL"
          }
        ]
      }
    ]
  }
}

But still it doesn’t work for me
Device is online, token is okay
PS: I found this topic, but I don’t know how to use it within OH:

Please help me out

So I’ve created ‘Execute Command’ item in OH3 and send from console commands there.
openhab> openhab:send myItem get_props and set_power[0] work well
but openhab> openhab:send myItem set_power[1] doesn’t :pensive:
I can here only signal, but Towel rack is still off
Any ideas please?

@marcel_verpaalen please, look at this, when have time
Probably you can help somehow please
Experimental channel doesn’t help here

Okay, I managed to sniff this

<-  192.168.1.160 data= N/A
<-  192.168.1.160 data= N/A
->  192.168.1.186 data= N/A
<-  192.168.1.160 data= N/A
->  192.168.1.186 data= {"id":3350,"method":"get_props","params":[]}
<-  192.168.1.160 data= {"id":3350,"result":[1,0,90,40,1,16777215,56,52,100,0],"exe_time":254}
->  192.168.1.186 data= {"id":3351,"method":"get_props","params":[]}
<-  192.168.1.160 data= {"id":3351,"result":[1,0,90,40,1,16777215,57,52,100,0],"exe_time":214}
->  192.168.1.186 data= N/A
<-  192.168.1.160 data= N/A
->  192.168.1.186 data= {"id":3353,"method":"set_power","params":[0]}
<-  192.168.1.160 data= {"id":3353,"result":[0],"exe_time":244}
->  192.168.1.186 data= {"id":3354,"method":"set_power","params":[1]}
<-  192.168.1.160 data= {"id":3354,"result":[1],"exe_time":84}

Strange that miiocli device --ip 192.168.1.160 --token token raw_command set_power 1 doesn’t work for me

@marcel_verpaalen please, give a piece of advice

Would try to get the properties one at the time.

Try these in openhab via the command channel

power_set 
mode_set 
tempdry_set 
tempheat_set  
temprog_set 
drytime_set
percent_get 
tempind_get
tempsurf_get

If they give proper respone, you can try to make a json file for it so it properly shows in OH
Looks like you already found out the commands for most of the settings.
Did you try to execute them via the command channel as well?

If not working, try to enable cloud in the thing properties as communication to see if that is the thing that is the issue.

Thanks for the reply Marcel!
I have a progress here!
I had to send
miiocli device --ip IP --token TOKEN raw_command set_power [1]
And it works
Space between command and parameter makes sense
But when I use item for Execute Command(actions#commands) channel in OpenHab this command still doesn’t work :face_with_monocle:
Tried different ways to send parameter
What else should I try?

openhab> openhab:send 11xiaomi set_power [1]
Command has been sent successfully.
openhab> openhab:send 11xiaomi set_power1
Command has been sent successfully.
openhab> openhab:send 11xiaomi set_power{1}
Command has been sent successfully.
openhab> openhab:send 11xiaomi set_power {1}
Command has been sent successfully.
openhab> openhab:send 11xiaomi set_power 1
Command has been sent successfully.

I would expect the very first line is the right one.
You better switch on the device logging to see the response of the device.

log:set debug org.openhab.binding.miio

Okay, I found the correct format
thanks Marcel for your time :slightly_smiling_face:

openhab> openhab:send ITEM 'set_power[1]'