I’ve tried a few different variations here but it get’s confusing for a novice that is getting google results from before all the changes and after.
Basically. I have this sample json data.
[
{
"id": "2436362028",
"assigner_id": null,
"assignee_id": null,
"project_id": "2170643363",
"section_id": null,
"parent_id": null,
"order": 1,
"content": "my to do list",
"description": "",
"is_completed": false,
"labels": [
"Assistant"
],
"priority": 1,
"comment_count": 0,
"creator_id": "None",
"created_at": "2017-12-13T16:44:14.000000Z",
"due": null,
"url": "https://todoist.com/showTask?id=2436362028"
},
{
"id": "6406815181",
"assigner_id": null,
"assignee_id": null,
"project_id": "2170643364",
"section_id": null,
"parent_id": null,
"order": 1,
"content": "Toilet",
"description": "",
"is_completed": false,
"labels": [
"Lowes"
],
"priority": 1,
"comment_count": 0,
"creator_id": "15330633",
"created_at": "2022-12-04T02:57:25.876862Z",
"due": null,
"url": "https://todoist.com/showTask?id=6406815181"
},
{
"id": "6406815422",
"assigner_id": null,
"assignee_id": null,
"project_id": "2170643364",
"section_id": null,
"parent_id": null,
"order": 2,
"content": "Project box",
"description": "",
"is_completed": false,
"labels": [
"Lowes"
],
"priority": 1,
"comment_count": 0,
"creator_id": "15330633",
"created_at": "2022-12-04T02:57:46.857337Z",
"due": null,
"url": "https://todoist.com/showTask?id=6406815422"
}
]
I’m trying to create a sensor from this that’s something like:
if the json contains the word “Lowes” anywhere then the state of the sensor is on.
Here is the last couple tries I had before giving up.
rest:
- resource: https://api.todoist.com/rest/v2/tasks
scan_interval: 3600
headers:
Content-Type: application/json
Authorization: Bearer My_Token
sensor:
- name: "Lowes"
value_template: "{{ value_json | selectattr('labels', 'eq', 'Lowes' ) | map(attribute = 'labels') | list | first }}"
and then I tried:
rest:
- scan_interval: 3600
resource: https://api.todoist.com/rest/v2/tasks
headers:
Content-Type: application/json
Authorization: Bearer My_Token_is_here
sensor:
- name: "Home Depot"
value_template: "{{ value_json | selectattr('labels', 'eq', 'Lowes' ) | map(attribute = 'labels') | list | first }}"
The sensor shows but it has no state. Don’t really care much what the state is as long as I can set it to Yes/No or On/Off or something. Anyone out there that can help me not pull the rest of my hair out? Thanks.