home-assistant.io icon indicating copy to clipboard operation
home-assistant.io copied to clipboard

Service google.create_event

Open jane-t opened this issue 3 years ago • 6 comments

Feedback

The fact it needs an entity_id in the data section is not mentioned. As the older service called needed a calendar_id it is not immediately obvious what line is needed.

URL

https://www.home-assistant.io/integrations/google/

Version

2022.7.7

Additional information

No response

jane-t avatar Aug 02 '22 08:08 jane-t

Hey there @allenporter, mind taking a look at this feedback as it has been labeled with an integration (google) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

It doesn't require an entity ID?

frenck avatar Aug 02 '22 08:08 frenck

This works

service: google.create_event
data:
  entity_id: calendar.work_days
  summary: Working
  start_date_time: >-
    {{state_attr('input_datetime.set_working_day','timestamp')|
    timestamp_custom('%Y-%m-%d 09:00:00')}}
  end_date_time: >-
    {{state_attr('input_datetime.set_working_day','timestamp')|
    timestamp_custom('%Y-%m-%d 09:01:00')}}

The following errors stating a Device, Entity ID is required, which makes sense, but is not mentioned on the documentation,

service: google.create_event
data:
  summary: Working
  start_date_time: >-
    {{state_attr('input_datetime.set_working_day','timestamp')|
    timestamp_custom('%Y-%m-%d 09:00:00')}}
  end_date_time: >-
    {{state_attr('input_datetime.set_working_day','timestamp')|
    timestamp_custom('%Y-%m-%d 09:01:00')}}

jane-t avatar Aug 02 '22 09:08 jane-t

It needs a target, you can also target an area or device directly, no need for entities IDs for that.

Please note, that putting entity_ids in the data section is considered "old-school" it still works, but we don't use such syntax anymore.

frenck avatar Aug 02 '22 09:08 frenck

Sorry, I am not making myself clear, the function is fine. It was just I found the documentation unclear, as there was no mention in the documentation of needing to set a target and as I was working in YAML as the script used templates the visual editor was switched off.

I have adjusted my script to

service: google.create_event
target:
  entity_id: calendar.work_days
data:
  summary: Working
  start_date_time: >-
    {{state_attr('input_datetime.set_working_day','timestamp')|
    timestamp_custom('%Y-%m-%d 09:00:00')}}
  end_date_time: >-
    {{state_attr('input_datetime.set_working_day','timestamp')|
    timestamp_custom('%Y-%m-%d 09:01:00')}}

jane-t avatar Aug 02 '22 10:08 jane-t

So maybe we want to include a link to https://www.home-assistant.io/docs/blueprint/selectors/#target-selector plus a full example to copy/paste?

allenporter avatar Aug 02 '22 14:08 allenporter

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved. If this issue is still relevant, please let us know by leaving a comment 👍 This issue has now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Oct 01 '22 14:10 github-actions[bot]