New backup 2025-04-21 14:45:02
This commit is contained in:
parent
35702ffd92
commit
c780fd2839
2 changed files with 29 additions and 42 deletions
|
@ -1,6 +1,6 @@
|
||||||
(defpoll weather_status :initial "{'condition':'loading...','current_temp':'--','feels_temp':'--','min_temp':'--','max_temp':'--','humidity':'--','icon':' ','updated':'loading...'}"
|
(defpoll weather_status :initial "{'condition':'loading...','current_temp':'--','feels_temp':'--','min_temp':'--','max_temp':'--','humidity':'--','icon':' ','updated':'loading...'}"
|
||||||
:interval "3600s"
|
:interval "3600s"
|
||||||
'scripts/home/weather')
|
'scripts/home/hass_weather')
|
||||||
(defwidget weather [json]
|
(defwidget weather [json]
|
||||||
(box
|
(box
|
||||||
:class "weather"
|
:class "weather"
|
||||||
|
|
|
@ -6,7 +6,7 @@ update_cache_json(){
|
||||||
# condition="$(jq -r '.current_condition[0].weatherDesc[0].value' ${hass_weather_cache})"
|
# condition="$(jq -r '.current_condition[0].weatherDesc[0].value' ${hass_weather_cache})"
|
||||||
condition="$(hass-cli -a states -e sensor.openweathermap_weather | jq -r '.state')"
|
condition="$(hass-cli -a states -e sensor.openweathermap_weather | jq -r '.state')"
|
||||||
# condition_code="$(jq -r '.current_condition[0].weatherCode' ${hass_weather_cache})"
|
# condition_code="$(jq -r '.current_condition[0].weatherCode' ${hass_weather_cache})"
|
||||||
condition_code="$(hass-cli -a states -e sensor.openweathermap_weather | jq -r '.state')"
|
condition_code="$(hass-cli -a states -e sensor.openweathermap_weather_code | jq -r '.state')"
|
||||||
# current_temp="$(jq -r '.current_condition[0].temp_F' ${hass_weather_cache})"
|
# current_temp="$(jq -r '.current_condition[0].temp_F' ${hass_weather_cache})"
|
||||||
current_temp="$(hass-cli -a states -e sensor.openweathermap_temperature | jq -r '.state')"
|
current_temp="$(hass-cli -a states -e sensor.openweathermap_temperature | jq -r '.state')"
|
||||||
# feels_temp="$(jq -r '.current_condition[0].FeelsLikeF' ${hass_weather_cache})"
|
# feels_temp="$(jq -r '.current_condition[0].FeelsLikeF' ${hass_weather_cache})"
|
||||||
|
@ -20,6 +20,31 @@ update_cache_json(){
|
||||||
# updated="$(date -r ${hass_weather_cache} '+%Y-%m-%d, %H:%M')"
|
# updated="$(date -r ${hass_weather_cache} '+%Y-%m-%d, %H:%M')"
|
||||||
updated="$(date '+%Y-%m-%d, %H:%M')"
|
updated="$(date '+%Y-%m-%d, %H:%M')"
|
||||||
|
|
||||||
|
case "${condition_code}" in
|
||||||
|
#https://openweathermap.org/weather-conditions#Weather-Condition-Codes-2
|
||||||
|
(2[0-9][0-9])
|
||||||
|
condition_icon=''
|
||||||
|
;;
|
||||||
|
(3[0-9][0-9])
|
||||||
|
condition_icon=''
|
||||||
|
;;
|
||||||
|
(5[0-9][0-9])
|
||||||
|
condition_icon=''
|
||||||
|
;;
|
||||||
|
(6[0-9][0-9])
|
||||||
|
condition_icon=''
|
||||||
|
;;
|
||||||
|
(7[0-9][0-9])
|
||||||
|
condition_icon='▒'
|
||||||
|
;;
|
||||||
|
800)
|
||||||
|
condition_icon=''
|
||||||
|
;;
|
||||||
|
(80[0-9])
|
||||||
|
condition_icon=''
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
jq -n \
|
jq -n \
|
||||||
--arg condition "${condition}" \
|
--arg condition "${condition}" \
|
||||||
--arg current_temp "${current_temp}" \
|
--arg current_temp "${current_temp}" \
|
||||||
|
@ -29,7 +54,7 @@ update_cache_json(){
|
||||||
--arg humidity "${humidity}" \
|
--arg humidity "${humidity}" \
|
||||||
--arg icon "${condition_icon}" \
|
--arg icon "${condition_icon}" \
|
||||||
--arg updated "${updated}" \
|
--arg updated "${updated}" \
|
||||||
'{condition: $condition,current_temp: $current_temp,feels_temp: $feels_temp,min_temp: $min_temp,max_temp: $max_temp,humidity: $humidity,icon: $icon,updated: $updated}' | tee "${hass_weather_cache}"
|
'{condition: $condition,current_temp: $current_temp,feels_temp: $feels_temp,min_temp: $min_temp,max_temp: $max_temp,humidity: $humidity,icon: $icon,updated: $updated}' | tee "${hass_weather_cache}" >/dev/null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,45 +62,7 @@ if [[ ! $(find "${hass_weather_cache}" -cmin -60 -print 2>/dev/null) ]]; then
|
||||||
# if ! ping -w 15 -c 5 hass.pogmom.me;then
|
# if ! ping -w 15 -c 5 hass.pogmom.me;then
|
||||||
# exit 1
|
# exit 1
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
update_cache_json
|
update_cache_json
|
||||||
|
|
||||||
# hass_weather_json=$(hass-cli)
|
|
||||||
# if [ "" != "${hass_weather_json}" ]; then
|
|
||||||
echo "${hass_weather_json}" | tee "${hass_weather_cache}"
|
|
||||||
# fi
|
|
||||||
else
|
|
||||||
cat "${hass_weather_cache}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#condition="$(jq -r '.current_condition[0].weatherDesc[0].value' ${hass_weather_cache})"
|
cat "${hass_weather_cache}"
|
||||||
#condition_code="$(jq -r '.current_condition[0].weatherCode' ${hass_weather_cache})"
|
|
||||||
#current_temp="$(jq -r '.current_condition[0].temp_F' ${hass_weather_cache})"
|
|
||||||
#feels_temp="$(jq -r '.current_condition[0].FeelsLikeF' ${hass_weather_cache})"
|
|
||||||
#min_temp="$(jq -r '.weather[0].mintempF' ${hass_weather_cache})"
|
|
||||||
#max_temp="$(jq -r '.weather[0].maxtempF' ${hass_weather_cache})"
|
|
||||||
#humidity="$(jq -r '.current_condition[0].humidity' ${hass_weather_cache})"
|
|
||||||
#updated="$(date -r ${hass_weather_cache} '+%Y-%m-%d, %H:%M')"
|
|
||||||
|
|
||||||
case "${condition_code}" in
|
|
||||||
113)
|
|
||||||
""
|
|
||||||
;;
|
|
||||||
116|119|122|143)
|
|
||||||
condition_icon=""
|
|
||||||
;;
|
|
||||||
179|227|230)
|
|
||||||
condition_icon=""
|
|
||||||
;;
|
|
||||||
248|260)
|
|
||||||
condition_icon="▒"
|
|
||||||
;;
|
|
||||||
176|182|185|200|263|266|281|284|293|296|299|302|305|308|311)
|
|
||||||
condition_icon=""
|
|
||||||
;;
|
|
||||||
386)
|
|
||||||
condition_icon=""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
#jq -n --arg condition "${condition}" --arg current_temp "${current_temp}" --arg feels_temp "${feels_temp}" --arg min_temp "${min_temp}" --arg max_temp "${max_temp}" --arg humidity "${humidity}" --arg icon "${condition_icon}" --arg updated "${updated}" '{condition: $condition,current_temp: $current_temp,feels_temp: $feels_temp,min_temp: $min_temp,max_temp: $max_temp,humidity: $humidity,icon: $icon,updated: $updated}'
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue