Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] #40

Open
Shablykinm opened this issue May 31, 2023 · 1 comment
Open

[FEATURE REQUEST] #40

Shablykinm opened this issue May 31, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Shablykinm
Copy link

I have a need to maintain three different lists.
Is there any way to simplify the following config?

sensor:
    - platform: rest
      name: tasks
      method: GET
      resource: 'https://api.todoist.com/sync/v9/projects/get_data'
      params:
        project_id: 2313385717
      headers:
        Authorization: !secret todoist_api_token
      value_template: '{{ value_json[''project''][''id''] }}'
      json_attributes:
        - project
        - items
      scan_interval: 30
    - platform: rest
      name: homeplans
      method: GET
      resource: 'https://api.todoist.com/sync/v9/projects/get_data'
      params:
        project_id: 2313385679
      headers:
        Authorization: !secret todoist_api_token
      value_template: '{{ value_json[''project''][''id''] }}'
      json_attributes:
        - project
        - items
      scan_interval: 30
    - platform: rest
      name: purchases
      method: GET
      resource: 'https://api.todoist.com/sync/v9/projects/get_data'
      params:
        project_id: 2313385630
      headers:
        Authorization: !secret todoist_api_token
      value_template: '{{ value_json[''project''][''id''] }}'
      json_attributes:
        - project
        - items
      scan_interval: 30
      
rest_command:
  todoist:
    method: post
    url: 'https://api.todoist.com/sync/v9/{{ url }}'
    payload: '{{ payload }}'
    headers:
      Authorization: !secret todoist_api_token
    content_type: 'application/x-www-form-urlencoded'
@Shablykinm Shablykinm added the enhancement New feature or request label May 31, 2023
@Shablykinm
Copy link
Author

I would not like to specify the same parameters for each list
I would like to minimize the code to the same structure

sensor:
     - platform: rest
      method: GET
      resource: 'https://api.todoist.com/sync/v9/projects/get_data'
      headers:
        Authorization: !secret todoist_api_token
      value_template: '{{ value_json[''project''][''id''] }}'
      json_attributes:
        - project
        - items
      scan_interval: 30
      resources:
        - type: 2313385717
          name: tasks
        - type: 7234632746
          name: homeplans
        - type: 7623476234
          name: purchases
       -  type: ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants