#!/bin/sh arg="$1" arg2=$2 case "$arg" in power|Power|POWER) if [ $arg2 = "on" ] || [ $arg2 = "On" ] || [ $arg2 = "ON" ] ; then curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X PUT -d '{"Operation" : {"power" : "On"}}' https://192.168.1.XX:8888/devices/0 fi if [ $arg2 = "off" ] || [ $arg2 = "Off" ] || [ $arg2 = "OFF" ] ; then curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X PUT -d '{"Operation" : {"power" : "Off"}}' https://192.168.1.XX:8888/devices/0 fi ;; temperature|Temperature|TEMPERATURE) if [ $arg2 = "20.0" ] ; then curl -s -X PUT -d '{"desired": 20}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "21.0" ] ; then curl -s -X PUT -d '{"desired": 21}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "22.0" ] ; then curl -s -X PUT -d '{"desired": 22}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "23.0" ] ; then curl -s -X PUT -d '{"desired": 23}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "24.0" ] ; then curl -s -X PUT -d '{"desired": 24}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "25.0" ] ; then curl -s -X PUT -d '{"desired": 25}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "26.0" ] ; then curl -s -X PUT -d '{"desired": 26}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "27.0" ] ; then curl -s -X PUT -d '{"desired": 27}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "28.0" ] ; then curl -s -X PUT -d '{"desired": 28}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "29.0" ] ; then curl -s -X PUT -d '{"desired": 29}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi if [ $arg2 = "30.0" ] ; then curl -s -X PUT -d '{"desired": 30}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/temperatures/0 fi ;; mode|Mode|MODE) if [ $arg2 = "cool" ] || [ $arg2 = "Cool" ] || [ $arg2 = "COOL" ] ; then curl -s -X PUT -d '{"modes": ["Cool"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "dry" ] || [ $arg2 = "Dry" ] || [ $arg2 = "DRY" ] ; then curl -s -X PUT -d '{"modes": ["Dry"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "wind" ] || [ $arg2 = "Wind" ] || [ $arg2 = "WIND" ] ; then curl -s -X PUT -d '{"modes": ["Wind"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "auto" ] || [ $arg2 = "Auto" ] || [ $arg2 = "AUTO" ] ; then curl -s -X PUT -d '{"modes": ["Auto"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "heat" ] || [ $arg2 = "Heat" ] || [ $arg2 = "HEAT" ] ; then curl -s -X PUT -d '{"modes": ["Heat"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi ;; purify|Purify|Purify) if [ $arg2 = "on" ] || [ $arg2 = "On" ] || [ $arg2 = "ON" ] ; then curl -s -X PUT -d '{"options": ["Spi_On"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "off" ] || [ $arg2 = "Off" ] || [ $arg2 = "OFF" ] ; then curl -s -X PUT -d '{"options": ["Spi_Off"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi ;; wind|Wind|WIND) if [ $arg2 = "all" ] || [ $arg2 = "All" ] || [ $arg2 = "ALL" ] ; then curl -s -X PUT -d '{"direction": "All"}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/wind fi if [ $arg2 = "upndown" ] || [ $arg2 = "Upndown" ] || [ $arg2 = "UPNDOWNALL" ] ; then curl -s -X PUT -d '{"direction": "Up_And_Low"}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/wind fi if [ $arg2 = "leftnright" ] || [ $arg2 = "Leftnright" ] || [ $arg2 = "LEFTNRIGHT" ] ; then curl -s -X PUT -d '{"direction": "Left_And_Right"}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/wind fi if [ $arg2 = "fix" ] || [ $arg2 = "Fix" ] || [ $arg2 = "FIX" ] ; then curl -s -X PUT -d '{"direction": "Fix"}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/wind fi ;; goodsleep|Goodsleep|GOODSLEEP) if [ $arg2 = "1.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_2"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "2.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_4"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "3.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_6"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "4.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_8"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "5.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_10"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "6.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_12"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "7.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_14"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "8.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_16"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "9.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_18"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi if [ $arg2 = "10.0" ] ; then curl -s -X PUT -d '{"options": ["Sleep_20"]}' -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure https://192.168.1.XX:8888/devices/0/mode fi ;; esac sleep 3 power=`curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X GET https://192.168.1.XX:8888/devices|jq '.Devices[0].Operation.power'` mode=`curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X GET https://192.168.1.XX:8888/devices|jq '.Devices[0].Mode.modes[0]'` purify=`curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X GET https://192.168.1.XX:8888/devices|jq '.Devices[0].Mode.options[3]'` goodsleep=`curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X GET https://192.168.1.XX:8888/devices|jq '.Devices[0].Mode.options[1]'` temperature=`curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X GET https://192.168.1.XX:8888/devices|jq '.Devices[0].Temperatures[0].current'` desired=`curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X GET https://192.168.1.XX:8888/devices|jq '.Devices[0].Temperatures[0].desired'` wind=`curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer rXXXXXXXXc" --cert '/var/packages/homeassistant/target/var/cert.pem' --insecure -X GET https://192.168.1.XX:8888/devices|jq '.Devices[0].Wind.direction'` if [[ $purify == *"On"* ]] ; then purify="On" else purify="Off" fi power=`echo "$power"|sed -e "s/^\"//" -e "s/\"$//"` mode=`echo "$mode"|sed -e "s/^\"//" -e "s/\"$//"` wind=`echo "$wind"|sed -e "s/^\"//" -e "s/\"$//"` goodsleep=`echo "$goodsleep"|sed -e "s/^\"//" -e "s/\"$//" -e "s/Sleep_//"` goodsleep=$((goodsleep / 2)) echo "Power: $power"; echo "Mode: $mode"; echo "Purify: $purify"; echo "Temperature: $temperatureĀ°C"; echo "Desired: $desiredĀ°C"; echo "Good sleep: "$goodsleep"h"; echo "Wind Direction: $wind";