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
A IC scan test interface for Arduino

ICSCAN_ARDUINO Prerequisites Python 3.6 or higher arduino uno or nano what is this It is a bitstream tranceiver to test IC chip It sends bitstream to

Nifty Chips Laboratory 0 Sep 15, 2022
Pi-hole with Inky pHAT ePaper display

Pi-hole with Inky pHAT ePaper display This is my Pi-hole with an ePaper display.

11 Sep 13, 2022
Python implementation of ZMP Preview Control approach for biped robot control.

ZMP Preview Control This is the Python implementation of ZMP Preview Control app

Chaobin 24 Dec 19, 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
My self-hosting infrastructure, fully automated from empty disk to operating services

Khue's Homelab Current status: ALPHA This project utilizes Infrastructure as Code to automate provisioning, operating, and updating self-hosted servic

Khue Doan 6.4k Dec 31, 2022
Raspberry Pi Pico support for VS Code

Pico-Go VS Code Extension Pico-Go provides code auto-completion and allows you to communicate with your Raspberry Pi Pico board using the built-in REP

Chris Wood 114 Dec 28, 2022
Red Light Green Light Robot

Red Light Green Light Robot The primary problem addressed by our project is robotic follower behavior i.e. maintaining distance from a moving target.

Will Romano 2 Nov 20, 2021
Inykcal is a software written in python for selected E-Paper displays.

Inykcal is a software written in python for selected E-Paper displays. It converts these displays into useful information dashboards. It's open-source, free for personal use, fully modular and user-f

Ace 727 Jan 02, 2023
Run this code to blink your ThinkPad LED with a hidden mysterious Morse code! ;)

TMorse Run this code to blink your ThinkPad LED with a hidden mysterious Morse code! ;) Compatible with python3.9+. No third-party library is required

Mahyar 2 Jul 11, 2022
This is a python script to grab data from Zyxel NSA310 NAS and display in Home Asisstant as sensors.

Home-Assistant Python Scripts Python Scripts for Home-Assistant (http://www.home-assistant.io) Zyxel-NSA310-Home-Assistant Monitoring This is a python

6 Oct 31, 2022
Raspberry Pi Pico Escape Room game.

Pico Escape Room Raspberry Pi Pico Escape Room game. Parts Raspberry Pi Pico Set of 2 x 20-pin Headers for Raspberry Pi Pico 4PCS Breadboards Kit Incl

Kevin Thomas 5 Feb 02, 2022
Shotgrid Toolkit Engine for Gaffer

Shotgun toolkit engine for Gaffer Contact : Diego Garcia Huerta Overview Implementation of a shotgun engine for Gaffer. It supports the classic bootst

Diego Garcia Huerta 12 May 21, 2022
🏡 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
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
Monorepo for my Raspberry Pi dashboard and GPS satellite listener.

🥧 pi dashboard My blog post: Listening to Satellites with my Raspberry Pi This is the monorepo for my Raspberry Pi dashboard!

Andrew Healey 27 Jun 08, 2022
Python code written to utilize the Korlan usb2can hardware to send and receive data over the can-bus on a 2008 Nissan 350z

nissan_ecu_hacking Python code written to utilize the Korlan usb2can hardware to send and receive data over the can-bus on a 2008 Nissan 350z My goal

Liam Goss 11 Sep 24, 2022
Home Assistant custom integration to fetch data from Powerpal

Powerpal custom component for Home Assistant Component to integrate with powerpal. This repository and integration is not affiliated with Powerpal. Th

Lawrence 32 Jan 07, 2023
LifeSaver automatically, periodically saves USB flash drive data into the PC

LifeSaver automatically, periodically saves USB flash drive data into the PC. Theoriticaly it will work with any any connected drive ex - Hard Disk ,SSD ... But, can't handle Backing up multipatition

siddharth dhaka 4 Sep 26, 2021
Better support for Nuki devices to the Home Assistant

Another attempt to add a better support for Nuki devices to the Home Assistant Features: Lock interface implementation Uses local webhook from bridge

Konstantin 105 Jan 07, 2023
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