Alexaで空気環境を調べる

  • Alexaからラズパイに部屋の空気環境を喋らす

    • 使用するRaspberry Piは低スペックなのでリアルタイムで喋らすには無理

      • iot001.local –> Raspberry Pi Model B Plus Rev 1.2
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        pi@iot001:~ $ cat /proc/cpuinfo
        processor : 0
        model name : ARMv6-compatible processor rev 7 (v6l)
        BogoMIPS : 697.95
        Features : half thumb fastmult vfp edsp java tls
        CPU implementer : 0x41
        CPU architecture: 7
        CPU variant : 0x0
        CPU part : 0xb76
        CPU revision : 7

        Hardware : BCM2835
        Revision : 0010
        Serial : 000000006979c362
        Model : Raspberry Pi Model B Plus Rev 1.2
      • iot002.local –> Raspberry Pi Zero W Rev 1.1
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        pi@iot002:~ $ cat /proc/cpuinfo
        processor : 0
        model name : ARMv6-compatible processor rev 7 (v6l)
        BogoMIPS : 997.08
        Features : half thumb fastmult vfp edsp java tls
        CPU implementer : 0x41
        CPU architecture: 7
        CPU variant : 0x0
        CPU part : 0xb76
        CPU revision : 7

        Hardware : BCM2835
        Revision : 9000c1
        Serial : 000000002c28cc9a
        Model : Raspberry Pi Zero W Rev 1.1
    • iot002.localではBME680環境センサーから温度、湿度、気圧、IAQをpepoiothoused_voiceopen-jtalkを使い定期的に音声ファイルに変換これを要求に応じて再生

    • Alexaのボイス・コマンドでSwitchのオンオフする際にhomebridge-cmdプラグインを使う・・・/var/log/homebridge.log抜粋
      [20/05/2023, 16:22:20] [Alexa] PowerController TurnOn B8:27:EB:7D:99:CF undefined null
      [20/05/2023, 17:25:08] [床下環境] Setting power state to on
      [20/05/2023, 17:25:09] [床下環境] power function succeeded!
      [20/05/2023, 17:25:09] [床下環境]
      [20/05/2023, 17:25:09] [Alexa] PowerController TurnOn B8:27:EB:7D:99:CF undefined null

      • 床下状態教えて・・・Alexaアプリ定型アクションで「床下環境」をオンオフ
      • homebridge config.json抜粋
        {
          "accessory": "CMD",
          "name": "床下環境",
          "on_cmd": "sudo /usr/local/bin/pepoalexacmd_on iot002.local remote hand dio1high",
          "off_cmd": "sudo /usr/local/bin/pepoalexacmd_off iot002.local remote hand dio1high"
        },
      • pepoalexacmdコマンドで/usr/bin/dio1highを起動
        pepoalexacmd_onとpepoalexacmd_offへSymbolic link
        https://github.com/kujiranodanna/IOT-House/blob/master/raspberrypi/usr/local/bin/pepoalexacmd
      • /usr/bin/dio1highを確認
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        # cat /usr/bin/dio1high
        #!/bin/bash
        LOCK=/www/remote-hand/tmp/dio1high.lock
        if [ -e $LOCK ];then
        exit
        else
        echo -en $$ >$LOCK
        fi
        WGETMAIL=/usr/local/bin/peposendmail
        if [ mail_message = "mail" ];then
        WGETMAIL=/usr/local/bin/peposendmail
        SUBJECT=床下環境+dio1high
        elif [ mail_message = "mail_message" ];then
        DIR=/www/remote-hand/tmp
        tTALK=$DIR/pepoiothoused_voice_talk.wav
        TALK=$DIR/iot002_voice.wav
        if [ -e $tTALK ];then
        cp $tTALK $TALK
        /usr/local/bin/pepocurlupload iot001.local $TALK
        fi
        /usr/local/bin/pepoalexahelp
        MESSAGE=$(cat /www/remote-hand/tmp/.voice_req| awk '{sub("部屋","床下",$0);sub("質","の状態",$0);printf $0}')
        WGETMAIL=/usr/local/bin/pepolinemsgsend
        $WGETMAIL $MESSAGE
      • iot002.localはスピーカー未搭載なのでiot001.localへ音声ファイルを転送して喋ってもらう
      • pepoalexahelpでリアルタイムの空気状態を取得pepolinemsgsendでLine通知iaq_line.png

Homebridge-alexa「床下状態教えて」音声コマンド・デモ