Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported device found - chuangmi.plug.hmi208 #616

Closed
MiSSHeaDShoT opened this issue Jan 20, 2020 · 13 comments · Fixed by #693
Closed

Unsupported device found - chuangmi.plug.hmi208 #616

MiSSHeaDShoT opened this issue Jan 20, 2020 · 13 comments · Fixed by #693

Comments

@MiSSHeaDShoT
Copy link

MiSSHeaDShoT commented Jan 20, 2020

Hello,
This is a Xiaomi Mijia Smart Wi-fi plug with Bluetooth and can act as Bluetooth Gateway. I just saw the code and seems there is nothing like it.
https://www.gearbest.com/access-control/pp_009225999378.html

Any chances to be integrated ?

@rytilahti
Copy link
Owner

You could try to adjust https://github.com/rytilahti/python-miio/blob/master/miio/chuangmi_plug.py by adding a new entry after the hmi206, simply to see if it works directly.

@MiSSHeaDShoT
Copy link
Author

I think it won't work as the Bluetooth gateway functionality is not in the other models. I could not find it implemented at all for Home Assistant ( for Xiaomi products). It was said somewhere that Xiaomi have not exposed and documented it in their SDK. As they released this plug in the end of 2019 I hope they will open our eyes for third party software.

@rytilahti
Copy link
Owner

Yes, the bluetooth functionality won't be there, but that would offer at least allow partial support.

@kghost
Copy link

kghost commented May 5, 2020

Verified, it works with modification, partially

% miiocli plugv3 --ip XXXX --token XXXX info
Model: chuangmi.plug.hmi208
Hardware version: esp32
Firmware version: 2.0.5_0024
Network: {'localIp': 'XXXX', 'mask': '255.255.255.0', 'gw': 'XXXX'}
AP: {'ssid': 'XXXX', 'bssid': 'XXXX', 'rssi': -36, 'primary': 11}
% miiocli plugv3 --ip XXXX --token XXXX off 
Powering off
['ok']
% miiocli plugv3 --ip XXXX --token XXXX on 
Powering on
['ok']
% miiocli plugv3 --ip XXXX --token XXXX usb_off
Powering USB off
['ok']
% miiocli plugv3 --ip XXXX --token XXXX usb_on 
Powering USB on
['ok']
% miiocli plugv3 --ip XXXX --token XXXX status
Error: {'code': -9999, 'message': 'user ack timeout'}

@rytilahti
Copy link
Owner

@kghost could you try out the commands I mentioned in the issue I just linked here? The 'user ack timeout' error happens sometimes when requesting an unknown property / making a call that is not supported, which is unfortunately not that informative..

@kghost
Copy link

kghost commented May 7, 2020

% miiocli device --ip XXXX --token XXXX raw_command get_prop '["power", "usb_on", "temperature"]'   
Running command raw_command
['on', True, 43]

@seoulop
Copy link

seoulop commented May 7, 2020

bash-5.0# miiocli device --ip xxx --token xxx info
Model: chuangmi.plug.hmi208
Hardware version: esp32
Firmware version: 2.0.5_0024
Network: {'localIp': 'xxx', 'mask': '255.255.255.0', 'gw': 'xxx'}
AP: {'ssid': 'xx', 'bssid': 'xx', 'rssi': -55, 'primary': 11}

bash-5.0# miiocli device --ip xxx --token xxx raw_command get_prop '["power", "temperature"]'
Running command raw_command
['on', 50]

bash-5.0# miiocli device --ip xxx --token xxx raw_command get_prop '["power", "usb_on", "temperature"]'
Running command raw_command
['on', True, 50]

bash-5.0# miiocli device --ip xxx --token xxx raw_command get_prop '["on", "usb_on", "temperature"]'
Running command raw_command
[True, 50]

bash-5.0# miiocli device --ip xxx --token xxx raw_command get_prop '["all"]'
Running command raw_command
[]

@AlexQuaken
Copy link

MODEL_CHUANGMI_PLUG_V3 = "chuangmi.plug.v3"
MODEL_CHUANGMI_PLUG_V1 = "chuangmi.plug.v1"
MODEL_CHUANGMI_PLUG_M1 = "chuangmi.plug.m1"
MODEL_CHUANGMI_PLUG_M3 = "chuangmi.plug.m3"
MODEL_CHUANGMI_PLUG_V2 = "chuangmi.plug.v2"
MODEL_CHUANGMI_PLUG_HMI205 = "chuangmi.plug.hmi205"
MODEL_CHUANGMI_PLUG_HMI206 = "chuangmi.plug.hmi206"
MODEL_CHUANGMI_PLUG_HMI208 = "chuangmi.plug.hmi208"

AVAILABLE_PROPERTIES = {
MODEL_CHUANGMI_PLUG_V1: ["on", "usb_on", "temperature"],
MODEL_CHUANGMI_PLUG_V3: ["on", "usb_on", "temperature", "wifi_led"],
MODEL_CHUANGMI_PLUG_M1: ["power", "temperature"],
MODEL_CHUANGMI_PLUG_M3: ["power", "temperature"],
MODEL_CHUANGMI_PLUG_V2: ["power", "temperature"],
MODEL_CHUANGMI_PLUG_HMI205: ["power", "temperature"],
MODEL_CHUANGMI_PLUG_HMI206: ["power", "temperature"],
MODEL_CHUANGMI_PLUG_HMI208: ["power", "temperature"],
}

Make changes as that, then copy to hassio by run command "docker cp /usr/share/hassio/homeassistant/chuangmi_plug.py homeassistant:/usr/local/lib/python3.7/site-packages/miio/chuangmi_plug.py" after that all my smart sockets makes inactive

lots of errors on all my smartsockets ip adresses
Unable to discover a device at address 192.168.0.79
19:18:33 – /usr/local/lib/python3.7/site-packages/miio/miioprotocol.py (ERROR) - первое сообщение получено 19:13:23 и повторялось 17 раз

somethig was wrong, after restore file from backup, error still not fix, mb i need do chmod + ?

@drudgebg
Copy link

drudgebg commented May 7, 2020

MODEL_CHUANGMI_PLUG_V3 = "chuangmi.plug.v3"
MODEL_CHUANGMI_PLUG_V1 = "chuangmi.plug.v1"
MODEL_CHUANGMI_PLUG_M1 = "chuangmi.plug.m1"
MODEL_CHUANGMI_PLUG_M3 = "chuangmi.plug.m3"
MODEL_CHUANGMI_PLUG_V2 = "chuangmi.plug.v2"
MODEL_CHUANGMI_PLUG_HMI205 = "chuangmi.plug.hmi205"
MODEL_CHUANGMI_PLUG_HMI206 = "chuangmi.plug.hmi206"
MODEL_CHUANGMI_PLUG_HMI208 = "chuangmi.plug.hmi208"

AVAILABLE_PROPERTIES = {
    MODEL_CHUANGMI_PLUG_V1: ["on", "usb_on", "temperature"],
    MODEL_CHUANGMI_PLUG_V3: ["on", "usb_on", "temperature", "wifi_led"],
    MODEL_CHUANGMI_PLUG_M1: ["power", "temperature"],
    MODEL_CHUANGMI_PLUG_M3: ["power", "temperature"],
    MODEL_CHUANGMI_PLUG_V2: ["power", "temperature"],
    MODEL_CHUANGMI_PLUG_HMI205: ["power", "temperature"],
    MODEL_CHUANGMI_PLUG_HMI206: ["power", "temperature"],
    MODEL_CHUANGMI_PLUG_HMI208: ["power", "usb_on", "temperature"],
}


class ChuangmiPlugStatus:
    """Container for status reports from the plug."""

    def __init__(self, data: Dict[str, Any]) -> None:
        """
        Response of a Chuangmi Plug V1 (chuangmi.plug.v1)
        { 'power': True, 'usb_on': True, 'temperature': 32 }

        Response of a Chuangmi Plug V3 (chuangmi.plug.v3):
        { 'on': True, 'usb_on': True, 'temperature': 32, 'wifi_led': True }

        Response of a Chuangmi Plug HMI208 (chuangmi.plug.hmi208):
        { 'power': True, 'usb_on': True, 'temperature': 32 }
        """
        self.data = data

After this it works.

miiocli chuangmiplug --ip xxxx --token xxxx status
Power: False
USB Power: None
Temperature: 27 °C
Load power: None
WiFi LED: None

miiocli chuangmiplug --ip xxxx --token xxxx on
Powering on
['ok']

miiocli chuangmiplug --ip xxxx --token xxxx off
Powering off
['ok']

miiocli chuangmiplug --ip xxxx --token xxxx usb_on
Powering USB on
['ok']

miiocli chuangmiplug --ip xxxx --token xxxx usb_off
Powering USB off
['ok']

Work with Home Assistant after edit
lib64/python3.7/site-packages/homeassistant/components/xiaomi_miio/switch.py:

        vol.Required(CONF_HOST): cv.string,
        vol.Required(CONF_TOKEN): vol.All(cv.string, vol.Length(min=32, max=32)),
        vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
        vol.Optional(CONF_MODEL): vol.In(
            [
                "chuangmi.plug.v1",
                "qmi.powerstrip.v1",
                "zimi.powerstrip.v2",
                "chuangmi.plug.m1",
                "chuangmi.plug.m3",
                "chuangmi.plug.v2",
                "chuangmi.plug.v3",
                "chuangmi.plug.hmi205",
                "chuangmi.plug.hmi206",
		"chuangmi.plug.hmi208",
                "lumi.acpartner.v3",
            ]


.......................

    if model in ["chuangmi.plug.v1", "chuangmi.plug.v3", "chuangmi.plug.hmi208"]:
        plug = ChuangmiPlug(host, token, model=model)

        # The device has two switchable channels (mains and a USB port).
        # A switch device per channel will be created.
        for channel_usb in [True, False]:
            device = ChuangMiPlugSwitch(name, plug, model, unique_id, channel_usb)
            devices.append(device)
            hass.data[DATA_KEY][host] = device

    elif model in ["qmi.powerstrip.v1", "zimi.powerstrip.v2"]:
        plug = PowerStrip(host, token, model=model)
        device = XiaomiPowerStripSwitch(name, plug, model, unique_id)
        devices.append(device)
        hass.data[DATA_KEY][host] = device
    elif model in [
        "chuangmi.plug.m1",
        "chuangmi.plug.m3",
        "chuangmi.plug.v2",
        "chuangmi.plug.hmi205",
        "chuangmi.plug.hmi206",
        "chuangmi.plug.hmi208",
    ]:

@rytilahti
Copy link
Owner

Could you confirm that the linked PR works and can be merged?

@biscuitee
Copy link

Could you confirm that the linked PR works and can be merged?

Hi, can I check if this will be merged into official release in HA miio component?

@rytilahti
Copy link
Owner

The homeassistant integration needs to be modified to accept this new device type. I think in the future we should add a list of known devices to python-miio that will remove the need to keep up two separate mappings of supported devices...

@biscuitee
Copy link

Hi, appreciate if expert here could share how could I add the chuangmi.plug.hmi208 support into my home assistant. I am running the Hassio homeassistant in Pi4.

I couldnt find the python package lib64/python3.7/site-packages/homeassistant/components/xiaomi_miio/switch.py: when I do a terminal in Home Assistant.

Any help is greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants