Skip to content

Instantly share code, notes, and snippets.

@xnumad
Last active February 19, 2021 14:15
Show Gist options
  • Save xnumad/96c95ebc605c50d43b33a34ba6f5ef21 to your computer and use it in GitHub Desktop.
Save xnumad/96c95ebc605c50d43b33a34ba6f5ef21 to your computer and use it in GitHub Desktop.
Bash shell script to run a desired action on a HomeMatic CCU
#!/bin/bash
ccuip="192.168.178.XX" # private/LAN (this way, the action can't be executed outside the home network, except if you happen to be connected to it via a VPN) IP address of your HomeMatic CCU
action="<prototypejs><![CDATA[<YOUR ACTION>]]></prototypejs>" # Copy the action request data from browser dev tools
# Fetch session id
sid=$(curl -sD - "http://${ccuip}/pages/index.htm&client=3" | sed -n "s/^.*\(sid.*\)$/\1/p"); # Only if automatic login is activated on your CCU, this request will receive a response with a session id (sid) which can be found by sed # If you run this script too often (multiple times within a short period), the CCU will not respond with new sids due to "too many connections" for a few minutes.
sid="${sid//[$'\t\r\n ']}"; # sanitize: filter out \t,\r,\n,space chars
# Request desired action, e.g. "open door" on a KeyMatic lock
curl "http://${ccuip}/esp/system.htm?${sid}" --data "${action}";
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment