Skip to content

Instantly share code, notes, and snippets.

@courville
courville / domoticz-closerollershutters.sh
Last active January 4, 2019 14:03
update domoticz scene timer to close roller shutters at dusk but not before 8pm and not after 10pm at Paris location
#!/bin/sh
#
# domoticz-closerollershutters
# use sunwait to get civil dusk time to calculates when to close roller shutters with the constraints to be in this interval >20h <22h, civildusk i.e. min(max(civildusk,20h),22h)
tdusk=`/usr/local/bin/sunwait -p 48.866667N 2.333333W | grep "Sun rises" | sed "s/^.* sets \([0-9]*\) .*$/\1/g"`
hdusk=`echo $tdusk | cut -c 1-2`
mdusk=`echo $tdusk | cut -c 3-4`
sdusk=`date -d"$hdusk:$mdusk" +%s`
notbefore=`date -d"20:00" +%s`