Created
April 13, 2020 07:58
-
-
Save rawiriblundell/f918caa09550a4c9540f21c1d506b246 to your computer and use it in GitHub Desktop.
A function to get some basic state and temperature info from a Daikin heatpump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daikin() { | |
local remote_unit temp_info unit_info unit_mode inside_temperature | |
local outside_temperature target_temperature | |
remote_unit=$(host -4 Client.burnination.net | awk '{print $4}') | |
case "${remote_unit}" in | |
(found:) | |
printf -- '%s\n' "Daikin Aircon Information" \ | |
"=========================" \ | |
"Remote unit not found" >&2 | |
exit 1 | |
esac | |
temp_info="http://${remote_unit}/aircon/get_sensor_info" | |
unit_info="http://${remote_unit}/aircon/get_control_info" | |
mapfile -t -d, tempdata < <(curl -s "${temp_info}") | |
mapfile -t -d, unitdata < <(curl -s "${unit_info}") | |
inside_temperature="${tempdata[1]}" | |
outside_temperature="${tempdata[3]}" | |
target_temperature="${unitdata[4]}" | |
case "${unitdata[1]}" in | |
(pow=0) | |
printf -- '%s\n' "Daikin Aircon Information" \ | |
"=========================" \ | |
"Heatpump unit is currently off" \ | |
"Inside Temperature: ${inside_temperature##*=}c" \ | |
"Outside Temperature: Unavailable, please turn unit on" \ | |
"Target Temperature: ${target_temperature##*=}c" | |
;; | |
(pow=1) | |
case "${unitdata[2]}" in | |
(mode=2) unit_mode=dehumidifying ;; | |
(mode=3) unit_mode=cooling ;; | |
(mode=4) unit_mode=heating ;; | |
(mode=6) unit_mode=fan ;; | |
(*) unit_mode=auto ;; | |
esac | |
printf -- '%s\n' "Daikin Aircon Information" \ | |
"=========================" \ | |
"Heatpump unit is currently on, in ${unit_mode} mode" \ | |
"Inside Temperature: ${inside_temperature##*=}c" \ | |
"Outside Temperature: ${outside_temperature##*=}c" \ | |
"Target Temperature: ${target_temperature##*=}c" | |
;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment