How to use Keypad-createKey in an automation? #46
lflondonol92
started this conversation in
General
Replies: 1 comment 2 replies
-
I'm not very familiar with how to specify input values in automation (/config/automation/dashboard), so I'll demonstrate using scripts (/config/script/dashboard).
When performing this as an operation on the controlset_onetime_password_script_bycontrol:
description: ""
fields:
device_id:
description: "DeviceId"
example: "F1681Dxxxxxx"
required: true
password:
description: "Password"
example: "0123456789"
required: true
name:
description: "Name"
example: "onetime passcode 0123456789"
required: true
sequence:
- parallel:
- service: number.set_value
target:
entity_id: "number.starttime_1_cmd_{{ device_id | lower }}"
data:
value: "{{ now().timestamp() |int }}"
- service: number.set_value
target:
entity_id: "number.endtime_1_cmd_{{ device_id | lower }}"
data:
value: "{{ (now()+ timedelta(days=1)).timestamp() |int }}"
- service: select.select_option
target:
entity_id: "select.type_1_cmd_{{ device_id | lower }}"
data:
option: "a one-time passcode."
- service: text.set_value
target:
entity_id: "text.password_1_cmd_{{ device_id | lower }}"
data:
value: "{{ password }}"
- service: text.set_value
target:
entity_id: "text.name_1_cmd_{{ device_id | lower }}"
data:
value: "{{ name }}"
- delay: 3
- service: button.press
target:
entity_id: "button.btn_1_cmd_{{ device_id | lower }}" When sending MQTT messages directly to the add-on for controlset_one_time_password_script_bymqtt:
description: ""
fields:
device_id:
description: "DeviceId"
example: "F1681Dxxxxxx"
required: true
password:
description: "Password"
example: "0123456789"
required: true
name:
description: "Name"
example: "onetime passcode 0123456789"
required: true
sequence:
- parallel:
- service: mqtt.publish
data_template:
topic: switchbot/{{ device_id | upper }}/cmd
payload: >
{
"CommandType": "command",
"Command": "createKey",
"ParamName": "type",
"ParamValue": "a one-time passcode."
}
- service: mqtt.publish
data_template:
topic: switchbot/{{ device_id | upper }}/cmd
payload: >
{
"CommandType": "command",
"Command": "createKey",
"ParamName": "name",
"ParamValue": "{{ name }}"
}
- service: mqtt.publish
data_template:
topic: switchbot/{{ device_id | upper }}/cmd
payload: >
{
"CommandType": "command",
"Command": "createKey",
"ParamName": "password",
"ParamValue": "{{ password }}"
}
- service: mqtt.publish
data_template:
topic: switchbot/{{ device_id | upper }}/cmd
payload: >
{
"CommandType": "command",
"Command": "createKey",
"ParamName": "startTime",
"ParamValue": "{{ now().timestamp() |int }}"
}
- service: mqtt.publish
data_template:
topic: switchbot/{{ device_id | upper }}/cmd
payload: >
{
"CommandType": "command",
"Command": "createKey",
"ParamName": "endTime",
"ParamValue": "{{ (now()+ timedelta(days=1)).timestamp() |int }}"
}
- delay: 3
- service: mqtt.publish
data_template:
topic: switchbot/{{ device_id | upper }}/cmd
payload: >
{
"ParamName": "position",
"CommandType": "command",
"Command": "createKey",
"ParamName": "btn",
"ParamValue": "action"
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to create one-time password with an automation. However, I cannot make the fields to use the template values that I am setting:
device_id: xxxxx domain: text entity_id: xxxx type: set_value value: Password for {{ (now() + timedelta(days=1)).date() }}
This is the result:
How can I use that create key function in an automation?
Beta Was this translation helpful? Give feedback.
All reactions