-
Notifications
You must be signed in to change notification settings - Fork 112
Home Assistant integration
tested on Home Assistant >= 2022.06
If you want to integrate your cam automagically, please visit this repo: https://github.com/roleoroleo/yi-hack_ha_integration
If you want to create entities manually, read below.
This hack implements a standard ONVIF interface, thanks to @KoynovStas - https://github.com/KoynovStas/onvif_srvd
Configure your cam using standard ONVIF integration in Home Assistant. RTSP stream and snapshot feature are supported. PTZ is also supported for models that have it.
The only feature not present in ONVIF is the event detection. You can add it through a binary sensor or an MQTT camera
If you want to use binary sensor, configure your cam as an MQTT sensor:
- Access to the web interface
- Go to MQTT section
- Enable MQTT and set the server parameters (ip, port, etc...)
- Set the topic prefix (e.g. "home-assistant/kitchen")
- Set the topic suffix for motion event (e.g. "motion_detection")
- Set the motion start message (e.g. "ON")
- Set the motion stop message (e.g. "OFF")
- Check the other options if you want to configure video list message and baby crying support.
- Check advanced options if you want to change qos or retain parameters.
- Save configuration
Configure Home Assistant adding a binary sensor like this.
mqtt:
binary_sensor:
- state_topic: "home-assistant/kitchen/motion_detection"
name: "Motion detection - kitchen"
payload_on: "motion_start"
payload_off: "motion_stop"
qos: 1
When a motion is detected the sensor will turn on.
If you want to use this feature, configure your cam as an MQTT sensor:
- Access to the web interface
- Go to MQTT section
- Enable MQTT and set the server parameters (ip, port, etc...)
- Set the topic prefix (e.g. "home-assistant/kitchen")
- Set the topic suffix for jpeg image (e.g. "motion_detection_image")
- Check advanced options if you want to change qos or retain parameters.
- Save configuration
Configure Home Assistant adding an MQTT camera like this and add, if you want, a picture-glance to lovelace.
mqtt:
camera:
- topic: "home-assistant/kitchen/motion_detection_image"
name: "Motion detection image - kitchen"
When a motion is detected a jpeg in binary format will be sent to the topic.
If you want to donwload videos recorded from the cam you have two ways:
- MQTT
- Web services
- Configure the topic suffix for video list message in MQTT section
- Wait for the json message sent to this topic when the motion event ends
Example:
{
"start": "2020-02-01T16:28:27+0200",
"end": "2020-02-01T16:29:27+0200",
"files": [
"2020Y02M01D16H/29M00S60.mp4",
"2020Y02M01D16H/28M24S36.mp4"
]
}
- Parse the message and extract the urls (e.g. http://IP-CAM:8080/record/2020Y02M01D16H/28M24S36.mp4)
- Get the videos using http get
- Wait for MQTT stop message
- Call getlastrecordedvideo web service: http://IP-CAM:8080/cgi-bin/getlastrecordedvideo.sh
- See the wiki for details: https://github.com/roleoroleo/yi-hack-Allwinner/wiki/Web-services-description