Kaptain.
Telegram /
LinkedIn /
Email /
GIT /
RSS /
GPG /
Заказ печатных плат

№ 12606 В разделе
Sysadmin
от June 3rd, 2025,
В подшивках: Bash, Security
XML used to make API calls.
Create file hiwatch-body.tmpl with your OSD template:
<?xml version="1.0" encoding="UTF-8"?> <TextOverlayList version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema"> <TextOverlay> <id>1</id> <displayText>$CAM_TEXT</displayText> <enabled>true</enabled> <positionX>0</positionX> <positionY>576</positionY> </TextOverlay> </TextOverlayList>
Here: OSD coords, ID and text in $CAM_TEXT variable. Of cource, you can template anything.
Now create bash script hiwatch-set-text.sh:
#!/bin/bash
# Load data from MQTT
romashka=$(/usr/bin/mosquitto_sub -C 1 -N -h 192.168.1.9 -p 1883 -u login -P password -t "/device/48:55:19:C8:E4:0A/termo/1/data" -W 1)
zemlya=$(/usr/bin/mosquitto_sub -C 1 -N -h 192.168.1.9 -p 1883 -u login -P password -t "/device/zemlya/termo/1/data" -W 1)
# Create string with your data in variable
export CAM_TEXT="Romashka: ${romashka}, Grunt: ${zemlya}"
# Load template and add string from variable CAM_TEXT
body=$(envsubst < hiwatch-body.tmpl)
# Camera URL
url="http://192.168.3.54/ISAPI/System/Video/inputs/channels/1/overlays/text"
# Add your camera creds and send PUT request
curl -s --digest -X PUT -u login:password "$url" -d "$body"
Result:
You are great!
Fortune cookie: Sex without love is an empty experience, but, as empty experiences go, it's one of the best. -- Woody Allen
Leave a Reply