How jezza34000/homeassistant_petkit works
This is a Home Assistant custom integration for Petkit devices. Users configure the integration, which obtains device data and exposes device-specific controls and monitoring as Home Assistant entities. MQTT events trigger faster refreshes; separate branches provide notifications, media access, Bluetooth-relay support, and camera streaming. The README documents these capabilities, while sampled source confirms representative command, MQTT, entity, and streaming behavior; some subsystem connections are therefore intentionally left unspecified.
Main entry points: coordinator.py Device coordinator · __init__.py Integration lifecycle · agora_api.py Petkit API client · camera.py Camera entity
Components 28
Setup and data
- Configuration flow
custom_components/petkit/config_flow.py - Integration lifecycle
custom_components/petkit/__init__.py - Device coordinator
custom_components/petkit/coordinator.py - Device data
custom_components/petkit/data.py - Petkit API client
custom_components/petkit/agora_api.py
Device entities
- Entity base
custom_components/petkit/entity.py - Device controls
custom_components/petkit/button.py - Device settings
custom_components/petkit/switch.py - Sensors
custom_components/petkit/sensor.py - Binary sensors
custom_components/petkit/binary_sensor.py - Other entity platforms
custom_components/petkit
Media and streaming
- Media access
custom_components/petkit/media_source.py - Device images
custom_components/petkit/image.py - Camera entity
custom_components/petkit/camera.py - go2rtc stream manager
custom_components/petkit/go2rtc_stream.py - WHEP proxy
custom_components/petkit/whep_proxy.py - Agora signaling
custom_components/petkit/agora_websocket.py - Agora RTM
custom_components/petkit/agora_rtm.py - SDP handling
custom_components/petkit/agora_sdp.py - Media coordinator
custom_components/petkit/coordinator.py
Events and alerts
- MQTT listener
custom_components/petkit/iot_mqtt.py - Persistent notifications
custom_components/petkit/notifications.py
Other components
- Home Assistant user
- Home Assistant
- Petkit services/devices
- Petkit MQTT broker
- go2rtc
- Browser viewer
Connections 39
- Home Assistant user → Configuration flow: configures
- Configuration flow → Integration lifecycle: sets up
- Integration lifecycle → Petkit API client: initializes
- Integration lifecycle → Device coordinator: starts
- Device coordinator → Petkit API client: fetches data
- Petkit API client → Petkit services/devices: API requests
- Device coordinator → Device data: updates
- Integration lifecycle → MQTT listener: starts
- MQTT listener → Petkit API client: gets MQTT config
- MQTT listener → Petkit MQTT broker: connects
- MQTT listener → Device coordinator: triggers refresh
- Integration lifecycle → Persistent notifications: sets up
- Device coordinator → Persistent notifications: provides device updates
- Integration lifecycle → Entity base: provides shared entity
- Entity base → Device coordinator: reads device state
- Device controls → Petkit API client: sends commands
- Device settings → Petkit API client: updates settings
- Device controls → Home Assistant: exposes actions
- Device settings → Home Assistant: exposes settings
- Sensors → Device coordinator: reads state
- Binary sensors → Device coordinator: reads state
- Sensors → Home Assistant: exposes measurements
- Binary sensors → Home Assistant: exposes statuses
- Other entity platforms → Home Assistant: exposes entities
- Integration lifecycle → Media coordinator: sets up media
- Media access → Media coordinator: reads media
- Media access → Home Assistant: provides media
- Device images → Home Assistant: exposes images
- Camera entity → Media coordinator: reads event images
- Camera entity → go2rtc stream manager: manages streams
- go2rtc stream manager → go2rtc: configures streams
- Camera entity → WHEP proxy: creates stream sessions
- WHEP proxy → Agora signaling: forwards signaling
- Agora signaling → Agora RTM: uses RTM
- Agora signaling → SDP handling: handles SDP
- WHEP proxy → go2rtc: proxies WHEP
- Browser viewer → Camera entity: requests live video
- Camera entity → Browser viewer: returns stream
- Persistent notifications → Home Assistant: creates alerts