Closed dkvdm closed 2 years ago
Fixed it with the following change in __init__.py
around line 135:
latest_record = weights.popitem(last=False) # grab first item
latest_weight = latest_record[1] # grab weight from record
additionally, I've added the following extra attributes, which you might find handy:
result["cal_remaining"] = goal_calories - total_calories # calories remaining for the day
result["cal_remaining_ex_workout"] = goal_calories - total_calories - cardio_calories_burned # calories remaining without exercise added for padding
result["cal_goal"] = goal_calories - cardio_calories_burned # calorie goal without exercise added
As an overall status, I want to graph my weight over time, so I've adjusted the sensor to output my weight instead of the % towards calorie goal for the day, which I found less useful as it resets every day:
sensor.py
around line 64
return self.coordinator.data.get("weight") # return weight instead of pct
Anyway, I hope these suggestions help, thank you for the hard work you put into this component!
Thanks for the tip. Will fix this within a few days.
No problem, glad to help! Thank you for your swift response.
I want to make it clear that I'm not telling you what to do, as this is your custom component and I can keep a fork if needed; it would be helpful to move the main sensor output of calorie goal %
to an attribute instead, and use the sensor output for weight instead, so this can be graphed over time :)
To make it more convenient for you, I've created a PR here: https://github.com/helto4real/custom_component_myfitnesspal/pull/15
Just unforked and switched back to master
and updated without any issues, thank you for accepting this PR!
Hey there,
I was about to implement my own custom component when I came across yours! Great work Question: weight is currently returning 0, do you know why this would be the case? See screenshot. Thank you!