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
Smart EQ connect - Custom Integration for Home Assistant

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

Rene Nulsch 2 Jan 04, 2022
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
Rasberry Pie GPIO memory game. Press the corresponding key to the lit LED.

RPie-keyboard-game Rasberry Pie GPIO memory game. Press the corresponding key to the lit LED. Randem LED (general output) is lit up on rasberrypi rand

Shawn Dowling 1 Oct 24, 2021
Segger Embedded Studio project for building & debugging Flipper Zero firmware.

Segger Embedded Studio project for Flipper Zero firmware Установка Добавить данный репозиторий в качестве сабмодуля в корень локальной копии репозитор

25 Dec 28, 2022
A iot Bike sytem based on RaspberryPi, Ardiuino

Cyclic 's Kernel ---- A iot Bike sytem based on RaspberryPi, Ardiuino, etc 0x1 What is This? Cyclic 's Kernel is an independent System With self-produ

Retr0mous 2 Oct 09, 2022
USB Rubber Ducky with the Rasberry Pi pico microcontroller

pico-ducky Install Install and have your USB Rubber Ducky working in less than 5 minutes. Download CircuitPython for the Raspberry Pi Pico. Plug the d

AnOnYmOus001100 3 Oct 08, 2022
MPY tool - manage files on devices running MicroPython

mpytool MPY tool - manage files on devices running MicroPython It is an alternative to ampy Target of this project is to make more clean code, faster,

Pavel Revak 5 Aug 17, 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
🎃 Some spooky code samples to hack yourself a pumpkin 👻

🎃 Tech Or Treat 👻 It's spooky season for those who celebrate Halloween, and to get in the spirit (spirit - get it? 👻 ) we thought it would be fun t

Jim Bennett 5 Feb 07, 2022
Technical Answers to Real-World Problems. Evolution of Watering Manually to Watering Automatically.

Automatic Watering System using Soil Moisture Sensor and RTC Timer with Arduino Technical Answers to Real-World Problems Know the plant, Grow the plan

NelakurthiSudheer 3 Jan 03, 2022
Using a raspberry pi, we listen to the coffee machine and count the number of coffee consumption

A typical datarootsian consumes high-quality fresh coffee in their office environment. The board of dataroots had a very critical decision by the end of 2021-Q2 regarding coffee consumption.

dataroots 51 Nov 21, 2022
A script that publishes power usage data of iDrac enabled servers to an MQTT broker for integration into automation and power monitoring systems

iDracPowerMonitorMQTT This script publishes iDrac power draw data for iDrac 6 enabled servers to an MQTT broker. This can be used to integrate the pow

Lucas Zanchetta 10 Oct 06, 2022
Designed and coded a password manager in Python with Arduino integration

Designed and coded a password manager in Python with Arduino integration. The Program uses a master user to login, and stores account data such as usernames and passwords to the master user. While lo

Noah Colbourne 1 Jan 16, 2022
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
2021 Real Robot Challenge Phase2 attemp

Real_Robot_Challenge_Phase2_AE_attemp We(team name:thriftysnipe) are the first place winner of Phase1 in 2021 Real Robot Challenge. Please see this pa

Qiang Wang 2 Nov 15, 2021
🏡 My Home Assistant Configs. Be sure to 🌟 my repo to follow the updates!

Home Assistant Configuration Here's my Home Assistant configuration. I have installed HA on a Lenovo ThinkCentre M93P Tiny with an Intel Dual-Core i5-

iLyas Bakouch 25 Dec 30, 2022
Homeautomation system created with Raspberry Pi 3 and Firebase.

Homeautomation System - Raspberry Pi 3 Desenvolvido com Python, Flask com AJAX e Firebase permite o controle local e remoto Itens necessários Raspberr

Joselino Santos 0 Mar 09, 2022
gdsfactory is an EDA (electronics design automation) tool to Layout Integrated Circuits.

gdsfactory 3.5.5 gdsfactory is an EDA (electronics design automation) tool to Layout Integrated Circuits. It is build on top of phidl gdspy and klayou

147 Jan 04, 2023
PBA: Pleco Breeding Assistant

A small monitor that reports the external, fishroom and water change parameters to have suitable water parameters and induce breeding. These two features already represent 50% of the "reproductive su

Mirko Mancin 1 Jan 19, 2022
A script and GUI for controlling stepper motors from an arduino

A script and GUI for controlling stepper motors from an arduino (nema 23 in my case but should work for others in general)

Pip 2 Aug 01, 2022