#Create file with automation.

1 messages · Page 1 of 1 (latest)

upbeat nova
#

I try to create file with variable but home assistant wont let me. here my automation : ```alias: Create ICS
description: ""
triggers:

  • trigger: state
    entity_id:
    • sensor.ical_ical_christie_event_0
      attribute: start
      to: "on"
      conditions: []
      actions:
  • variables:
    uid: "{{ states('input_text.generated_uuid_new') }}"
    start: >-
    {{ as_timestamp(state_attr('sensor.ical_custom_qmda_solo_event_0',
    'start')) | timestamp_custom('%Y%m%dT%H%M%SZ') }}
    end: >-
    {{ as_timestamp(state_attr('sensor.ical_custom_qmda_solo_event_0',
    'end')) | timestamp_custom('%Y%m%dT%H%M%SZ') }}
    summary: "{{ state_attr('sensor.ical_custom_qmda_solo_event_0', 'summary') }}"
    description: "{{ state_attr('sensor.ical_custom_qmda_solo_event_0', 'description') }}"
    location: "{{ state_attr('sensor.ical_custom_qmda_solo_event_0', 'location') }}"
    file_path: /config/{{ states('input_text.generated_uuid_new') }}.ics
  • action: shell_command.ecrire_fichier_ics
    data:
    content: >
    BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Apple Inc.//NONSGML iCal 4.0.5//EN
    BEGIN:VEVENT UID:{{ uid }} DTSTAMP:{{ start }} DTSTART:{{ start }}
    DTEND:{{ end }} SUMMARY:{{ summary }} DESCRIPTION:{{ description }}
    LOCATION:{{ location }} END:VEVENT END:VCALENDAR
  • action: persistent_notification.create
    data:
    title: Fichier ICS généré
    message: Le fichier ICS a été généré à l'emplacement {{ file_path }}
    mode: single
muted pebble
#

What is the error that you are getting? Is the shell command running correctly?

molten condor
#

I think you need to add parameters in your shell_command like:
unix_add_message: bash /config/unix_cmd/add_log_msg.sh "{{p_group}}" "{{p_level}}" "{{p_message}}"

#

then you can call:

sequence:
  - action: shell_command.unix_add_message
    metadata: {}
    data:
      p_group: "{{ p_group }}"
      p_level: "{{ p_level}}"
      p_message: "{{ p_message}}"