Rule작성법을 연습하기 위해 PushBullet 연동을 해보았다. Kankun wifi plug의 상태가 변할 때마다 push notification을 받을 수 있도록 OpenHAB2 rule을 작성하면 된다.
PushBullet api token 준비
Pushbullet에서 Account setting페이지를 가보면 Access token을 생성할 수 있다.
Rule 작성
sudo -u openhab vi /etc/openhab2/rules/switch.rules
해서 다음을 입력
rule "switchOn"
when Item mqttsw1 changed from OFF to ON
then executeCommandLine("curl@@-k@@-H@@Access-Token: 토큰키@@-XPOST@@https://api.pushbullet.com/v2/pushes@@-H@@Content-Type: application/json@@--data-binary@@{\"type\": \"note\", \"title\": \"스위치1 상태", \"body\": \"현재 On입니다.\"}@@")
end
rule "switchOff"
when Item mqttsw1 changed from ON to OFF
then executeCommandLine("curl@@-k@@-H@@Access-Token: 토큰키@@-XPOST@@https://api.pushbullet.com/v2/pushes@@-H@@Content-Type: application/json@@--data-binary@@{\"type\": \"note\", \"title\": \"스위치1 상태\", \"body\": \"현재 Off입니다."}@@")
end
이제 스위치를 On/Off하면 이제 푸쉬메시지가 온다.