#Mushroom Chip card action - context user
19 messages · Page 1 of 1 (latest)
You're using the wrong context or accessing it at the wrong time
if you're inside condition or variables before actions are executed, you must use trigger.context. If you are inside an action, you can use context. But it's probably best to always use trigger.context
that is exactly what I am using
action: notify.mobile_app_chris_mobile
metadata: {}
data:
title: Checking context user
message: "{{trigger.context.user_id}}"
What trigger are you using? Or is this just running a script? Some triggers don’t have context
If you’re just in the action section of a script that does not contain triggers, you use the base context object.
Yes, i have no trigger set, then just hit it feom the action
That means there’s no trigger, so you use the context object
@cedar coral did it work?
unfortunately no. When I check the logbook it is showing as null
context:
id: 01J8NFSZDN2P6EX6FX0DNBTJWC
parent_id: 01J8NFSZDMCQGZ0V5Q1T6E8481
user_id: null
that means there is no user_id
can you post the entire setup you're using?
the fact that it has a parent_id tells me something else is creating the context
type: custom:mushroom-chips-card
chips:
- type: template
entity: switch.kitchen_socket_1_relay_switch
icon: mdi:cctv
icon_color: |-
{{
'green' if states('switch.kitchen_socket_1_relay_switch') == 'on'
}}
content: Living
tap_action:
action: perform-action
perform_action: automation.trigger
target:
entity_id: automation.cameras_turning_on
data:
skip_condition: false
hold_action:
action: none
double_tap_action:
action: none
And the automation:
alias: Living Room Camera ON - Request
description: ""
trigger: []
condition: []
action:
- action: notify.mobile_app_chris_mobile
metadata: {}
data:
title: Checking context user
message: "{{ context.user_id }}" - if:
- condition: template
value_template: ""
then: []
enabled: false
- condition: template
- action: notify.mobile_app_chris_mobile
metadata: {}
data:
title: "{{ trigger.entity_id }} is requesting to turn on the cameras"
message: Test Message
data:
actions:
- action: ALLOW_CAMERAS_ON
title: Allow
- action: BLOCK_CAMERAS_ON
title: Block - wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: ALLOW_CAMERAS_ON - platform: event
event_type: mobile_app_notification_action
event_data:
action: BLOCK_CAMERAS_ON
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
continue_on_timeout: false
- platform: event
- if:
- condition: template
value_template: "{{ wait.trigger.event.data.action == 'ALLOW_CAMERAS_ON' }}"
then: - action: notify.mobile_app_chris_mobile
metadata: {}
data:
title: "Cameras: Allowed"
message: cameras will now be turned on
- condition: template
- if:
- condition: template
value_template: "{{ wait.trigger.event.data.action == 'BLOCK_CAMERAS_ON' }}"
then: - action: notify.mobile_app_chris_mobile
metadata: {}
data:
title: "Cameras: Blocked"
message: cameras will NOT be turned on.
mode: single
- condition: template
the first notify is just a test. What I want is to do a condition based on which user is requesting it
can you please format this properly?