Xiaomi Mijia Smart DC Inverter Fan 1X

{
    "life": 2535,
    "model": "dmaker.fan.p5c",
    "token": "<hidden>",
    "ipflag": 1,
    "fw_ver": "2.2.2",
    "mcu_fw_ver": "0006",
    "miio_ver": "0.0.9",
    "hw_ver": "RTL8720C",
    "mmfree": 72336,
    "mac": "<hidden>",
    "wifi_fw_ver": "WifiVer.N/A",
    "ap": {
        "ssid": "<hidden>",
        "bssid": "<hidden>",
        "rssi": -60,
        "primary": 1
    },
    "netif": {
        "localIp": "<hidden>",
        "mask": "255.255.255.0",
        "gw": "<hidden>"
    },
    "uid": 123456789
}

Sometimes:

Received response from 111.222.333.444: {"id":177,"error":{"code":-9999,"message":"user ack timeout"},"exe_time":4042}

How do we go about getting this to work? I tried using dmaker.fan.p5 but it doesn’t switch on/off. Let me know what to do. Thanks.

This device most likely supports the newer miot style of commands.
You can have the binding trying to create support for your device while it is in the ’ unsupported mode’ and switching the ’ create experimental support’ button (miot one)

see readme for more details. You prob need to remove the device first in order to have it redetected

Thanks @marcel_verpaalen .
Got the database.

{
  "deviceMapping": {
    "id": [
      "dmaker.fan.p5c"
    ],
    "propertyMethod": "get_properties",
    "maxProperties": 1,
    "channels": [
      {
        "property": "",
        "friendlyName": "Actions",
        "channel": "actions",
        "type": "String",
        "stateDescription": {
          "options": [
            {"value": "fan-toggle", "label": "Fan Toggle"},
            {"value": "fan-turn-left", "label": "Fan Turn Left"},
            {"value": "fan-turn-right", "label": "Fan Turn Right"},
            {"value": "dm-service-toggle-mode", "label": "Dm Service Toggle Mode"},
            {"value": "dm-service-loop-gear", "label": "Dm Service Loop Gear"}
          ]
        },
        "refresh": false,
        "actions": [
          {
            "command": "action",
            "parameterType": "EMPTY",
            "siid": 2,
            "aiid": 1,
            "condition": {"name": "matchValue", "parameters": [{"matchValue": "fan-toggle"}]}
          },
          {
            "command": "action",
            "parameterType": "EMPTY",
            "siid": 2,
            "aiid": 2,
            "condition": {"name": "matchValue", "parameters": [{"matchValue": "fan-turn-left"}]}
          },
          {
            "command": "action",
            "parameterType": "EMPTY",
            "siid": 2,
            "aiid": 3,
            "condition": {"name": "matchValue", "parameters": [{"matchValue": "fan-turn-right"}]}
          },
          {
            "command": "action",
            "parameterType": "EMPTY",
            "siid": 8,
            "aiid": 1,
            "condition": {"name": "matchValue", "parameters": [{"matchValue": "dm-service-toggle-mode"}]}
          },
          {
            "command": "action",
            "parameterType": "EMPTY",
            "siid": 8,
            "aiid": 2,
            "condition": {"name": "matchValue", "parameters": [{"matchValue": "dm-service-loop-gear"}]}
          }
        ]
      },
      {
        "property": "on",
        "siid": 2,
        "piid": 1,
        "friendlyName": "Fan - Switch Status",
        "channel": "on",
        "type": "Switch",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "ONOFFBOOL"}
        ]
      },
      {
        "property": "fan-level",
        "siid": 2,
        "piid": 2,
        "friendlyName": "Fan - Fan Level",
        "channel": "fan_level",
        "type": "Number",
        "stateDescription": {
          "options": [
            {"value": "1", "label": "Level1"},
            {"value": "2", "label": "Level2"},
            {"value": "3", "label": "Level3"},
            {"value": "4", "label": "Level4"}
          ]
        },
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "NUMBER"}
        ],
        "readmeComment": "Value mapping [\"1\"\u003d\"Level1\",\"2\"\u003d\"Level2\",\"3\"\u003d\"Level3\",\"4\"\u003d\"Level4\"]"
      },
      {
        "property": "mode",
        "siid": 2,
        "piid": 3,
        "friendlyName": "Fan - Mode",
        "channel": "mode",
        "type": "Number",
        "stateDescription": {
          "options": [
            {"value": "0", "label": "Straight Wind"},
            {"value": "1", "label": "Natural Wind"}
          ]
        },
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "NUMBER"}
        ],
        "readmeComment": "Value mapping [\"0\"\u003d\"Straight Wind\",\"1\"\u003d\"Natural Wind\"]"
      },
      {
        "property": "horizontal-swing",
        "siid": 2,
        "piid": 4,
        "friendlyName": "Fan - Horizontal Swing",
        "channel": "horizontal_swing",
        "type": "Switch",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "ONOFFBOOL"}
        ]
      },
      {
        "property": "horizontal-swing-included-angle",
        "siid": 2,
        "piid": 5,
        "friendlyName": "Fan - Horizontal Swing Included Angle",
        "channel": "horizontal_swing_included_angle",
        "type": "Number",
        "stateDescription": {
          "options": [
            {"value": "30", "label": "30"},
            {"value": "60", "label": "60"},
            {"value": "90", "label": "90"},
            {"value": "120", "label": "120"},
            {"value": "140", "label": "140"}
          ]
        },
        "refresh": true,
        "actions": [
          {
            "command": "set_properties",
            "parameterType": "STRING"
          }
        ],
        "readmeComment": "Value mapping [\"30\"\u003d\"30\",\"60\"\u003d\"60\",\"90\"\u003d\"90\",\"120\"\u003d\"120\",\"140\"\u003d\"140\"]"
      },
      {
        "property": "status",
        "siid": 2,
        "piid": 6,
        "friendlyName": "Fan - Status",
        "channel": "status",
        "type": "Number",
        "stateDescription": {
          "readOnly": true,
          "options": [
            {"value": "0", "label": "12"},
            {"value": "1", "label": "9"},
            {"value": "2", "label": "5"}
          ]
        },
        "refresh": true,
        "actions": [],
        "readmeComment": "Value mapping [\"0\"\u003d\"12\",\"1\"\u003d\"9\",\"2\"\u003d\"5\"]"
      },
      {
        "property": "on1",
        "siid": 4,
        "piid": 1,
        "friendlyName": "Indicator Light - Switch Status",
        "channel": "on1",
        "type": "Switch",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "ONOFFBOOL"}
        ]
      },
      {
        "property": "alarm",
        "siid": 5,
        "piid": 1,
        "friendlyName": "Alarm - Alarm",
        "channel": "alarm",
        "type": "Switch",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "ONOFFBOOL"}
        ]
      },
      {
        "property": "physical-controls-locked",
        "siid": 7,
        "piid": 1,
        "friendlyName": "Physical Control Locked - Physical Control Locked",
        "channel": "physical_controls_locked",
        "type": "Switch",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "ONOFFBOOL"}
        ]
      },
      {
        "property": "off-delay-time",
        "siid": 3,
        "piid": 1,
        "friendlyName": "Off Delay Time - Off Delay Time",
        "channel": "off_delay_time",
        "type": "Number:Time",
        "unit": "minutes",
        "stateDescription": {
          "minimum": 0,
          "maximum": 480,
          "step": 1,
          "pattern": "%.0f %unit%"
        },
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "STRING"}
        ]
      },
      {
        "property": "speed-level",
        "siid": 8,
        "piid": 1,
        "friendlyName": "Dm Service - Speed Level",
        "channel": "speed_level",
        "type": "Number",
        "stateDescription": {
          "minimum": 1,
          "maximum": 100,
          "step": 1,
          "pattern": "%.0f"
        },
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "NUMBER"}
        ]
      },
      {
        "property": "start-left",
        "siid": 8,
        "piid": 3,
        "friendlyName": "Dm Service - Start Left",
        "channel": "start_left",
        "type": "Switch",
        "refresh": false,
        "actions": [
          {"command": "set_properties", "parameterType": "ONOFFBOOL"}
        ]
      },
      {
        "property": "start-right",
        "siid": 8,
        "piid": 4,
        "friendlyName": "Dm Service - Start Right",
        "channel": "start_right",
        "type": "Switch",
        "refresh": false,
        "actions": [
          {"command": "set_properties", "parameterType": "ONOFFBOOL"}
        ]
      },
      {
        "property": "natural-list",
        "siid": 8,
        "piid": 5,
        "friendlyName": "Dm Service - Natural List",
        "channel": "natural_list",
        "type": "String",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "STRING"}
        ]
      },
      {
        "property": "natural-e",
        "siid": 8,
        "piid": 6,
        "friendlyName": "Dm Service - Natural E",
        "channel": "natural_e",
        "type": "String",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "STRING"}
        ]
      },
      {
        "property": "natural-f",
        "siid": 8,
        "piid": 7,
        "friendlyName": "Dm Service - Natural F",
        "channel": "natural_f",
        "type": "String",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "STRING"}
        ]
      },
      {
        "property": "natural-g",
        "siid": 8,
        "piid": 8,
        "friendlyName": "Dm Service - Natural G",
        "channel": "natural_g",
        "type": "String",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "STRING"}
        ]
      },
      {
        "property": "natural-h",
        "siid": 8,
        "piid": 9,
        "friendlyName": "Dm Service - Natural H",
        "channel": "natural_h",
        "type": "String",
        "refresh": true,
        "actions": [
          {"command": "set_properties", "parameterType": "STRING"}
        ]
      }
    ],
    "experimental": true
  }
}

Great. Do all channels work well and your device is usable now?
Then I’ll add it to the supported devices

Hi. Seems to work fine.

Thing:

Thing miio:basic:abcd123456 "Xiaomi Fan" [ host="192.168.x.y", token="xxx", deviceId="xxxxxxxxx", model="dmaker.fan.p5c", communication="direct", refreshInterval=1500 ]

Item:

Group G_fan "Mi Smart Fan 1X" <status>
Switch power "Power" (G_fan) {channel="miio:basic:abcd123456:on"}
Switch roll "Rotation" (G_fan) {channel="miio:basic:abcd123456:horizontal_swing"}
Number mode "Mode" (G_fan) {channel="miio:basic:abcd123456:mode"}
Number angle "Angle" (G_fan) {channel="miio:basic:abcd123456:horizontal_swing_included_angle"}
Number timer "Timer" (G_fan) {channel="miio:basic:abcd123456:off_delay_time"}
Switch beep "Beep Sound" (G_fan) {channel="miio:basic:abcd123456:alarm"}
Number light "Light" (G_fan) {channel="miio:basic:abcd123456:on1"}
Switch child_lock "Child Lock" (G_fan) {channel="miio:basic:abcd123456:physical_controls_locked"}
Number speed "Speed" (G_fan) {channel="miio:basic:abcd123456:speed_level"}

I don’t know whether it’s due to the fan being off the internet, but sometimes (most of the time actually) I am unable to control the fan, and following logs appear. The ability to control the fan returns on its own sometimes but there is no pattern to it.

2024-07-07 08:08:17.022 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Sending Ping to device 'xxxxxxxxx' (192.168.x.y)
2024-07-07 08:08:32.037 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Communication error for Mi device at 192.168.x.y: Receive timed out
2024-07-07 08:08:32.037 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping to device 'xxxxxxxxx' (192.168.x.y) failed
2024-07-07 08:08:32.037 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Received message is without id: {"error":"No Response"}
2024-07-07 08:08:32.037 [DEBUG] [internal.handler.MiIoAbstractHandler] - Received response for device abcd123456 type: GET_PROPERTIES, result: {}, fullresponse: {"error":"Received message is without id"}
2024-07-07 08:08:32.038 [DEBUG] [internal.handler.MiIoAbstractHandler] - Error received for command '{"id":3775,"method":"get_properties","params":[{"did":"fan-level","siid":2,"piid":2}]}': "Received message is without id".
2024-07-07 08:08:47.053 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Communication error for Mi device at 192.168.x.y: Receive timed out
2024-07-07 08:08:47.053 [DEBUG] [nal.transport.MiIoAsyncCommunication] - No response from device xxxxxxxxx at 192.168.x.y for command {"id":3776,"method":"get_properties","params":[{"did":"mode","siid":2,"piid":3}]}.

The ability to control does not come back even if I unplug the fan and plug it back in from the mains. All the while IP ping gets replies (unless I unplugged it).

2024-07-07 08:08:32.037 [DEBUG] [nal.transport.MiIoAsyncCommunication] - Ping to device 'xxxxxxxxx' (192.168.x.y) failed

The entry in your log has a failed ping. Though the binding normally does not use internet for the communication, some devices don’t behave well when not connected via the inernet.

When you can’t connect to it via openhab, can you connect at that time via the mihome app? And if yes, is the network the same as in openhab (ip address?)