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

Xiaomi camera (chuangmi.camera.ipc019): Add orientation controls and alarm #663

Merged
merged 5 commits into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions miio/chuangmi_camera.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
"""Xiaomi Chuangmi camera (chuangmi.camera.ipc009) support."""
"""Xiaomi Chuangmi camera (chuangmi.camera.ipc009, ipc019) support."""

import enum
import logging
from typing import Any, Dict

from .click_common import command, format_output
import click

from .click_common import EnumType, command, format_output
from .device import Device

_LOGGER = logging.getLogger(__name__)


class Direction(enum.Enum):
"""Rotation direction."""

Left = 1
Right = 2
Up = 3
Down = 4


class CameraStatus:
"""Container for status reports from the Xiaomi Chuangmi Camera."""

Expand Down Expand Up @@ -269,3 +281,16 @@ def night_mode_off(self):
def night_mode_on(self):
"""Night mode always on."""
return self.send("set_night_mode", [2])

@command(
click.argument("mode", type=EnumType(Direction, False)),
default_output=format_output("Rotating to direction '{direction.name}'"),
)
def rotate(self, direction: Direction):
"""Rotate camera to given direction (left, right, up, down)."""
return self.send("set_motor", {"operation": direction.value})

@command()
def alarm(self):
"""Sound a loud alarm for 10 seconds."""
return self.send("alarm_sound")
3 changes: 2 additions & 1 deletion miio/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
"zhimi-airpurifier-mc1": AirPurifier, # mc1
"zhimi-airpurifier-mb3": AirPurifierMiot, # mb3 (3/3H)
"zhimi-airpurifier-ma4": AirPurifierMiot, # ma4 (3)
"chuangmi.camera.ipc009": ChuangmiCamera,
"chuangmi-camera-ipc009": ChuangmiCamera,
"chuangmi-camera-ipc019": ChuangmiCamera,
"chuangmi-ir-v2": ChuangmiIr,
"chuangmi-remote-h102a03_": ChuangmiIr,
"zhimi-humidifier-v1": partial(AirHumidifier, model=MODEL_HUMIDIFIER_V1),
Expand Down