googlefit-homeassistant icon indicating copy to clipboard operation
googlefit-homeassistant copied to clipboard

No Nutrition data

Open AFumi39 opened this issue 2 years ago • 6 comments

Hello, I integrated this component and all works well (all the data that I have on Google Fit app are correctly showed in HA) except Nutrition data. I've integrated MyNetDiary with Google Fit and it sends data correctly. For examples I can see that today at 00:09 local time, I've 3 foods with all their information. But in HA the Nutrition entity is empty

AFumi39 avatar Jan 26 '23 10:01 AFumi39

Nobody can help me? It's been few days that I use this integration, and it's frustrating that I can't have nutrition data in my HA instance. Anyone have some suggestion to try to resolve the problem?

Thank you

AFumi39 avatar Jan 30 '23 11:01 AFumi39

I just tried https://developers.google.com/oauthplayground to view if my data are present, querying derived:com.google.nutrition:com.google.android.gms:merged it correctly returns data. For example:

{
      "startTimeMillis": "1674732767000", 
      "endTimeMillis": "1674819167000", 
      "dataset": [
        {
          "dataSourceId": "derived:com.google.nutrition.summary:com.google.android.gms:aggregated", 
          "point": [
            {
              "startTimeNanos": "1674761760001000000", 
              "originDataSourceId": "raw:com.google.nutrition:com.fourtechnologies.mynetdiary.ad:", 
              "endTimeNanos": "1674761760002000000", 
              "value": [
                {
                  "mapVal": [
                    {
                      "value": {
                        "fpVal": 7.900000095367432
                      }, 
                      "key": "fat.total"
                    }, 
                    {
                      "value": {
                        "fpVal": 1256
                      }, 
                      "key": "sodium"
                    }, 
                    {
                      "value": {
                        "fpVal": 4.050000071525574
                      }, 
                      "key": "fat.saturated"
                    }, 
                    {
                      "value": {
                        "fpVal": 34.80000019073486
                      }, 
                      "key": "protein"
                    }, 
                    {
                      "value": {
                        "fpVal": 1.2999999523162842
                      }, 
                      "key": "carbs.total"
                    }, 
                    {
                      "value": {
                        "fpVal": 218.5
                      }, 
                      "key": "calories"
                    }, 
                    {
                      "value": {
                        "fpVal": 1.2999999523162842
                      }, 
                      "key": "sugar"
                    }, 
                    {
                      "value": {
                        "fpVal": 0.8999999761581421
                      }, 
                      "key": "dietary_fiber"
                    }
                  ]
                }, 
                {
                  "mapVal": [], 
                  "intVal": 3
                }
              ], 
              "dataTypeName": "com.google.nutrition.summary"
            }
          ]
        }
      ]
    }, 

AFumi39 avatar Jan 30 '23 11:01 AFumi39

Have you been able to solve the problem? Except for the Nutriotion sensor, all my values are correct. Nutrition still 0.

En3myNightmare avatar Feb 11 '23 20:02 En3myNightmare

Have you been able to solve the problem? Except for the Nutriotion sensor, all my values are correct. Nutrition still 0.

I found out that the code for this custom component is wrong, not only for nutrition, but also for other parameters. I solved cloning it in my github repository and fixing all the bugs I found out. Since we haven't received any reply/feedback, I think it's not a bad thing if I share my "version" of the component. I you replace the content of "/config/custom_components/google_fit/sensor.py" with this one and reboot, you should see all the data: https://github.com/AFumi39/googlefit-homeassistant/blob/master/custom_components/google_fit/sensor.py

AFumi39 avatar Feb 13 '23 08:02 AFumi39

When I added your code to sensor.py, it returned the error:

ModuleNotFoundError: No module named 'homeassistant.component'

Line 14 is missing an "s": component -> components

Now i works like a charm! Thank you very much!

En3myNightmare avatar Feb 13 '23 16:02 En3myNightmare

Yeah, you're right... I fixed it on my HA but I forgot to push the fix into the repository

AFumi39 avatar Feb 13 '23 16:02 AFumi39