Home Assistant custom integration for Yi cameras: yi-hack-MStar, yi-hack-Allwinner and yi-hack-Allwinner-v2

Overview

yi-hack Home Assistant integration

Overview

yi-hack Home Assistant is a custom integration for Yi cameras (or Sonoff camera) with one of the following custom firmwares:


This integration is available from the Lovelace frontend without the need to configure the devices in the file configuration.yaml The wizard will connect to your cam and will install the following entities:

  • ffmpeg cam with stream and snapshot capabilities
  • mqtt cam with the last frame saved during a motion detection event
  • mqtt binary sensor for status
  • mqtt binary sensor for motion detection
  • mqtt binary sensor for ai human detection (there are known issues when enabling ai human detection) (*)
  • mqtt binary sensor for sound detection (*)
  • mqtt binary sensor for baby crying detection (*)
  • media player entity useful to play Home Assistant standard tts service (*)
  • ptz service (*)
  • speak service (only available if you install the internal tts engine from here https://github.com/roleoroleo/yi-hack-utils)

(*) available only if your cam supports it.

Installation

(1) Copy the custom_components folder your configuration directory. It should look similar to this:

/
|-- custom_components/
|   |-- yi_hack/
|       |-- translations/
|       |-- __init__.py
|       |-- binary_sensor.py
|       |-- camera.py
|       |-- config.py
|       |-- config_flow.py
|       |-- const.py
|       |-- manifest.json
|       |-- media_player.py
|       |-- services.yaml
|       |-- strings.json

(2) Restart Home Assistant

(3) Configure device and entities:

  • Go to Settings -> Integrations
  • Click "Add Integration" in the lower-right corner
  • Select "Yi Cam with yi-hack" integration

  • Enter the settings to connect to the web interface of your cam: host, port, username, password and ffmpeg parameters

  • Confirm and wait for the wizard completion
  • Set the "Area" if you need it
  • Enjoy your cam

Add the stream to lovelace

If you want to add your live stream to lovelace, use this custom components: https://github.com/AlexxIT/WebRTC/

And add a simple configuration like this:

type: 'custom:webrtc-camera'
entity: camera.yi_hack_mstar_XXXXXXXXXXXX_cam
ui: true

Requirements

This component requires MQTT integration to be installed. Please be sure you added MQTT to you Home Assistant configuration.

Donation

If you like this project, you can buy me a beer :) paypal


DISCLAIMER

I AM NOT RESPONSIBLE FOR ANY USE OR DAMAGE THIS SOFTWARE MAY CAUSE. THIS IS INTENDED FOR EDUCATIONAL PURPOSES ONLY. USE AT YOUR OWN RISK.

Comments
  • Two cameras linked in the same integration

    Two cameras linked in the same integration

    Hello, I use the h30ga hack for my two Yi Outdoor 1080p IFUS cameras. I use two differents device name in camera settings (IP:8080)

    I add the first one in a new piece, I change the entity name, it's ok. I add the second in another piece, the two cam are on this same piece, and the two integrations are linked.

    There is no problem with my others cam Yi 1080p Home IFUS, there is one integration for each camera.

    opened by cbroissa-github 21
  • [Yi Dome Camera U BFUS (Full HD)] Sound/baby crying sensor always off; human detection the same

    [Yi Dome Camera U BFUS (Full HD)] Sound/baby crying sensor always off; human detection the same

    Hi, First of all thanks for your work! But...I've noticed that on my Yi Dome Camera U BFUS (Full HD) with 9.0.22.14_202011061019 despite setting high sensitivity, my sound sensor and baby crying sensor are always off. Even though I see notifications from app that it (the sound) was detected. I really don't understand why there are two sesors (one for sound and second for baby crying) in integration and only one setting for sound in application? The same goes for motion detection. When I disable human detection, motion sensor acts as expected. But when I enable it (it should react only for human detection right?) it always stays off even though I see a notification from app that a person has been detected.

    This is what I get from mqtt explorer:

    image

    opened by majkers 17
  • Motion detection on MQTTP but not appearing in the motion_sensor in HA

    Motion detection on MQTTP but not appearing in the motion_sensor in HA

    HI,

    I'm having aproblem, with 5 cameras and the motion_sensor. I can see the MQTTP packets on HO, but it don't refresh the sensors on HA.

    image

    I have tried to configure first the mqttp on the cameras and later add them in the integration but nothing, but i'm getting the connect status to work. image

    Even i've tried to use a diferent Topics Prefix for each camera.

    P.d works fine! but any other sensor than the offline don't work.

    This camera is

    Thanks Again!!

    opened by xinux87 15
  • Unknown error occurred

    Unknown error occurred

    Receiving the above error when setting up the yi-hack configuration via Integrations. MQTT is enabled and I can sub to (and see) my Yi topics via MQTT in HA Integrations. Authenticaion credentials are enabled in the yi-hack interface. RTSP stream can be viewed in VLC. Home assistant log below,

    Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request resp = await self._request_handler(request) File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle resp = await handler(request) File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 202, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 24, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 144, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 135, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 63, in wrapper result = await method(view, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 202, in async_configure result = await self._async_handle_step(flow, cur_step["step_id"], user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 260, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) File "/config/custom_components/yi_hack/config_flow.py", line 68, in async_step_user response = await self.hass.async_add_executor_job(get_status, user_input) File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/yi_hack/config.py", line 39, in get_status return response.json() File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 900, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/lib/python3.8/site-packages/simplejson/init.py", line 525, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/usr/local/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.errors.JSONDecodeError: Invalid control character '\n' at: line 8 column 18 (char 172)

    opened by AaronAutomation 12
  • Add Authorization header to media player requests

    Add Authorization header to media player requests

    When opening Media Player in HA we weren't passing Authorization data in requests for thumbnails and video itself, so requests couldn't be completed successfully.

    opened by karolVimn 11
  • YIapp

    YIapp "At home" and "Away" modes controlled by Home Assistant / YIHack

    Hi, There is a way, through integration, sensor, MQTT, to send the command "at home" and "not_home" from Home Assistant and have it read to the YI app. It would be handy for creating automations. I have noticed that the commands that are sent via integration / MQTT are executed, but are not synchronized by HA / YIapp. Example, if I activate the cam from YIapp, the switch on Home Assistant continues to be disabled Thanks

    opened by SmartM-ui 11
  • Partial functioning

    Partial functioning

    Hi, I have installed the latest version of the integration (HA docker on Synology).

    Screenshot 2021-04-25 at 10 35 54

    The snapshot is showing correctly. But when opening the stream, it does not load and generates the following error in the logs:

    Logger: aiohttp.server
    Source: custom_components/yi_hack/camera.py:200
    First occurred: 10:30:39 AM (2 occurrences)
    Last logged: 10:32:55 AM
    
    Error handling request
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
        resp = await self._request_handler(request)
      File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
        resp = await handler(request)
      File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
        return await handler(request)
      File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
        return await handler(request)
      File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
        return await handler(request)
      File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 74, in ban_middleware
        return await handler(request)
      File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 135, in auth_middleware
        return await handler(request)
      File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 131, in handle
        result = await result
      File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 498, in get
        return await self.handle(request, camera)
      File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 533, in handle
        return await camera.handle_async_mjpeg_stream(request)
      File "/config/custom_components/yi_hack/camera.py", line 200, in handle_async_mjpeg_stream
        await stream.close()
      File "/usr/local/lib/python3.8/site-packages/haffmpeg/core.py", line 158, in close
        await self._loop.run_in_executor(None, _close)
      File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/usr/local/lib/python3.8/site-packages/haffmpeg/core.py", line 153, in _close
        self._proc.stdin.write(b"q")
    BrokenPipeError: [Errno 32] Broken pipe
    

    I have auth setup on my camera

    Firmware Version | 0.2.5
    Base Version | 8.2.0.0A_201912270941
    Model Suffix | y20ga
    
    opened by jjansen85 11
  • HA core-2021.5.1 Compatibility

    HA core-2021.5.1 Compatibility

    Hello, is it compatible with core-2021.5.1 version of HA? I just set it in custom_components , I see in logs a message that tells it's not tested component.. But then I cant call it anywhere... checked in integrations and no Yi object at all..

    Any help?

    Thanks

    opened by satomma 9
  • Error - Config flow could not be loaded

    Error - Config flow could not be loaded

    Hi @roleoroleo

    (3) Configure device and entities:
    
    Go to Settings -> Integrations
    Click "Add Integration" in the lower-right corner
    Select "Yi Cam with yi-hack" integration
    

    I am trying to follow the instructions, so after the above steps, the following error appears.

    image

    I am running HA as the container on QNAP with a dedicated config folder.

    opened by alienatedsec 8
  • Guide on how to copy files

    Guide on how to copy files

    Hi to all of you.

    Would it be possible to have a link or someone can guide me on how to copy files?

    I've created folder "yi-hack" in the root folder of cameras FTP server. Copied nano file so I can use TTS but it doesn't work. Do i need to ssh or there is something else?

    Kind regards.

    opened by robix90 8
  • Error in Home Assitant log

    Error in Home Assitant log

    I see this error a lot of times:

    2021-11-18 22:36:13 ERROR (SyncWorker_3) [homeassistant.util.json] Could not parse JSON content: /config/custom_components/yi_hack/translations/es.json
    Traceback (most recent call last):
    File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read()) # type: ignore
    File "/usr/local/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 166: invalid continuation byte
    2021-11-18 22:36:13 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547109082784] Error handling message: 'utf-8' codec can't decode byte 0xf3 in position 166: invalid continuation byte
    2021-11-18 22:36:28 ERROR (SyncWorker_5) [homeassistant.util.json] Could not parse JSON content: /config/custom_components/yi_hack/translations/es.json
    Traceback (most recent call last):
    File "/usr/src/homeassistant/homeassistant/util/json.py", line 33, in load_json
    return json.loads(fdesc.read()) # type: ignore
    File "/usr/local/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 166: invalid continuation byte
    

    I suspect of bad encoding in the spanish translation file.

    opened by McGiverGim 7
  • Browsing yi-hack media source in HA throws error

    Browsing yi-hack media source in HA throws error

    Hi I am experiencing this error when I try to browse yi-hack media files in Home Assistant:

    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
        await func(hass, connection, msg)
      File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 170, in websocket_browse_media
        media = await async_browse_media(hass, msg.get("media_content_id", ""))
      File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 121, in async_browse_media
        item = await _get_media_item(hass, media_content_id, None).async_browse()
      File "/usr/src/homeassistant/homeassistant/components/media_source/models.py", line 79, in async_browse
        return await self.async_media_source().async_browse_media(self)
      File "/config/custom_components/yi_hack/media_source.py", line 71, in async_browse_media
        device_registry = await self.hass.helpers.device_registry.async_get()
    TypeError: async_get() missing 1 required positional argument: 'hass'
    
    opened by Failure404 3
  • Dome X loses Wifi

    Dome X loses Wifi

    Hi! I am on 0.4.2 version installed on my Dome X camera. Every few days I lose wifi connection and when I go to the camera I hear the message "waiting to connect". I use Yi app to generate the QR code and everything works OK again for a few days. Please advise. Best regards,

    José

    opened by jjvelar 0
  • Consider support xiaoyi Y4 with IFCN Y39U1E?

    Consider support xiaoyi Y4 with IFCN Y39U1E?

    Came across the post here and tried to use y29ga hack for xiaoyi Y4 IFCN.

    But obviously it failed. the hack stuck and I cannot restore the camera now.

    Did a backup like this. y4_IFCNY39U1E_backup.zip

    The homever.txt file is backed up when I did the hack. All other file is for the backup original.

    opened by shiningbridge 5
  • Privacy switch enabled when media player gets deactivated

    Privacy switch enabled when media player gets deactivated

    Hi!

    Moving forward on my automation, I noticed that when I deactivate the media player in HA, the privacy switch is automatically activated, with around a 20s delay:

    image

    Same behavior happens when I activate the media player, the privacy switch is set to off:

    image

    I've tested on both MStar and Allwinnerv2, same behavior.

    FYI, MQTT is disabled on every camera as I use Frigate for motion detection, but I guess it has not impact as these 2 controls use API.

    BTW, no matter if media player is on or off, I can play TTS using HA TTS service. Is there another purpose for this switch?

    Thanks!

    opened by aqwserf 3
  • feature: set various configurations

    feature: set various configurations

    as a user, i would like to configure cameras via HA, such as enabling or disabling motion detection so that i can enable motion detection when i am away using Automation.

    the integration does not offer much when it comes to configuring cameras. only privacy switch is implemented.

    https://github.com/roleoroleo/yi-hack_ha_integration/blob/454f3aa3d243453eec64f9a31c0f915642adfe64/custom_components/yi_hack/switch.py#L17-L20

    with this feature, one can implement "Home and Away" feature found in the yi mobile app.

    opened by trombik 11
  • Please create a release including the fix for baby crying

    Please create a release including the fix for baby crying

    When trying to create a new integration in Home Assistant using version 0.3.9 of yi-hack_ha_integration and a camera with 0.2.3 of yi-hack-Allwinnerv2, setup fails with the following error:

    Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/yi_hack/init.py", line 65, in async_setup_entry CONF_TOPIC_BABY_CRYING: mqtt[CONF_TOPIC_BABY_CRYING], KeyError: 'TOPIC_BABY_CRYING’

    I'd update manually but I don't know how to get the version from main into HACS. Please press the release button so magic can happen! :)

    opened by ak6i 3
Releases(0.4.2)
  • 0.4.2(Nov 9, 2022)

  • 0.4.1(Oct 7, 2022)

  • 0.4.0(Sep 11, 2022)

    Add pt-BR.json (thanks to @LeandroIssa) Reset motion_detection sensor when the cam disconnects Add preset support (thanks to @mcarbonne) Add pl.json (thanks to @LukaszP2) Fix google tts Add Authorization header to media player requests (thanks to @karolVimn) Update baby crying management to the last firmware

    Source code(tar.gz)
    Source code(zip)
  • 0.3.9(May 7, 2022)

    Fix Media Player unable to play sometimes (thanks to @vin-w) Fix uninitialized variables Add configuration_url attribute (thanks to @hcoohb) Init privacy swith as off Add integration to hacs repo Add state to camera entity Fix on/off typos Remove unused code Improve on/off state management Improve switch state after turn on/off

    Source code(tar.gz)
    Source code(zip)
  • 0.3.8(Mar 17, 2022)

  • 0.3.7(Mar 6, 2022)

  • 0.3.6(Nov 29, 2021)

  • 0.3.4(Nov 15, 2021)

    Fix "User input malformed" during setup (2021.11) Remove ai human detection Add spanish translation (thx @Mkampff) Fix switch/device relation Change entry_id from serial number to mac address Fix rtsp port for sonoff Fix UnboundLocalError in get_privacy Add support for width and height (2021.9)

    Source code(tar.gz)
    Source code(zip)
  • 0.3.1(Sep 2, 2021)

Owner
roleo
roleo
CO2Ampel - This RaspberryPi project uses weather data to estimate the share of renewable energy in the power grid

CO2Ampel This RaspberryPi project uses weather data to estimate the share of ren

Felix 4 Jan 19, 2022
uOTA - OTA updater for MicroPython

Update your device firmware written in MicroPython over the air. Suitable for private and/or larger projects with many files.

Martin Komon 25 Dec 19, 2022
PyTorch implementation of paper "MT-ORL: Multi-Task Occlusion Relationship Learning" (ICCV 2021)

MT-ORL: Multi-Task Occlusion Relationship Learning Official implementation of paper "MT-ORL: Multi-Task Occlusion Relationship Learning" (ICCV 2021) P

Panhe Feng 12 Oct 11, 2022
🔆 A Python module for controlling power and brightness of the official Raspberry Pi 7

rpi-backlight A Python module for controlling power and brightness of the official Raspberry Pi 7" touch display. Note: This GIF was created using the

Linus Groh 238 Jan 08, 2023
Cascade Drone Swarm Physical Demonstration Project

Cascade Drone Swarm Physical Demonstration Project Table of Contents About The Project Built With Getting Started Prerequisites Installation About The

3 Aug 24, 2022
Classes and functions for animated text and graphics on an LED display

LEDarcade A collection of classes and functions for animated text and graphics on an Adafruit LED Matrix.

datagod 31 Jan 04, 2023
This tool emulates an EMV-CAP device, to illustrate the article "Banque en ligne : à la decouverte d'EMV-CAP" published in MISC

About This tool emulates an EMV-CAP device, to illustrate the article "Banque en ligne : à la decouverte d'EMV-CAP" published in MISC, issue #56 and f

Philippe Teuwen 28 Nov 21, 2022
Detic ros - A simple ROS wrapper for Detic instance segmentation using pre-trained dataset

Detic ros - A simple ROS wrapper for Detic instance segmentation using pre-trained dataset

Hirokazu Ishida 12 Nov 19, 2022
Controlling fireworks with micropython

Controlling-fireworks-with-micropython How the code works line 1-4 from machine

Montso Mokake 1 Jan 08, 2022
Used python functional programming to make this Ai assistant

Python-based-AI-Assistant I have used python functional programming to make this Ai assistant. Inspiration of project : we have seen in our daily life

Durgesh Kumar 2 Dec 26, 2021
Pure micropython ESP32 SPI driver for sdcard and screen at the same SPI bus

micropython-esp32-spi-sdcard-and-screen-driver Proof of concept of Pure micropython espidf SPI driver for sdcard with screen at the same SPI bus (exam

Thomas Favennec 7 Mar 14, 2022
A Python program that makes it easy to manage modules on a CircuitPython device!

CircuitPython-Bundle-Manager-v2 A Python program that makes it easy to manage modules on a CircuitPython device! The CircuitPython Bundle Manager v2 i

Ckyiu 1 Dec 18, 2021
Jarvis: a personal assistant which can help you to manage your system

Jarvis Jarvis is personal AI based assistant which can help you to manage stuff in your computer. This is demo but I decided to make it more better so

2 Jun 02, 2022
This repo uses a stereo camera and gray-code-based structured light to realize dense 3D reconstruction.

Structured-light-stereo This repo uses a stereo camera and gray-code-based structured light to realize dense 3D reconstruction. . How to use: STEP 1:

FEI 20 Dec 31, 2022
Python para microcontroladores com MicroPyhton

MicroPython - PyBR2021 Python para microcontroladores com MicroPyhton Repositório de exemplos para tutorial "Python para microcontroladores com MicroP

gabriel aragão 1 Oct 18, 2021
Modeling and Simulation of Satellite Servicing Manipulators

Modeling and Simulation of Satellite Servicing Manipulators Final Project for the course ENPM662: Introduction to Robot Modeling (Fall 2021). This pro

Adarsh M 1 Jan 24, 2022
A Home Assistant sensor that tells you what holiday is next

Next Holiday Sensor This sensor tells you what holiday is coming up next. You can use it to set holiday light colors or other scenes. The state of the

Nick Touran 20 Dec 04, 2022
DOS-like OS for RP2040 basic microcontroller boards

Micropython DOS-like OS for RP2040 microcontroller boards. Check out the demo video at https://www.youtube.com/watch?v=Az_oiq8GE4Y To start the OS typ

RetiredWizard 58 Dec 27, 2022
An open source operating system designed primarily for the Raspberry Pi Pico, written entirely in MicroPython

PycOS An open source operating system designed primarily for the Raspberry Pi Pico, written entirely in MicroPython. "PycOS" is an combination of the

8 Oct 06, 2022
Интеграция Home Assistant с ЛК "Интер РАО"

ЕЛК ЖКХ «Интер РАО» для Home Assistant Предоставление информации о текущем состоянии ваших аккаунтов в ЕЛК ЖКХ. Введение @ TODO @ Установка Посредство

Alexander Ryazanov 27 Nov 05, 2022