LoginSignup
0
1

More than 3 years have passed since last update.

googlehomeを使ってラズパイからPC起動

Last updated at Posted at 2019-07-20

etherwakeでラズパイからPC起動に成功したので
googleHomeに「PCつけて」とか指示をだして、PCを起動したいと思い、環境構築。
以下を参考に構築しました。
https://code-life.hatenablog.com/entry/raspberry-pi-wol

この方はwakeonlanでのサンプルだったので
コマンド起動のsubprocess を追加
import subprocess

以下記述を加工してhpwake.pyを作成。

#   send_magic_packet(mac) ここを変更 
    print('Send Magic Packet: ' + mac)  
    cmd = 'sudo etherwake '
    cmdh = cmd + mac
    print(cmdh)
    subprocess.call(cmdh.split())

これで「PCつけて」と言えばPC起動しました。

さらにsystemdに登録。
$sudo nano /etc/systemd/system/hpwake.service

hpwake.service
[Unit]
Description=hpwake
After=network.target

[Service]
Restart=always
Type=simple
ExecStart=/usr/bin/python3.7 /home/pi/hpwake/hpwake.py

[Install]
WantedBy=graphical.target

そして以下を実施
$sudo systemctl daemon-reload
$sudo systemctl start hpwake
$sudo systemctl status hpwake

起動時に登録をするように設定
$sudo systemctl enable hpwake

でもラズパイリブートするとエラーとなり動きません。
「まあいいか」ですましてます。
だれか教えて。

2020/6/13 
Beebotteサーバ側の問題でSSL接続でエラーとなり6/9ぐらいから動きませんでした。

Traceback (most recent call last):
  File "hpwake.py", line 34, in <module>
    client.connect(HOST, PORT)
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1100, in reconnect
    sock.do_handshake()
  File "/usr/lib/python3.7/ssl.py", line 1117, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1056)

1883(非SSL接続)ポートとし、以下をコメントアウトしたら動いた。
client.tls_set(CA_CERTS)

セキュリティ問題ありとなります。ね。。。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1