Home Assistant 2022.8.6 Configuration for your WQHD INSTAR MQTTv5 Broker
- Installation with Docker
- Basic Setup
- Turn your MQTT Topics into Switches
- Add your Switches as UI Elements
Installation with Docker
docker pull homeassistant/home-assistant:latest
mkdir -p /opt/homeassistant/{config}
chmod -R 775 /opt/homeassistant
docker run -d --rm --privileged --net=host --name='home-assistant' -e 'TZ=Europe/Berlin' -v /opt/homeassistant/config:/config homeassistant/home-assistant:latest
Basic Setup
Open your browser on http://localhost:8123/onboarding.html
and create a user account to log in:
Along the way we can directly install the MQTT Addon:
And connect it to our camera's MQTTv5 Broker:
Turn your MQTT Topics into Switches
If you followed the installation path described above you will now be able to find the main configuration file in /opt/homeassistant/config/configuration.yaml
. Here we can add an import for Switch items that we want to use to toggle our camera state through the MQTT API:
# MQTT
# switch: !include mqtt/switches.yaml /deprecated
mqtt: !include mqtt/switches.yaml
Now create the mqtt
folder next to the configuration file and create the file switches.yaml
inside:
mkdir mqtt
nano mqtt/switches.yaml
Here we can create, for example, 4 switches that can toggle the privacy masks in our camera. If your set your camera to use the prefix
cameras and the mqtt ID
115:
You can use the following configuration file - feel free to replace the used used MQTT topics with any topic from our MQTTv5 API:
switch:
- name: 'Garden Red Alarm Area'
state_topic: 'cameras/115/status/alarm/areas/red/enable'
command_topic: 'cameras/115/alarm/areas/red/enable'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Blue Alarm Area'
state_topic: 'cameras/115/status/alarm/areas/blue/enable'
command_topic: 'cameras/115/alarm/areas/blue/enable'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Green Alarm Area'
state_topic: 'cameras/115/status/alarm/areas/green/enable'
command_topic: 'cameras/115/alarm/areas/green/enable'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Yellow Alarm Area'
state_topic: 'cameras/115/status/alarm/areas/yellow/enable'
command_topic: 'cameras/115/alarm/areas/yellow/enable'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Privacy Mask 1'
state_topic: 'cameras/115/status/multimedia/privacy/region1/enable'
command_topic: 'cameras/115/multimedia/privacy/region1/enable'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Privacy Mask 2'
state_topic: 'cameras/115/status/multimedia/privacy/region2/enable'
command_topic: 'cameras/115/multimedia/privacy/region2/enable'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Privacy Mask 3'
state_topic: 'cameras/115/status/multimedia/privacy/region3/enable'
command_topic: 'cameras/115/multimedia/privacy/region3/enable'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Privacy Mask 4'
state_topic: 'cameras/115/status/multimedia/privacy/region4/enable'
command_topic: 'cameras/115/multimedia/privacy/region4/enable'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Auto Gamma'
state_topic: 'cameras/115/status/multimedia/image/gamma/auto'
command_topic: 'cameras/115/multimedia/image/gamma/auto'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Auto Denoise'
state_topic: 'cameras/115/status/multimedia/image/denoise/auto'
command_topic: 'cameras/115/multimedia/image/denoise/auto'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Flip'
state_topic: 'cameras/115/status/multimedia/image/transform/flip'
command_topic: 'cameras/115/multimedia/image/transform/flip'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
- name: 'Garden Mirror'
state_topic: 'cameras/115/status/multimedia/image/transform/mirror'
command_topic: 'cameras/115/multimedia/image/transform/mirror'
qos: 1
payload_on: '{"val":"1"}'
payload_off: '{"val":"0"}'
optimistic: false
retain: false
number:
- name: 'Garden Brightness'
object_id: in9408_brightness
unique_id: in9408_brightness
icon: 'mdi:brightness-6'
state_topic: 'cameras/115/status/multimedia/image/brightness'
command_topic: 'cameras/115/multimedia/image/brightness'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 1
max: 100
step: 1
unit_of_measurement: '%'
qos: 1
optimistic: false
- name: 'Garden Contrast'
object_id: in9408_contrast
unique_id: in9408_contrast
icon: 'mdi:contrast-box'
state_topic: 'cameras/115/status/multimedia/image/contrast'
command_topic: 'cameras/115/multimedia/image/contrast'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 1
max: 100
step: 1
unit_of_measurement: '%'
qos: 1
optimistic: false
- name: 'Garden Saturation'
object_id: in9408_saturation
unique_id: in9408_saturation
icon: 'mdi:palette-outline'
state_topic: 'cameras/115/status/multimedia/image/saturation'
command_topic: 'cameras/115/multimedia/image/saturation'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 1
max: 100
step: 1
unit_of_measurement: '%'
qos: 1
optimistic: false
- name: 'Garden Hue'
object_id: in9408_hue
unique_id: in9408_hue
icon: 'mdi:palette-outline'
state_topic: 'cameras/115/status/multimedia/image/hue'
command_topic: 'cameras/115/multimedia/image/hue'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 0
max: 360
step: 1
qos: 1
optimistic: false
- name: 'Garden Sharpness'
object_id: in9408_sharpness
unique_id: in9408_sharpness
icon: 'mdi:shark-fin-outline'
state_topic: 'cameras/115/status/multimedia/image/sharpness'
command_topic: 'cameras/115/multimedia/image/sharpness'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 1
max: 100
step: 1
unit_of_measurement: '%'
qos: 1
optimistic: false
- name: 'Garden Vibrancy'
object_id: in9408_vibrancy
unique_id: in9408_vibrancy
icon: 'mdi:palette-outline'
state_topic: 'cameras/115/status/multimedia/image/vibrancy/value'
command_topic: 'cameras/115/multimedia/image/vibrancy/value'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 1
max: 255
step: 1
qos: 1
optimistic: false
- name: 'Garden Gamma'
object_id: in9408_gamma
unique_id: in9408_gamma
icon: 'mdi:gamma'
state_topic: 'cameras/115/status/multimedia/image/gamma/preset'
command_topic: 'cameras/115/multimedia/image/gamma/preset'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 1
max: 18
step: 1
qos: 1
optimistic: false
- name: 'Garden Denoise'
object_id: in9408_denoise
unique_id: in9408_denoise
icon: 'mdi:contrast-box'
state_topic: 'cameras/115/status/multimedia/image/denoise/preset'
command_topic: 'cameras/115/multimedia/image/denoise/preset'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 0
max: 15
step: 1
qos: 1
optimistic: false
- name: 'Garden Max ISO'
object_id: in9408_isomax
unique_id: in9408_isomax
icon: 'mdi:brightness-6'
state_topic: 'cameras/115/status/multimedia/image/isomax'
command_topic: 'cameras/115/multimedia/image/isomax'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 1
max: 32
step: 1
qos: 1
optimistic: false
- name: 'Garden Auto IR LEDs'
object_id: in9408_autoled
unique_id: in9408_autoled
icon: 'mdi:lightbulb-night-outline'
state_topic: 'cameras/115/status/features/nightvision/autoled'
command_topic: 'cameras/115/features/nightvision/autoled'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 0
max: 2
step: 1
qos: 1
optimistic: false
- name: 'Garden Auto IRcut'
object_id: in9408_autoircut
unique_id: in9408_autoircut
icon: 'mdi:lightbulb-night-outline'
state_topic: 'cameras/115/status/features/nightvision/autoircut'
command_topic: 'cameras/115/features/nightvision/autoircut'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 0
max: 2
step: 1
qos: 1
optimistic: false
- name: 'Garden Red Alarm Area Sensitivity'
object_id: in9408_red_area_sense
unique_id: in9408_red_area_sense
icon: 'mdi:cctv-off'
state_topic: 'cameras/115/status/alarm/areas/red/sensitivity'
command_topic: 'cameras/115/alarm/areas/red/sensitivity'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 0
max: 100
step: 1
qos: 1
optimistic: false
- name: 'Garden Blue Alarm Area Sensitivity'
object_id: in9408_blue_area_sense
unique_id: in9408_blue_area_sense
icon: 'mdi:cctv-off'
state_topic: 'cameras/115/status/alarm/areas/blue/sensitivity'
command_topic: 'cameras/115/alarm/areas/blue/sensitivity'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 0
max: 100
step: 1
qos: 1
optimistic: false
- name: 'Garden Green Alarm Area Sensitivity'
object_id: in9408_blue_area_green
unique_id: in9408_blue_area_green
icon: 'mdi:cctv-off'
state_topic: 'cameras/115/status/alarm/areas/green/sensitivity'
command_topic: 'cameras/115/alarm/areas/green/sensitivity'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 0
max: 100
step: 1
qos: 1
optimistic: false
- name: 'Garden Yellow Alarm Area Sensitivity'
object_id: in9408_blue_area_yellow
unique_id: in9408_blue_area_yellow
icon: 'mdi:cctv-off'
state_topic: 'cameras/115/status/alarm/areas/yellow/sensitivity'
command_topic: 'cameras/115/alarm/areas/yellow/sensitivity'
value_template: '{{ value_json.val }}'
command_template: '{"val":"{{ value }}"}'
min: 0
max: 100
step: 1
qos: 1
optimistic: false
button:
- name: 'Garden Alarm Trigger'
command_topic: 'cameras/115/alarm/pushalarm'
payload_press: '{"val":"1"}'
icon: mdi:alarm-light
qos: 2
retain: false
- name: 'Garden Reboot'
command_topic: 'system/reboot/now'
payload_press: '{"val":"1"}'
icon: mdi:cog-refresh-outline
qos: 2
retain: false
Note that you need to add both the Command and State Topic. By setting the optimistic
parameter to false each switch will update the command topic when toggled but will only actually switch after your camera returns the state update - signifying that the command was received and executed.
Add your Switches as UI Elements
Now that we have our switches defined we need to add them to our dashboard. Start by enabling the Edit mode:
Create a new dashboard tab:
And click on Add Card to add a new element:
Here you need to select Entities:
And add all switches:
type: entities
entities:
- entity: switch.privacy_mask_1
- entity: switch.privacy_mask_2
- entity: switch.privacy_mask_3
- entity: switch.privacy_mask_4
title: Privacy Mode
state_color: true
Save your dashboard and try it out: