Home Assistant custom component for notifying message via Line Messaging API (https://developers.line.biz/en/docs/messaging-api/overview/)
service: line_bot.send_message
data:
to: me
message:
type: text
text: "Hello World!"
- Created a channel from Line Console.
- Follow instructions from the link to create a new channel.
-
Install via custom component of HACS.
-
Retrieve "Channel access token" and "Channel secret" from Line Console
-
Install integration
-
Set "Webhook URL" from "Messaging API" tab of Line Console as below
- Webhook URL is base_url + "/api/line/callback"
- Your HomeAssistant URL has to support https
-
Click "Verify" button to verify URL is valid. It has to return "Success"
-
Add a bot as a friend by either QR code or Bot ID
-
Send any message to a bot
-
Go to [Configure > Add a chat] and follow the directions.
configure add a chat configure a chat -
Try examples
service data attribute | required | dataType | description |
---|---|---|---|
to | no | string | name of chat ID from allowed_chat_ids in configuration.yaml file to push message. |
reply_token | no | string | reply_token received from webhook event to reply message. |
message | yes | Message | eg. Text message, Image message,Template message, etc... |
service: line_bot.send_message
data:
to: me
message:
type: text
text: "Hello World!"
service data attribute | required | dataType | description |
---|---|---|---|
to | no | string | name of chat ID from allowed_chat_ids in configuration.yaml file to push message. |
reply_token | no | string | reply_token received from webhook event to reply message. |
buttons | yes | list | a list of Actions (max: 4) |
service: line_bot.send_button_message
data:
to: me
text: What do you want to do?
buttons:
# MessageAction (https://developers.line.biz/en/reference/messaging-api/#message-action)
- label: Turn off the light
text: light off
# PostbackAction (https://developers.line.biz/en/reference/messaging-api/#postback-action)
- label: Buy
data: action=buy&itemid=111
# UriAction (https://developers.line.biz/en/reference/messaging-api/#uri-action)
- uri: https://www.google.com/
label: Google
service data attribute | required | dataType | description |
---|---|---|---|
to | no | string | name of chat ID from allowed_chat_ids in configuration.yaml file to push message. |
reply_token | no | string | reply_token received from webhook event to reply message. |
buttons | yes | list | a list of Actions (max: 2) |
service: line_bot.send_confirm_message
data:
to: me
text: Are you sure?
buttons:
# PostbackAction
- text: Yes
data: action=buy&itemid=111 # equivalent to {"label" : "Yes", "data" : "action=buy&itemid=111 "}
# MessageAction
- text: No # equivalent to {"text" : "No", "label" : "No"}
event data attribute | dataType | description |
---|---|---|
reply_token | string | It is used to reply message. |
event | MessageEvent | Event object which contains the sent message. The message field contains a message object which corresponds with the message type. You can reply to message events. |
content | TextMessage | Message object which contains the text sent from the source. |
text | string | actual text received |
event data attribute | dataType | description |
---|---|---|
reply_token | string | It is used to reply message. |
event | PostbackEvent | Event object for when a user performs an action on a template message which initiates a postback. You can reply to postback events. |
content | Postback | Postback |
data | string | Postback data |
data_json | dictionary | Postback data as JSON object |
params | dictionary | JSON object with the date and time selected by a user through a datetime picker action. Only returned for postback actions via the datetime picker. |