MarH
(Martin)
1
Hi!
I have some HikVision cameras which support text overlay. The text overlay can be changed by “uploading” (curl -T) a xml file
<TextOverlay xmlns="http://www.hikvision.com/ver10/XMLSchema" version="1.0">
<id>1</id>
<enabled>true</enabled>
<posX>48</posX>
<posY>494</posY>
<message>Temperature: 12.3 °C</message>
</TextOverlay>
I wonder whats the best way to do this in HA. Is there any way to create a file like this, with values of sensors inside the <message> node?
To upload the file from within an automation I can use shell_command?
shell_command:
update_overlay: "curl -T {{ filepath }} {{ url }}"
action:
- service: shell_command.update_overlay
data_template:
url: 'http://1.2.3.4/Video/inputs/channels/1/overlays/text/1'
filepath: '/tmp/overlay.xml'
MarH
(Martin)
2
I still haven’t found a solution …
MarH
(Martin)
3
With a little help of a friend I got it to work:
automations.yaml:
- alias: Webcam Overlay
trigger:
- platform: state
entity_id: sensor.outdoor_avg_temp
action:
- service: shell_command.update_cam_overlay
data_template:
temp_out: '{{ states.sensor.outdoor_avg_temp.state | float }}'
userpassword: admin:12345
url: http://1.2.3.4/Video/inputs/channels/1/overlays/text/1
filepath: /tmp/overlay.xml
configuration.yaml
homeassistant:
whitelist_external_dirs:
- /tmp
shell_command:
update_cam_overlay: /bin/bash -c "sed 's/@@TEMP_OUT@@/{{temp_out}}/g' /tmp/overlay_template.xml > /tmp/overlay.xml && curl --digest --user {{userpassword}} -T {{ filepath }} {{ url }}"
overlay_template.xml
<TextOverlay xmlns="http://www.hikvision.com/ver10/XMLSchema" version="1.0">
<id>1</id>
<enabled>true</enabled>
<posX>48</posX>
<posY>494</posY>
<message>out @@TEMP_OUT@@</message>
</TextOverlay>
On newer HikVision cams the authentication needs to be enabled under “System” -> “Security” -> “Authentication”
Also the overlay needs to be enabled “Advanced Config” -> “Image” -> “OSD” -> “Text Overlay”