I want to know how to extract the attribute from a text contained in it. How to do that?
In Habitica integration each daily task is an attribute of the entity sensor.habitica_myusername_dailys
So the attributes will change as I change those tasks.
In the following (simplified) example, since I am looking for the attribute refering to the “cooking” task, what template would return ‘37e06aeb-0a4b-4a19-a087-9390c6f5b323’, knowing only that the text is “cooking” ?
states.sensor.habitica_myusername_dailys.attributes
gives this in the template dev tool:
{
"37e06aeb-0a4b-4a19-a087-9390c6f5b323": {
"repeat": {
"m": false,
"t": false,
"w": false,
"th": false,
"f": false,
"s": false,
"su": true
},
"group": {
"completedBy": {},
"assignedUsers": []
},
"frequency": "weekly",
"every_x": 1,
"next_due": [
"2024-01-14T05:00:00.000Z",
"2024-01-21T05:00:00.000Z",
"2024-01-28T05:00:00.000Z",
"2024-02-04T05:00:00.000Z",
"2024-02-11T05:00:00.000Z",
"2024-02-18T05:00:00.000Z"
],
"yester_daily": true,
"type": "daily",
"priority": 1.5,
"start_date": "2024-01-07T05:00:00.000Z",
"created_at": "2024-01-07T22:01:28.302Z",
"text": "cooking",
"is_due": true
},
"395ea8a4-5a8d-4bc4-9d56-eb6415ca9571": {
"repeat": {
"m": false,
"t": false,
"w": false,
"th": true,
"f": false,
"s": false,
"su": false
},
"group": {
"completedBy": {},
"assignedUsers": []
},
"frequency": "weekly",
"every_x": 1,
"next_due": [
"2024-01-11T05:00:00.000Z",
"2024-01-18T05:00:00.000Z",
"2024-01-25T05:00:00.000Z",
"2024-02-01T05:00:00.000Z",
"2024-02-08T05:00:00.000Z",
"2024-02-15T05:00:00.000Z"
],
"yester_daily": true,
"type": "daily",
"value": 1.0240441476547515,
"priority": 0.1,
"start_date": "2023-12-18T05:00:00.000Z",
"created_at": "2023-12-19T02:55:54.830Z",
"text": "cleaning"
}
In the context of my question, let’s just assume that “cooking” will always be found, and be found once only.