IBM Cloud의 Node-RED를 사용하여 LINE에서 L 치카
IBM Cloud 및 Line Message API 등록에는 다양한 사이트가 있으므로 그곳을 참조하십시오.
시스템 구성
만든 시스템의 개요는 이쪽입니다.
Line Message API에서 보낸 메시지를 IBM Cloud의 Node-RED에서 수신하고 Internet of Things platform에서 게이트웨이로 보냅니다.
게이트웨이는 메시지를 분석하고 920MHz 무선으로 마이크로 컴퓨터 보드로 전송하여 마이크로 컴퓨터 보드에서 NeoPixel을 빛냅니다. 이때 게이트웨이는 메시지와 라디오 내용에 따라 회선에서 회신했습니다.

완성된 모습

동영상은 여기
클라우드(IBM Cloud/Node-RED)
클라우드 측의 Node-RED는 이것뿐입니다.

Function 노드의 내용
Function 노드에서의 포인트는 3개.

동영상은 여기
클라우드(IBM Cloud/Node-RED)
클라우드 측의 Node-RED는 이것뿐입니다.

Function 노드의 내용
Function 노드에서의 포인트는 3개.
for (var e of msg.payload.events){
if(msg)
node.send({
deviceId: e.source.userId,
payload: {
msg: e.message.text,
replyToken: e.replyToken
}
});
}
return;
클라우드(Line 설정)
여기에 로그인하여 '신규 공급자 만들기'에서 BOT를 만듭니다.
BOT를 작성한 후 Webhook을 이용하여 Node-RED가 움직이는 URL/callback을 Webhook URL로 설정합니다.
또한 이번에는 BOT의 Your user ID를 IBM Cloud의 Internet Of Things Platform의 디바이스 ID에 사용하기 때문에 메모해 둡니다.

클라우드(IBM Cloud/Internet Of Things Platform)
1. 이 화면의 "장치 추가"버튼을 누릅니다.

2. 디바이스 타입은 임의의 문자를, 디바이스 ID에는 Line의 Your User ID를 입력하고 「다음」을 클릭

3. 장치 정보는 필요에 따라 정보를 입력하고 "다음"을 클릭합니다.
4.다음 인증 토큰도 아무것도 하지 않고 '다음'을 클릭
5. 다음 "장치 자격 증명"에는 중요한 정보가 있으므로 이대로 두십시오.
게이트웨이 설정
Raspberry Pi에 Node-RED를 설치하는 방법은 여기을 참조하십시오.
설치가 완료되면 노드를 다음과 같이 배치하십시오.

watson IoT 노드의 설정은 다음과 같이 설정합니다.

각 Function 노드의 소스 코드입니다. Line의 액세스 토큰은 각 페이지의 액세스 토큰을 입력하십시오.
메시지 분석switch(msg.payload.msg) {
case 1:
case 2:
case 3:
case '1':
case '2':
case '3':
return [{
payload: msg.payload.msg,
org: msg.payload
},null];
default:
return [null,msg];
}
지원되지 않는 메시지 회신
const AccessToken = "lineのアクセストークン";
var newMsg = {
headers: {'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer ' + AccessToken,
},
'payload': {
'replyToken': msg.payload.replyToken,
'messages': [{
'type': 'text',
'text': 'ごめんね..解らない m(_ _)m',
}],
}
}
return newMsg;
라디오 결과로 회신
const AccessToken = "lineのアクセストークン";
var replyMsg;
if(msg.payload.result === 0) {
replyMsg = "了解!!"
} else {
replyMsg = "無線でエラーが出ました"
}
return {
headers: {'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer ' + AccessToken,
},
'payload': {
'replyToken': msg.org.replyToken,
'messages': [{
'type': 'text',
'text': replyMsg,
}],
}
}
장치 측 프로그램
Lazurite SubGHz에서 Line에서 보낸 메시지가 1, 2, 3일 때 각각의 빛방법을 하는 프로그램의 소스 코드입니다.
여기에 소스 코드를 넣었습니다.
서둘러서 썼기 때문에 엉망이되어 버렸습니다. Lazurite 블로그 (분)편에, 조금 더 정중하게 기재해 가므로 잘 부탁드립니다! !
Reference
이 문제에 관하여(IBM Cloud의 Node-RED를 사용하여 LINE에서 L 치카), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/NaotakaSaito/items/9f380ad3a1e8388d3df2
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
1. 이 화면의 "장치 추가"버튼을 누릅니다.

2. 디바이스 타입은 임의의 문자를, 디바이스 ID에는 Line의 Your User ID를 입력하고 「다음」을 클릭

3. 장치 정보는 필요에 따라 정보를 입력하고 "다음"을 클릭합니다.
4.다음 인증 토큰도 아무것도 하지 않고 '다음'을 클릭
5. 다음 "장치 자격 증명"에는 중요한 정보가 있으므로 이대로 두십시오.
게이트웨이 설정
Raspberry Pi에 Node-RED를 설치하는 방법은 여기을 참조하십시오.
설치가 완료되면 노드를 다음과 같이 배치하십시오.

watson IoT 노드의 설정은 다음과 같이 설정합니다.

각 Function 노드의 소스 코드입니다. Line의 액세스 토큰은 각 페이지의 액세스 토큰을 입력하십시오.
메시지 분석switch(msg.payload.msg) {
case 1:
case 2:
case 3:
case '1':
case '2':
case '3':
return [{
payload: msg.payload.msg,
org: msg.payload
},null];
default:
return [null,msg];
}
지원되지 않는 메시지 회신
const AccessToken = "lineのアクセストークン";
var newMsg = {
headers: {'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer ' + AccessToken,
},
'payload': {
'replyToken': msg.payload.replyToken,
'messages': [{
'type': 'text',
'text': 'ごめんね..解らない m(_ _)m',
}],
}
}
return newMsg;
라디오 결과로 회신
const AccessToken = "lineのアクセストークン";
var replyMsg;
if(msg.payload.result === 0) {
replyMsg = "了解!!"
} else {
replyMsg = "無線でエラーが出ました"
}
return {
headers: {'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer ' + AccessToken,
},
'payload': {
'replyToken': msg.org.replyToken,
'messages': [{
'type': 'text',
'text': replyMsg,
}],
}
}
장치 측 프로그램
Lazurite SubGHz에서 Line에서 보낸 메시지가 1, 2, 3일 때 각각의 빛방법을 하는 프로그램의 소스 코드입니다.
여기에 소스 코드를 넣었습니다.
서둘러서 썼기 때문에 엉망이되어 버렸습니다. Lazurite 블로그 (분)편에, 조금 더 정중하게 기재해 가므로 잘 부탁드립니다! !
Reference
이 문제에 관하여(IBM Cloud의 Node-RED를 사용하여 LINE에서 L 치카), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/NaotakaSaito/items/9f380ad3a1e8388d3df2
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
switch(msg.payload.msg) {
case 1:
case 2:
case 3:
case '1':
case '2':
case '3':
return [{
payload: msg.payload.msg,
org: msg.payload
},null];
default:
return [null,msg];
}
const AccessToken = "lineのアクセストークン";
var newMsg = {
headers: {'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer ' + AccessToken,
},
'payload': {
'replyToken': msg.payload.replyToken,
'messages': [{
'type': 'text',
'text': 'ごめんね..解らない m(_ _)m',
}],
}
}
return newMsg;
const AccessToken = "lineのアクセストークン";
var replyMsg;
if(msg.payload.result === 0) {
replyMsg = "了解!!"
} else {
replyMsg = "無線でエラーが出ました"
}
return {
headers: {'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer ' + AccessToken,
},
'payload': {
'replyToken': msg.org.replyToken,
'messages': [{
'type': 'text',
'text': replyMsg,
}],
}
}
Lazurite SubGHz에서 Line에서 보낸 메시지가 1, 2, 3일 때 각각의 빛방법을 하는 프로그램의 소스 코드입니다.
여기에 소스 코드를 넣었습니다.
서둘러서 썼기 때문에 엉망이되어 버렸습니다. Lazurite 블로그 (분)편에, 조금 더 정중하게 기재해 가므로 잘 부탁드립니다! !
Reference
이 문제에 관하여(IBM Cloud의 Node-RED를 사용하여 LINE에서 L 치카), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/NaotakaSaito/items/9f380ad3a1e8388d3df2텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)