Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aneisch committed May 6, 2024
1 parent f9e803b commit 0d526ed
Show file tree
Hide file tree
Showing 22 changed files with 172 additions and 51 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Build Status](https://github.com/aneisch/home-assistant-config/actions/workflows/check-ha-release-compatibility.yml/badge.svg)](https://github.com/aneisch/home-assistant-config/actions)
[![GitHub last commit](https://img.shields.io/github/last-commit/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/commits/master)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/graphs/commit-activity)
[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2024.5.0%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest)
[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2024.5.1%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest)
<br><a href="https://www.buymeacoffee.com/aneisch" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-black.png" width="150px" height="35px" alt="Buy Me A Coffee" style="height: 35px !important;width: 150px !important;" ></a>


Expand Down Expand Up @@ -56,8 +56,8 @@ Also using Grafana/Influx for graphing, both running in Docker containers on NUC
## Some statistics about my installation:
Description | value
-- | --
Lines of ESPHome YAML | 2801
Lines of Home Assistant YAML | 9031
Lines of ESPHome YAML | 2802
Lines of Home Assistant YAML | 9055
[Integrations](https://www.home-assistant.io/integrations/) in use | 60
Zigbee devices in [`zha`](https://www.home-assistant.io/integrations/zha/) | 26
Z-Wave devices in [`zwave_js`](https://www.home-assistant.io/integrations/zwave_js/) | 37
Expand Down Expand Up @@ -88,19 +88,19 @@ Entities in the [`number`](https://www.home-assistant.io/components/number) doma
Entities in the [`person`](https://www.home-assistant.io/components/person) domain | 2
Entities in the [`plant`](https://www.home-assistant.io/components/plant) domain | 1
Entities in the [`remote`](https://www.home-assistant.io/components/remote) domain | 1
Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 56
Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 48
Entities in the [`select`](https://www.home-assistant.io/components/select) domain | 3
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 417
Entities in the [`siren`](https://www.home-assistant.io/components/siren) domain | 1
Entities in the [`sun`](https://www.home-assistant.io/components/sun) domain | 1
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 167
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 166
Entities in the [`timer`](https://www.home-assistant.io/components/timer) domain | 6
Entities in the [`tts`](https://www.home-assistant.io/components/tts) domain | 1
Entities in the [`update`](https://www.home-assistant.io/components/update) domain | 34
Entities in the [`vacuum`](https://www.home-assistant.io/components/vacuum) domain | 1
Entities in the [`weather`](https://www.home-assistant.io/components/weather) domain | 1
Entities in the [`zone`](https://www.home-assistant.io/components/zone) domain | 6
**Total state objects** | **1204**
**Total state objects** | **1195**
## The HACS integrations/plugins that I use:
**Appdaemon**:<br>
[aneisch/follow_me_appdaemon](https://github.com/aneisch/follow_me_appdaemon)<br>
Expand Down
24 changes: 15 additions & 9 deletions custom_components/dahua/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,6 @@ async def _async_update_data(self):
# Do the one time initialization (do this when Home Assistant starts)
if not self.initialized:
try:
try:
await self.client.async_get_snapshot(0)
# If able to take a snapshot with index 0 then most likely this cams channel needs to be reset
self._channel_number = self._channel
except ClientError:
pass
_LOGGER.info("Using channel number %s", self._channel_number)

# Find the max number of streams. 1 main stream + n number of sub-streams
self._max_streams = await self.client.get_max_extra_streams() + 1
_LOGGER.info("Using max streams %s", self._max_streams)
Expand Down Expand Up @@ -229,6 +221,16 @@ async def _async_update_data(self):
self.machine_name = data.get("table.General.MachineName")
self._serial_number = data.get("serialNumber")

try:
await self.client.async_get_snapshot(0)
# If able to take a snapshot with index 0 then most likely this cams channel needs to be reset
# but check if unit is not a doorbell first as channel 0 doesnt exist for VTOs
if not self.is_doorbell():
self._channel_number = self._channel
except ClientError:
pass
_LOGGER.info("Using channel number %s", self._channel_number)

try:
await self.client.async_get_coaxial_control_io_status()
self._supports_coaxial_control = True
Expand Down Expand Up @@ -538,12 +540,16 @@ def is_doorbell(self) -> bool:
""" Returns true if this is a doorbell (VTO) """
m = self.model.upper()
return m.startswith("VTO") or m.startswith("DH-VTO") or (
"NVR" not in m and m.startswith("DHI")) or self.is_amcrest_doorbell()
"NVR" not in m and m.startswith("DHI")) or self.is_amcrest_doorbell() or self.is_empiretech_doorbell()

def is_amcrest_doorbell(self) -> bool:
""" Returns true if this is an Amcrest doorbell """
return self.model.upper().startswith("AD")

def is_empiretech_doorbell(self) -> bool:
""" Returns true if this is an EmpireTech doorbell """
return self.model.upper().startswith("DB2X")

def is_flood_light(self) -> bool:
""" Returns true if this camera is an floodlight camera (eg.ASH26-W) """
m = self.model.upper()
Expand Down
4 changes: 2 additions & 2 deletions custom_components/dahua/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ def is_on(self):
This is the magic part of this sensor along with the async_added_to_hass method below.
The async_added_to_hass method adds a listener to the coordinator so when the event is started or stopped
it calls the async_write_ha_state function. async_write_ha_state gets the current value from this is_on method.
it calls the schedule_update_ha_state function. schedule_update_ha_state gets the current value from this is_on method.
"""
return self._coordinator.get_event_timestamp(self._event_name) > 0

async def async_added_to_hass(self):
"""Connect to dispatcher listening for entity data notifications."""
self._coordinator.add_dahua_event_listener(self._event_name, self.async_write_ha_state)
self._coordinator.add_dahua_event_listener(self._event_name, self.schedule_update_ha_state)

@property
def should_poll(self) -> bool:
Expand Down
10 changes: 5 additions & 5 deletions custom_components/dahua/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform
from homeassistant.components.camera import SUPPORT_STREAM, Camera
from homeassistant.components.camera import Camera, CameraEntityFeature

from custom_components.dahua import DahuaDataUpdateCoordinator
from custom_components.dahua.entity import DahuaBaseEntity
Expand Down Expand Up @@ -254,8 +254,8 @@ async def async_camera_image(self, width: int | None = None, height: int | None

@property
def supported_features(self):
"""Return supported features."""
return SUPPORT_STREAM
"""Flag supported features."""
return CameraEntityFeature.STREAM

async def stream_source(self):
"""Return the RTSP stream source."""
Expand Down Expand Up @@ -316,7 +316,7 @@ async def async_set_video_profile_mode(self, mode: str):
channel = self._coordinator.get_channel()
model = self._coordinator.get_model()
# Some NVRs like the Lorex DHI-NVR4108HS-8P-4KS2 change the day/night mode through a switch
if 'NVR4108HS' in model:
if 'NVR4108HS' or 'IPC-Color4K' in model:
await self._coordinator.client.async_set_night_switch_mode(channel, mode)
else:
await self._coordinator.client.async_set_video_profile_mode(channel, mode)
Expand All @@ -325,7 +325,7 @@ async def async_adjustfocus(self, focus: str, zoom: str):
""" Handles the service call from SERVICE_SET_INFRARED_MODE to set zoom and focus """
await self._coordinator.client.async_adjustfocus_v1(focus, zoom)
await self._coordinator.async_refresh()

async def async_set_privacy_masking(self, index: int, enabled: bool):
""" Handles the service call from SERVICE_SET_PRIVACY_MASKING to control the privacy masking """
await self._coordinator.client.async_setprivacymask(index, enabled)
Expand Down
47 changes: 47 additions & 0 deletions custom_components/dahua/translations/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"config": {
"step": {
"user": {
"title": "Ajouter une caméra Dahua",
"description": "Adresse exemple : 192.168.1.108",
"data": {
"username": "Nom d'utilisateur",
"password": "Mot de passe",
"address": "Adresse",
"port": "Port",
"rtsp_port": "Port RTSP",
"streams": "Flux RTSP",
"events": "Événements",
"channel": "Canal (les caméras individuelles sont 0, les NVR sont indexés à partir de 0)"
}
},
"name": {
"title": "Configurer le nom du périphérique",
"data": {
"name": "Nom du périphérique"
}
}
},
"error": {
"auth": "Nom d'utilisateur, mot de passe ou adresse incorrect."
},
"abort": {
"single_instance_allowed": "Une seule instance est autorisée.",
"already_configured": "Une seule instance d'un périphérique est autorisée."
}
},
"options": {
"step": {
"user": {
"data": {
"binary_sensor": "Capteur binaire activé",
"sensor": "Capteur activé",
"switch": "Interrupteur activé",
"light": "Lumière activée",
"select": "Sélection activée",
"camera": "Caméra activée"
}
}
}
}
}
7 changes: 6 additions & 1 deletion custom_components/frigate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def get_zones(config: dict[str, Any]) -> set[str]:
return cameras_zones


def decode_if_necessary(data: str | bytes) -> str:
"""Decode a string if necessary."""
return data.decode("utf-8") if isinstance(data, bytes) else data


async def async_setup(hass: HomeAssistant, config: Config) -> bool:
"""Set up this integration using YAML is not supported."""
integration = await async_get_integration(hass, DOMAIN)
Expand Down Expand Up @@ -474,5 +479,5 @@ async def async_will_remove_from_hass(self) -> None:
@callback # type: ignore[misc]
def _availability_message_received(self, msg: ReceiveMessage) -> None:
"""Handle a new received MQTT availability message."""
self._available = msg.payload == "online"
self._available = decode_if_necessary(msg.payload) == "online"
self.async_write_ha_state()
5 changes: 3 additions & 2 deletions custom_components/frigate/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from . import (
FrigateMQTTEntity,
ReceiveMessage,
decode_if_necessary,
get_cameras,
get_cameras_and_audio,
get_cameras_zones_and_objects,
Expand Down Expand Up @@ -184,7 +185,7 @@ def __init__(
@callback # type: ignore[misc]
def _state_message_received(self, msg: ReceiveMessage) -> None:
"""Handle a new received MQTT state message."""
self._is_on = msg.payload == "ON"
self._is_on = decode_if_necessary(msg.payload) == "ON"
self.async_write_ha_state()

@property
Expand Down Expand Up @@ -265,7 +266,7 @@ def __init__(
@callback # type: ignore[misc]
def _state_message_received(self, msg: ReceiveMessage) -> None:
"""Handle a new received MQTT state message."""
self._is_on = msg.payload == "ON"
self._is_on = decode_if_necessary(msg.payload) == "ON"
self.async_write_ha_state()

@property
Expand Down
5 changes: 3 additions & 2 deletions custom_components/frigate/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
FrigateEntity,
FrigateMQTTEntity,
ReceiveMessage,
decode_if_necessary,
get_friendly_name,
get_frigate_device_identifier,
get_frigate_entity_unique_id,
Expand Down Expand Up @@ -238,13 +239,13 @@ def __init__(
@callback # type: ignore[misc]
def _state_message_received(self, msg: ReceiveMessage) -> None:
"""Handle a new received MQTT state message."""
self._attr_is_recording = msg.payload.decode("utf-8") == "ON"
self._attr_is_recording = decode_if_necessary(msg.payload) == "ON"
self.async_write_ha_state()

@callback # type: ignore[misc]
def _motion_message_received(self, msg: ReceiveMessage) -> None:
"""Handle a new received MQTT extra message."""
self._attr_motion_detection_enabled = msg.payload.decode("utf-8") == "ON"
self._attr_motion_detection_enabled = decode_if_necessary(msg.payload) == "ON"
self.async_write_ha_state()

@property
Expand Down
2 changes: 1 addition & 1 deletion custom_components/frigate/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/blakeblackshear/frigate-hass-integration/issues",
"requirements": ["pytz"],
"version": "5.1.0"
"version": "5.2.0"
}
2 changes: 1 addition & 1 deletion custom_components/frigate/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export_recording:
select:
options:
- "realtime"
- "timelapse"
- "timelapse_25x"
start_time:
name: Export Start Time
description: Start time of exported recording
Expand Down
3 changes: 2 additions & 1 deletion custom_components/frigate/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from . import (
FrigateMQTTEntity,
ReceiveMessage,
decode_if_necessary,
get_friendly_name,
get_frigate_device_identifier,
get_frigate_entity_unique_id,
Expand Down Expand Up @@ -119,7 +120,7 @@ def __init__(
@callback # type: ignore[misc]
def _state_message_received(self, msg: ReceiveMessage) -> None:
"""Handle a new received MQTT state message."""
self._is_on = msg.payload == "ON"
self._is_on = decode_if_necessary(msg.payload) == "ON"
self.async_write_ha_state()

@property
Expand Down
36 changes: 36 additions & 0 deletions custom_components/frigate/translations/ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"config": {
"step": {
"user": {
"description": "L'URL que utilitzeu per accedir a Frigate (p. ex. 'http://frigate:5000/')\\n\\nSi feu servir HassOS amb el complement, l'URL hauria de ser 'http://ccab4aaf-frigate:5000/' \\n\\nHome Assistant necessita accedir al port 5000 (api) i 1935 (rtmp) per a totes les funcions.\\n\\nLa integració configurarà sensors, càmeres i la funcionalitat del navegador multimèdia.\\n\\nSensors:\\n- Estadístiques per supervisar el rendiment de Frigate\\n- Recompte d'objectes per a totes les zones i càmeres\\n\\nCàmeres:\\n- Càmeres per a la imatge de l'últim objecte detectat per a cada càmera\\n- Entitats de càmera amb suport de transmissió (requereix RTMP)\\n\\nNavegador multimèdia:\\n - Interfície d'usuari enriquida amb miniatures per explorar clips d'esdeveniments\\n- Interfície d'usuari enriquida per navegar per enregistraments les 24 hores al dia, els set dies a la setmana, per mes, dia, càmera, hora\\n\\nAPI:\\n- API de notificació amb punts de connexió públics per a imatges a les notificacions.",
"data": {
"url": "URL"
}
}
},
"error": {
"cannot_connect": "No s'ha pogut connectar",
"invalid_url": "URL no vàlid"
},
"abort": {
"already_configured": "El dispositiu ja està configurat"
}
},
"options": {
"step": {
"init": {
"data": {
"enable_webrtc": "Activa WebRTC per als fluxos de la càmera",
"rtmp_url_template": "Plantilla de l'URL del RTMP (vegeu la documentació)",
"rtsp_url_template": "Plantilla de l'URL del RTSP (vegeu la documentació)",
"media_browser_enable": "Habiliteu el navegador multimèdia",
"notification_proxy_enable": "Habiliteu el servidor intermediari no autenticat d'esdeveniments de notificacions",
"notification_proxy_expire_after_seconds": "No permetre l'accés a notificacions no autenticades després dels segons especificats (0=mai)"
}
}
},
"abort": {
"only_advanced_options": "El mode avançat està desactivat i només hi ha opcions avançades"
}
}
}
2 changes: 1 addition & 1 deletion extras/Node-RED/flows.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions extras/docker-compose/other/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ services:
container_name: frigate
privileged: true
restart: always
image: ghcr.io/blakeblackshear/frigate:stable
#image: ghcr.io/blakeblackshear/frigate:0.13.0-beta7
#image: ghcr.io/blakeblackshear/frigate:stable
image: ghcr.io/blakeblackshear/frigate:dev-ca8ef70
shm_size: "256mb"
devices:
- /dev/bus/usb:/dev/bus/usb
Expand Down
4 changes: 2 additions & 2 deletions extras/docker-compose/unified/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,8 @@ services:
container_name: frigate
privileged: true
restart: always
image: ghcr.io/blakeblackshear/frigate:stable
#image: ghcr.io/blakeblackshear/frigate:0.13.0-beta7
#image: ghcr.io/blakeblackshear/frigate:stable
image: ghcr.io/blakeblackshear/frigate:dev-ca8ef70
shm_size: "256mb"
devices:
- /dev/bus/usb:/dev/bus/usb
Expand Down
1 change: 1 addition & 0 deletions extras/esphome/kmc_multi_plug_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ switch:
pin: GPIO14
# inverted: yes
id: relay3
restore_mode: ALWAYS_ON
- platform: restart
id: restart_device
name: "${friendly_name} Restart"
Expand Down
2 changes: 1 addition & 1 deletion extras/traefik/traefik.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ experimental:
log:
level: DEBUG

accessLog: {}
#accessLog: {}
Binary file modified images/nodered_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/nodered_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion packages/frigate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ automation:
data:
type: tts
target: media_player.kitchen
- delay: "00:02:00"
- service: camera.snapshot
data:
filename: /config/media/images/{{ '{{ entity_id.entity_id }}' }}/{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg
Expand All @@ -176,6 +175,8 @@ automation:
- service: shell_command.create_timelapse
data:
camera: usps_vehicle
- delay: "00:02:00"


- if: "{{ 'PrimeAir' in trigger.payload_json['after']['label'] }}"
then:
Expand Down
Loading

0 comments on commit 0d526ed

Please sign in to comment.