-
Notifications
You must be signed in to change notification settings - Fork 0
/
caldera.sh
executable file
·146 lines (141 loc) · 5.45 KB
/
caldera.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
IP_CALDERA="$(grep URL esp_conf.cfg | cut -d'=' -f2)"
estado_caldera() {
RESP=$(curl -s ${IP_CALDERA})
arRS=(${RESP//,/ })
echo "=============================="
echo " Estado Termo "
[[ ${arRS[1]} = "1" ]] && echo " - ENCENDIDO - "
[[ ${arRS[1]} = "0" ]] && echo " - APAGADO - "
echo "------------------------------"
case ${arRS[0]} in
'1') echo " Modo Automático " ;;
'5') echo " Modo Manual " ;;
'6') echo " Modo Libre " ;;
*) echo " verificar conexión! " ;;
esac
echo "------------------------------"
for i in {10..14}; do [[ ${arRS[${i}]} -lt 10 ]] && arRS[${i}]="0"${arRS[${i}]}; done
echo " Hora : ${arRS[10]}:${arRS[11]}:${arRS[12]}"
echo " Fecha : ${arRS[13]}/${arRS[14]}/${arRS[15]}"
echo "------------------------------"
for i in {2..5}; do [[ ${arRS[${i}]} -lt 10 ]] && arRS[${i}]=" "${arRS[${i}]}; done
echo " Horario Temporizador "
echo " 1) ON: ${arRS[2]} OFF: ${arRS[3]} "
echo " 2) ON: ${arRS[4]} OFF: ${arRS[5]} "
echo -e "==============================\n"
}
ejec_orden() {
ORD=""
case $1 in
2) ORD="/sethora?1=2&2=${2}&3=${3}&4=${4}&5=${5}&6=${6}&7=${7}" ;;
3) ORD="/horasAcc?1=3&2=${2}&3=${3}&4=${4}&5=${5}" ;;
4) ORD="/setservo?1=4&2=${2}&3=${3}&4=${4}&5=${5}" ;;
5) if [ -n ${2} ]; then
if [ ${2} = "on" ]; then
ORD="/accion?1=5&2=on"
elif [ ${2} = "off" ]; then
ORD="/accion?1=5&2=off"
fi
else
return
fi ;;
6) ORD="/setlibre?1=6&2=${1}" ;;
*) ORD="" ;;
esac
curl ${IP_CALDERA}${ORD}
}
principal() {
clear
estado_caldera
echo " 1) Funcionamiento Autonomo"
echo " 2) Ajustar hora y fecha"
echo " 3) Ajustar termporizador"
echo " 4) Calibrar Servo"
echo " 5) Modo Manual"
echo " 6) Modo Libre"
echo " 0) Salir"
echo
read -p " Ingresa Opcion :" OPC
case ${OPC} in
"1") echo; curl -s ${IP_CALDERA}'/auto' ;;
"2")
clear
echo "============================"
echo " Valores Actuales en RTC "
echo " Hora : ${arRS[10]}:${arRS[11]}:${arRS[12]}"
echo " Fecha : ${arRS[13]}/${arRS[14]}/${arRS[15]}"
echo -e "============================\n"
echo -e " Configuracion fecha y hora \n"
read -p "ingresa el DIA: " DIA
read -p "ingresa el MES: " MES
read -p "ingresa el AÑO: " ANO
read -p "ingresa la HORA: " HRA
read -p "ingresa los MINUTOS: " MIN
read -p "ingresa los SEGUNDOS: " SEG
ejec_orden 2 ${DIA} ${MES} ${ANO} ${HRA} ${MIN} ${SEG}
;;
"3")
clear
echo -e "=============================="
echo " Horario Temporizador "
echo " 1) ON: ${arRS[2]} OFF: ${arRS[3]} "
echo " 2) ON: ${arRS[4]} OFF: ${arRS[5]} "
echo -e "==============================\n"
echo -e " ingresa nuevo horario \n"
read -p " 1ra hora de encendido: " HR_ON1
read -p " 1ra hora de apagado : " HR_OFF1
echo " opcional"
read -p " 2da hora de encendido: " HR_ON2
read -p " 2da hora de apagado : " HR_OFF2
ejec_orden 3 ${HR_ON1} ${HR_OFF1} ${HR_ON2} ${HR_OFF2}
;;
"4")
for i in {6..9}; do [[ ${arRS[${i}]} -lt 100 ]] && arRS[${i}]=" "${arRS[${i}]}; done
clear
echo -e "============================"
echo " Configuración actual "
echo "----------------------------"
echo " 1ra Posicion ON : ${arRS[6]}"
echo " 2da Posición ON : ${arRS[7]}"
echo "----------------------------"
echo " 1ra Posición OFF : ${arRS[8]}"
echo " 2da Posición OFF : ${arRS[9]}"
echo -e "============================\n"
echo -e " Ingresar valores \n"
read -p " 1ra posición encendido: " POS_ON1
read -p " 2ra posición encendido: " POS_ON2
read -p " 1ra posición apagado: " POS_OFF1
read -p " 2ra posición apagado: " POS_OFF2
echo
ejec_orden 4 ${POS_ON1} ${POS_ON2} ${POS_OFF1} ${POS_OFF2}
;;
"5")
clear
echo -e "============================\n"
echo -e " Accionamiento Manual "
[[ ${arRS[1]} = "1" ]] && echo " - ENCENDIDO - "
[[ ${arRS[1]} = "0" ]] && echo " - APAGADO - "
echo -e "============================\n"
echo -e " Encender o apagar (on/off)\n"
read -p " :" MANUAL
echo
ejec_orden 5 ${MANUAL}
;;
"6")
clear
echo -e "============================\n"
echo -e " Movimiento libre \n"
echo -e "============================\n"
echo " ingresa posición (15<165):"
read -p " :" MANUAL
echo
ejec_orden 6 ${MANUAL}
;;
"0") exit ;;
esac
sleep 8
principal
}
principal
exit