Hi everyone!
I’d like to share a new custom integration I’ve created for Home Assistant: ha-fatsecret.
What it does:
This integration connects to the FatSecret API to fetch your nutrition data for today (calories, macros, etc.) and expose them as sensors.
It’s perfect if you want to track your food intake and combine it with other data like activity or energy expenditure.
Notes:
- Requires a FatSecret API account to obtain the Consumer Key and the Consumer Secret when installing the integration.
- Data is fetched for the current day.
- Sensors update automatically every 15 minutes.
Install & Use:
- Add the integration via HACS by searching for “fatsecret”
- Authorize with your FatSecret account
Example setup:
Here’s how I use it in my own dashboard: a custom bar-card to show daily nutrition values alongside my Fitbit burned calories, with a refresh button at the bottom:
I also use Grafana to visualize historical nutrition data over time:
Feedback, feature ideas, or bug reports are very welcome!
You can reply here or open an issue on GitHub.
Cheers,
Xavi
3 Likes
This is brilliant. I use myfitnesspal to track food/calories but I’ve never found a way to get it into HA and it’s now bloated with ads so going to make the switch to fatsecret. Can you share your yaml for the bar cards? That looks great!
Thanks! I also came from MyFitnessPal and changed to FatSecret some time ago.
Here’s the YAML I use for the bar-cards. I’m using the custom:bar-card and a custom:button-card at the bottom.
type: vertical-stack
cards:
- type: markdown
content: |
<h2>Calories goal: {{ states('input_number.calories_goal') }}</h2>
- type: entities
state_color: true
entities:
- entity: sensor.activity_calories
name: Activity Calories
min: 0
max: 3000
entity_row: true
target: 1100
severity:
- color: rgb(42, 96, 153)
from: 0
to: 900
- color: darkgreen
from: 900
to: 1400
- color: darkred
from: 1400
to: 3000
type: custom:bar-card
- entity: input_number.expected_calories
name: Expected Calories
min: 0
max: 3300
entity_row: true
target: 2400
severity:
- color: rgb(42, 96, 153)
from: 0
to: 2300
- color: darkgreen
from: 2300
to: 2700
- color: darkred
from: 2700
to: 3300
type: custom:bar-card
- entity: sensor.calories
name: Burned Calories
min: 0
max: 3300
entity_row: true
target: 2400
severity:
- color: rgb(42, 96, 153)
from: 0
to: 2300
- color: darkgreen
from: 2300
to: 2700
- color: darkred
from: 2700
to: 3300
type: custom:bar-card
- entity: sensor.fatsecret_calories
min: 0
max: 3300
entity_row: true
target: 2300
severity:
- color: rgb(42, 96, 153)
from: 0
to: 2100
- color: darkgreen
from: 2100
to: 2500
- color: darkred
from: 2500
to: 3300
type: custom:bar-card
- entity: input_number.fatsecret_remaining_calories
min: -500
max: 3300
entity_row: true
target: 0
severity:
- color: rgb(42, 96, 153)
from: 300
to: 3300
- color: darkgreen
from: -300
to: 300
- color: darkred
from: -500
to: -300
type: custom:bar-card
- entity: sensor.fatsecret_fiber
min: 0
max: 100
entity_row: true
target: 38
severity:
- color: rgb(42, 96, 153)
from: 0
to: 33
- color: darkgreen
from: 33
to: 43
- color: darkred
from: 43
to: 100
type: custom:bar-card
- entity: sensor.fatsecret_fat
min: 0
max: 100
entity_row: true
target: 59
severity:
- color: rgb(42, 96, 153)
from: 0
to: 49
- color: darkgreen
from: 49
to: 69
- color: darkred
from: 69
to: 100
type: custom:bar-card
- entity: sensor.fatsecret_protein
min: 0
max: 200
entity_row: true
target: 144
severity:
- color: rgb(42, 96, 153)
from: 0
to: 124
- color: darkgreen
from: 124
to: 164
- color: darkred
from: 164
to: 200
type: custom:bar-card
- entity: sensor.fatsecret_sugar
min: 0
max: 150
entity_row: true
target: 75
severity:
- color: rgb(42, 96, 153)
from: 0
to: 50
- color: darkgreen
from: 50
to: 100
- color: darkred
from: 100
to: 150
type: custom:bar-card
- entity: sensor.fatsecret_carbohydrate
min: 0
max: 400
entity_row: true
target: 300
severity:
- color: rgb(42, 96, 153)
from: 0
to: 280
- color: darkgreen
from: 280
to: 320
- color: darkred
from: 320
to: 400
type: custom:bar-card
- type: horizontal-stack
cards:
- type: custom:button-card
color_type: blank-card
- type: custom:button-card
section_mode: false
tap_action:
action: call-service
service: fatsecret.update_fatsecret
icon: mdi:food
size: 100%
styles:
card:
- height: 100px
- width: 100px