Just wondering if anyone has managed to get any form of data from Myfitnesspal into Home Assistant ?
Do they have an API?
They do. https://www.myfitnesspal.com/api
Or you could just buy the data off the dark web. (they had a major breach).
Well spotted. The OP has a path to success if no one else has a solution.
A little above my ability to use the API, was just wondering if anyone had got it working.
That is how home assistant works, it leverages APIs to find shit out.
If it is a fairly normal API you can use a rest sensor. Give it a go.
Have requested access to the API for personal use.
I’d like to help more, but the API documentation doesn’t seem to be obvious, I guess they only tell you how it works if you enrol. As I don’t have the device/service I doubt that it’d be much use to me, or that I’d have the ability to test.
I will give you a shout if they give me access to any API
I was going to start a new topic for just this, but figured I should probably see if somebody here was still on this…
It is possible to use python
to access myfitnesspal
without registering to their API (which I tried, but no success yet) via the myfitnesspal
library.
Here is a script I just put together. Do any of you know how to integrate this into Home Assistant? There is pyscript
(HACS addon), but I have not worked with it yet myself…
#!/usr/bin/env python3
import myfitnesspal
client = myfitnesspal.Client(my_username, password=my_password)
day = client.get_date(2021, 1, 17)
print(day)
weight = client.get_measurements('Weight')
print(weight)
activities = day.exercises[0].get_as_list()
print(activities)
This will return
01/17/21 {'calories': 1830.0, 'carbohydrates': 273.0, 'fat': 36.0, 'protein': 79.0, 'sodium': 19364.0, 'sugar': 62.0}
OrderedDict([(datetime.date(2021, 1, 17), most_recent_weight), (datetime.date(2021, 1, 13), second_most_recent_weight)])
[{'name': 'Running (jogging), 8 kph (7.5 min per km)', 'nutrition_information': {'minutes': 61.0, 'calories burned': 741.0}}]
I really hope this sodium value has been calculated incorrectly…
I am considering working on a script that will request the activities per day, then writes them to an influxdb
. Perhaps I’ll do the same for the weight data, but I already log it via OpenMQTTGateway
and node-red
in an influxdb
database.
However!! I am a hobbyist spaghetti coder. While I won’t mind sharing the code here if I got somewhere, it won’t be well written, bug free, or guaranteed to work that great.
So have any of you already done this? Either integrated myfitnesspal
into Home Assistant directly, or perhaps written something that will publish these values locally via mqtt
(so that Home Assistant, or any other tool, could easily access them)?
Found this, though it doesn’t load for me after installation as a custom repository in HACS.
Edited this as the previous component mentioned is up-to-date again.