So, it’s working now, here are the steps:
- Go into your config folder, create a new file
homepilot_cookie.sh
- Paste this into the newly created file:
######
# Config
password="myPassword!123" # Change this to your password
ip="192.168.x.x" # Change this to the IP of the HomePilot
######
# You shouldn't need to change anything after this line
# Request a salt
saltrequest=$(curl --silent -X POST http://$ip/authentication/password_salt)
#echo "Saltrequest: "$saltrequest
# Extract the salt from JSON.
salt=$(echo -n $saltrequest | jq -r '.password_salt')
#echo "Salt: "$salt
# Calculate sha256 of password
hashedpassword=$(echo -n $password | sha256sum | cut -d " " -f 1)
#echo "Hashed Password: "$hashedpassword
# Concatenate the salt and hashed password
saltedpassword=$salt$hashedpassword
#echo "saltedpassword: "$saltedpassword
# Calculate sha256 of the salt+hashed password
finalpassword=$(echo -n $saltedpassword | sha256sum | cut -d " " -f 1)
#echo "Final Password: "$finalpassword
# Request the cookie
curl --silent --output /dev/null --cookie-jar - --header "Content-Type: application/json" --request POST --data '{"password":"'$finalpassword'","password_salt":"'$salt'"}' http://$ip/authentication/login | tail -n 1| awk '{print $NF}'
- Create a new sensor:
- platform: command_line
name: homepilot cookie
command: "sh /config/homepilot_cookie.sh"
scan_interval: 300 # You can increase this, I don't know how long the session is valid, so 5 minutes sounds good
- Add this to your existing rest commands (
belt_winder_up
,belt_winder_down
,…) and sensors (Cover Dining West Position
,…)
headers:
cookie: "HPSESSION={{ states('sensor.homepilot_cookie') }}"
Please report back if and how well that works I’ll add it to the guide if it does.