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
Raspberry Pi & Accelerometer with Losant's EEA

Raspberry Pi & Accelerometer with Losant's EEA This is a repository that contains companion code to this EEA How To guide. Each folder is named accord

Losant 1 Oct 29, 2021
Adafruit IO connected smart thermostat based on CircuitPython.

Adafruit IO Thermostat Adafruit IO connected smart thermostat based on CircuitPython. Background and Motivation I have a 24 V Heat-only system with a

Shubham Chaudhary 1 Jan 18, 2022
Sticklog2heatmap - Draw a heatmap of RC sticks from OpenTX logs or USB HID device

sticklog2heatmap Draw a heatmap of RC sticks from OpenTX logs or USB HID device

2 Feb 02, 2022
Plug and Play on Internet of Things with LoRa wireless modulation.

IoT-PnP Plug and Play on Internet of Things with LoRa wireless modulation. Device Side In the '505_PnP' folder has a modified ardunino template code s

Lambert Yang 1 May 19, 2022
Example code and projects for FeatherS2 and FeatherS2 Neo

FeatherS2 & FeatherS2 Neo This repo is a collection of code, firmware, and files

Unexpected Maker 5 Jan 01, 2023
The main aim of this project is to avoid the accidents in shredding ( Waste Recycling Industry )

shredder-Machine-Hand-Safety The main aim of this project is to avoid the accidents in shredding ( Waste Recycling Industry ) . The Basic function of

Shubham Chaudhari 1 Nov 15, 2021
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
Huawei Solar sensors for Home Assistant

Huawei Solar Sensors This integration splits out the various values that are fetched from your Huawei Solar inverter into separate HomeAssistant senso

Thijs Walcarius 151 Dec 31, 2022
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
Extremely simple PyBadge examples to demonstrate different aspects of CircuitPython using PyBadge hardware.

BeginnerPyBadge I purchased a PyBadge recently. I'm new to hardware. I was surprised how hard it was to find easy examples demonstrating how different

Rubini LaForest 2 Oct 21, 2021
Python Client for ESPHome native API. Used by Home Assistant.

aioesphomeapi aioesphomeapi allows you to interact with devices flashed with ESPHome. Installation The module is available from the Python Package Ind

ESPHome 76 Jan 04, 2023
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

3 Dec 15, 2022
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
SPI driven CircuitPython driver for PCA9745B constant current LED driver.

Introduction THIS IS VERY MUCH ALPHA AND IN ACTIVE DEVELOPMENT. THINGS WILL BREAK! THIS MAY ALSO BREAK YOUR THINGS! SPI driven CircuitPython driver fo

Andrew Ferguson 1 Jan 14, 2022
🐱🖨Cat printer is a portable thermal printer sold on AliExpress for around $20.

Cat printer is a portable thermal printer sold on AliExpress for around $20. This repository contains Python code for talking to the cat printer over

671 Jan 05, 2023
A small Python app to converse between MQTT messages and 433MHz RF signals.

mqtt-rf-bridge A small Python app to converse between MQTT messages and 433MHz RF signals. This acts as a bridge between Paho MQTT and rpi-rf. Require

David Swarbrick 3 Jan 27, 2022
BMP180 sensor driver for Home Assistant used in Raspberry Pi

BMP180 sensor driver for Home Assistant used in Raspberry Pi Custom component BMP180 sensor for Home Assistant. Copy the content of this directory to

747Developments 1 Dec 17, 2021
Python application, displaying currently played track from Spotify on OLED display connected via I2C

RaspberryPi Spotify OLED Display This application will display currently played track on SSD1306 OLED display connected to RaspberryPi. Displayed stuf

Wojciech Olech 2 Dec 30, 2021
A flexible data historian based on InfluxDB, Grafana, MQTT and more. Free, open, simple.

Kotori Telemetry data acquisition and sensor networks for humans. Documentation: https://getkotori.org/ Source Code: https://github.com/daq-tools/koto

83 Nov 26, 2022
A ch341dll Wrap is for using in Python 32bits windows to access I2C SPI and MDIO (by GPIO), and Demo with display PC sreen on OLED by i2c or SPI .

ch341dll_wrap_typcal_app A ch341dll Wrap is for using in Python 32bits windows to access I2C SPI and MDIO (by GPIO). In addition, I provided 3 Demo. I

13 Jan 02, 2023