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
Nordpool_diff custom integration for Home Assistant

nordpool_diff custom integration for Home Assistant Requires https://github.com/custom-components/nordpool Applies non-causal FIR differentiator1 to N

Joonas Pulakka 45 Dec 23, 2022
Smart EQ connect - Custom Integration for Home Assistant

Smart EQ Connect platform as a Custom Component for Home Assistant.

Rene Nulsch 2 Jan 4, 2022
Universal Xiaomi MIoT integration for Home Assistant

Xiaomi MIoT Raw 简体中文 | English MIoT 协议是小米智能家居从 2018 年起推行的智能设备通信协议规范,此后凡是可接入米家的设备均通过此协议进行通信。此插件按照 MIoT 协议规范与设备通信,实现对设备的状态读取及控制。

null 1.9k Jan 2, 2023
Home Assistant integration for energy consumption data from UK SMETS (Smart) meters using the Hildebrand Glow API.

Hildebrand Glow (DCC) Integration Home Assistant integration for energy consumption data from UK SMETS (Smart) meters using the Hildebrand Glow API. T

Aniket 153 Dec 30, 2022
Electrolux Pure i9 robot vacuum integration for Home Assistant.

Home Assistant Pure i9 This repository integrates your Electrolux Pure i9 robot vacuum with the smart home platform Home Assistant. The integration co

Niklas Ekman 15 Dec 22, 2022
Water quality integration for Home Assistant with data provided by Budapest FVM

Water Quality FVM (Budapest, HU) custom integration for Home Assistant This custom component integrates water quality information provided by Budapest

Atticus Maximus 3 Dec 23, 2021
A Home Assistant integration for Solaredge inverters

A Home Assistant integration for Solaredge inverters. Supports multiple inverters chained through RS485.

Seth 50 Dec 23, 2022
OPNsense integration with Home Assistant

hass-opnsense Join OPNsense with home-assistant! hass-opnsense uses the built-in xmlrpc service of OPNsense for all interactions. This project is curr

Travis Glenn Hansen 54 Jan 3, 2023
Component for deep integration LedFx from Home Assistant.

LedFX for Home Assistant Component for deep integration LedFx from Home Assistant. Table of Contents FAQ Install Config Performance FAQ Q. What versio

Dmitry Mamontov 28 Dec 13, 2022
Aqara Camera G3 integration for Home Assistant

Aqara Camera G3 integration for Home Assistant ATTENTION: The component only works after enabled telnet. Only supportd stream. Not support still image

null 14 Dec 18, 2022
Sleep As Android integration for Home Assistant

Sleep As Android custom integration This integration will allow you to get events from your SleepAsAndroid application in a form of the sensor states

Igor 84 Dec 30, 2022
Skykettle ha - Redmond SkyKettle integration for Home Assistant

Redmond SkyKettle integration for Home Assistant This integration allows to cont

Alexey 'Cluster' Avdyukhin 48 Jan 6, 2023
Ha-rpi gpio - Home Assistant Raspberry Pi GPIO Integration

Home Assistant Raspberry Pi GPIO custom integration This is a spin-off from the

Shay Levy 98 Dec 24, 2022
Custom component for Home Assistant that integrates Candy/Haier Wi-Fi washing machines (also known as Simply-Fi).

Candy Home Assistant component Custom component for Home Assistant that integrates Candy/Haier Wi-Fi washing machines (also known as Simply-Fi). This

Olivér Falvai 61 Dec 29, 2022
SALUS THERMOSTAT Custom component for Home-Assistant

Home-Assistant Custom Components Custom Components for Home-Assistant (http://www.home-assistant.io) Salus Thermostat Climate Component My device is R

null 21 Dec 18, 2022
Windhager myComfort custom component for Home Assistant

Windhager myComfort custom component for Home Assistant

null 5 Apr 27, 2022
Home Assistant custom components MPK-Lodz

MPK Łódź sensor This sensor uses unofficial API provided by MPK Łódź. Configuration options Key Type Required Default Description name string False MP

Piotr Machowski 3 Nov 1, 2022
Custom component for MPC-HC for home-assistant

mpc_hc The current mpchc integration in homeassistant violates ADR0004, so it will be deleted from core. This is just the existing integration copied

null 3 Dec 15, 2022
A lightweight script for updating custom components for Home Assistant

Updater for Home Assistant This is a lightweight script for updating custom components for Home Assistant. If for some reason you do not want to use H

Alex X 12 Sep 21, 2022