空気環境の監視

温度、湿度、IAQなどアナログ値をスライス、1分単位で規定値の上下限値を超えたらアクション、空気環境の監視を自動化出来ます

  • DIO Settingsタブで空気環境のスライスを設定、必要に応じて上下限値を超えたらアクション・・・今回は警報アナウンスとlinenotifyで通知
sound.png
  • Sound Settingsタブで事前に「温度が設定値を超えました対処して下さい」など音声ファイルを用意アップロードしておきます
sound.png
  • Auto_Processタブで条件を設定、自動化はLinuxのcronを使います
    • 温度が規定値より上昇したら毎分固定メッセージをアナウンス設定・・・事前に作成した音声ファイル「温度が設定値を超えました対処して下さい」を再生
    • 湿度が規定値より上昇したら毎分固定メッセージをアナウンス設定・・・「湿度が設定値を超えました対処して下さい」
    • IAQが規定値より上昇したら毎分固定メッセージをアナウンス設定・・・「空気が汚れています直ちに対処して下さい」
    • これらは標準のWEB GUIで設定できます
auto.png
  • ここからは標準で作成されたスクリプトを温度、湿度、空気質の値を音声変換とlinenotifyで通知するように変更します
    スクリプトは/www/remote-hand/tmp/以下auto_act0,auto_act1,auto_act2
auto_act.png auto_act0.png 温度が規定値を超えたら音声ファイル作成、スピーカー搭載ホストiot001.localとiot002f.localへ転送・アナウンスとlinenotify通知するスクリプト/www/remote-hand/tmp/auto_act0を編集
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
#!/bin/bash
if [ ENABLE = "DISABLE" ];then
exit
elif [ "1" != -1 ];then
[ -e /www/remote-hand/tmp/.di_read_data ] && . /www/remote-hand/tmp/.di_read_data
[ -z "${di[17]}" ] && exit
[ "${di[17]}" = "-1" ] && exit
[ "${di[17]}" != "1" ] && exit
fi
if [ 19 -gt 7 -a 19 -lt 14 ];then
/usr/local/bin/pepoirkitpost
elif [ 19 -gt 13 -a 19 -lt 17 ];then
/usr/local/bin/pepotocoshelp 2
elif [ 19 -gt 16 -a 19 -lt 27 ];then
DIR=/www/remote-hand/tmp
OPENJTALK=/usr/bin/open_jtalk
TAKMIVOICE="/var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/takumi/takumi_normal.htsvoice"
USEVOICE=${TAKMIVOICE}
VOICE_PITCH=0.7
prog=iot002_auto_act0
VROOMTEMP=$DIR/${prog}_vtemp.wav
[ -e $VROOMTEMP ] && exit
ROOMNAME="部屋"
tTEMPROOM=$(cat /www/remote-hand/.di_read_data.json| jq -r .gpio_i2c.temp)
[ -z "$tTEMPROOM" -o "$tTEMPROOM" = "1" -o "$tTEMPROOM" = "null" ] && exit
TEMPROOM=$(echo $tTEMPROOM| awk '{gsub(/[^0-9\.]+/,"",$0);printf $0}')
svc -d /www/pepolinux/iaqvoice/
TALK=${ROOMNAME}"の温度が"${TEMPROOM}"度で設定値を超えました、直ちに対処して下さい"
WGETMAIL=/usr/local/bin/pepolinemsgsend
SUBJECT=$prog
$WGETMAIL $SUBJECT++$TALK
echo -en $TALK |$OPENJTALK -r $VOICE_PITCH -x $USEVOICE -ow $VROOMTEMP
/usr/local/bin/pepocurlupload iot001.local $VROOMTEMP
msleep 10000
/usr/local/bin/pepocurlupload iot02f.local $VROOMTEMP
msleep 10000
/usr/local/bin/pepocurlupload iot001.local $VROOMTEMP
msleep 10000
/usr/local/bin/pepocurlupload iot02f.local $VROOMTEMP
# /usr/bin/aplay $VROOMTEMP
msleep 10000
rm $VROOMTEMP
svc -u /www/pepolinux/iaqvoice/
# /usr/local/bin/peposound 2
elif [ 19 -lt 8 ];then
/usr/local/bin/pepodioctl 19 2
fi
auto_act1.png 湿度が規定値を超えたら音声ファイル作成、スピーカー搭載ホストiot001.localとiot002f.localへ転送・アナウンスとlinenotify通知するスクリプト/www/remote-hand/tmp/auto_act1を編集
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
#!/bin/bash
if [ ENABLE = "DISABLE" ];then
exit
elif [ "1" != -1 ];then
[ -e /www/remote-hand/tmp/.di_read_data ] && . /www/remote-hand/tmp/.di_read_data
[ -z "${di[18]}" ] && exit
[ "${di[18]}" = "-1" ] && exit
[ "${di[18]}" != "1" ] && exit
fi
if [ 20 -gt 7 -a 20 -lt 14 ];then
/usr/local/bin/pepoirkitpost
elif [ 20 -gt 13 -a 20 -lt 17 ];then
/usr/local/bin/pepotocoshelp 3
elif [ 20 -gt 16 -a 20 -lt 27 ];then
DIR=/www/remote-hand/tmp
OPENJTALK=/usr/bin/open_jtalk
TAKMIVOICE="/var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/takumi/takumi_normal.htsvoice"
USEVOICE=${TAKMIVOICE}
VOICE_PITCH=0.7
prog=iot002_auto_act1
VROOMHUM=$DIR/${prog}_vhum.wav
[ -e $VROOMHUM ] && exit
ROOMNAME="部屋"
tHUMROOM=$(cat /www/remote-hand/.di_read_data.json| jq -r .gpio_i2c.hum)
[ -z "$tHUMROOM" -o "$tHUMROOM" = "1" -o "$tHUMROOM" = "null" ] && exit
HUMROOM=$(echo $tHUMROOM| awk '{gsub(/[^0-9\.]+/,"",$0);printf $0}')
svc -d /www/pepolinux/iaqvoice/
TALK=${ROOMNAME}"の湿度が"${HUMROOM}"%で設定値を超えました、直ちに対処して下さい"
WGETMAIL=/usr/local/bin/pepolinemsgsend
SUBJECT=$prog
$WGETMAIL $SUBJECT++$TALK
echo -en $TALK |$OPENJTALK -r $VOICE_PITCH -x $USEVOICE -ow $VROOMHUM
/usr/local/bin/pepocurlupload iot001.local $VROOMHUM
# /usr/bin/aplay $VROOMHUM
msleep 10000
/usr/local/bin/pepocurlupload iot02f.local $VROOMHUM
msleep 10000
/usr/local/bin/pepocurlupload iot001.local $VROOMHUM
msleep 10000
/usr/local/bin/pepocurlupload iot02f.local $VROOMHUM
msleep 10000
rm $VROOMHUM
svc -u /www/pepolinux/iaqvoice/
# /usr/local/bin/peposound 3
elif [ 20 -lt 8 ];then
/usr/local/bin/pepodioctl 20 3
fi
auto_act2.png IAQが規定値を超えたら音声ファイル作成、スピーカー搭載ホストiot001.localとiot002f.localへ転送・アナウンスとlinenotify通知するスクリプト/www/remote-hand/tmp/auto_act2を編集
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
#!/bin/bash
if [ ENABLE = "DISABLE" ];then
exit
elif [ "1" != -1 ];then
[ -e /www/remote-hand/tmp/.di_read_data ] && . /www/remote-hand/tmp/.di_read_data
[ -z "${di[23]}" ] && exit
[ "${di[23]}" = "-1" ] && exit
[ "${di[23]}" != "1" ] && exit
fi
if [ 21 -gt 7 -a 21 -lt 14 ];then
/usr/local/bin/pepoirkitpost
elif [ 21 -gt 13 -a 21 -lt 17 ];then
/usr/local/bin/pepotocoshelp 4
elif [ 21 -gt 16 -a 21 -lt 27 ];then
DIR=/www/remote-hand/tmp
OPENJTALK=/usr/bin/open_jtalk
TAKMIVOICE="/var/lib/mecab/dic/open-jtalk/naist-jdic -m /usr/share/hts-voice/takumi/takumi_normal.htsvoice"
USEVOICE=${TAKMIVOICE}
VOICE_PITCH=0.7
prog=iot002_auto_act2
VROOMIAQ=$DIR/${prog}_viaq.wav
[ -e $VROOMIAQ ] && exit
ROOMNAME="部屋"
tIAQROOM=$(cat /www/remote-hand/.di_read_data.json| jq -r .gpio_i2c.iaq)
[ -z "$tIAQROOM" -o "$tIAQROOM" = "1" -o "$tIAQROOM" = "null" ] && exit
IAQROOM=$(echo $tIAQROOM| awk '{gsub(/[^0-9\.]+/,"",$0);printf $0}')
svc -d /www/pepolinux/iaqvoice/
TALK=${ROOMNAME}"の空気が"${IAQROOM}"で設定値を超えました、直ちに対処して下さい"
WGETMAIL=/usr/local/bin/pepolinemsgsend
SUBJECT=$prog
$WGETMAIL $SUBJECT++$TALK
echo -en $TALK |$OPENJTALK -r $VOICE_PITCH -x $USEVOICE -ow $VROOMIAQ
/usr/local/bin/pepocurlupload iot001.local $VROOMIAQ
# /usr/bin/aplay $VROOMIAQ
msleep 10000
/usr/local/bin/pepocurlupload iot02f.local $VROOMIAQ
msleep 10000
/usr/local/bin/pepocurlupload iot001.local $VROOMIAQ
msleep 10000
/usr/local/bin/pepocurlupload iot02f.local $VROOMIAQ
msleep 10000
rm $VROOMIAQ
svc -u /www/pepolinux/iaqvoice/
# /usr/local/bin/peposound 4
elif [ 21 -lt 8 ];then
/usr/local/bin/pepodioctl 21 4
fi
  • linenotifyで通知する
auto_act_line.png