You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code takes the detailed attributes from the SureHA bowl entities to track daily consumption for the cat and also set up some notifications.
Integrations
Sure Petcare has the following entities exposed. I don't think I use any of these in the code below, but they are in the lovelace frontend code below so including them for completion
Also make sure you're including the above sensor and var entities in your recorder.
Some input helpers
Sorry not sure how to show these in Yaml as i set them up in the UI
(Input Numbers)
set these up with step = 1
Nik dry food Calories per kg
input_number.nik_dry_food_calories_per_kg
Nik Dry Food Last Weight
input_number.nik_dry_food_last_weight
Nik wet food Calories per kg
input_number.nik_wet_food_calories_per_kg
Nik Wet Food Last Weight
input_number.nik_wet_food_last_weight
(Input DateTime)
Nik last ate
input_datetime.nik_last_ate
Nik last fed
input_datetime.nik_last_fed
(Input boolean -toggle)
Nik_fed_breakfast
input_boolean.nik_fed_breakfast
nik_fed_dinner
input_boolean.nik_fed_dinner
Automations and scripts
This is triggered when the weight of the bowls change. It works out if it is added to (fed) or subtracted from (ate). I've included this as one automation as previously I had them separately and both were changing similar variables so ended up both running.
When the cat eats, it adds the recent feed to the daily consumption variables and sets the time of the feed
When the cat is fed, it sets the time that the cat was last fed (i.e. the bowls were filled by a human), updates the variables measuring how much is left in each bowl, and sets the booleans for 'fed dinner' or 'fed breakfast' based on the time
This next one notifies me if Nik hasn't been fed breakfast by 8.30am, and again at 10am and 11am
- id: '[yours here 4]'
alias: Nik hungry (breakfast)
description: ''
trigger:
- platform: time
at: 08:30:00
- platform: time
at: '10:00:00'
- platform: time
at: '11:00:00'
condition:
- condition: state
entity_id: input_boolean.nik_fed_breakfast
state: 'off'
action:
- service: notify.[your-mobile-app-address-here-without-brackets]
data:
message: Cat is hungry :(
title: Nik hasn't been fed breakfast yet!!
mode: single
This one does the same but for dinner - 7.30pm etc.
- id: '[yours here 5]'
alias: Nik hungry (dinner)
description: ''
trigger:
- platform: time
at: '19:30:00'
- platform: time
at: '22:00:00'
- platform: time
at: '21:00:00'
condition:
- condition: state
entity_id: input_boolean.nik_fed_dinner
state: 'off'
action:
- service: notify.[your-mobile-address-here-without-brackets]
data:
message: Cat is hungry :(
title: Nik hasn't been fed dinner yet!!
mode: single
This one tells me if its after 6pm, nik hasn't been fed dinner, and he has come in and tried to eat (usually if i'm nearby i won't feed him until he comes in, to make it as fresh as possible
- id: '[yours here 6]'
alias: Nik hungry (dinner and tried)
description: ''
trigger:
- platform: state
entity_id:
- input_datetime.nik_last_ate
for:
hours: 0
minutes: 0
seconds: 10
condition:
- condition: state
entity_id: input_boolean.nik_fed_dinner
state: 'off'
- condition: time
after: '18:00:00'
weekday:
- sat
- fri
- thu
- wed
- tue
- mon
- sun
before: '23:59:00'
action:
- service: notify.[your-mobile-address-here-without-brackets]
data:
message: Cat is hungry and just tried to eat :(
title: Nik hasn't been fed dinner yet and he has just tried to eat something
in his bowl!!
mode: single
Same for breakfast
- id: '[yours here 7]'
alias: Nik hungry (breakfast and tried)
description: ''
trigger:
- platform: state
entity_id:
- input_datetime.nik_last_ate
for:
hours: 0
minutes: 0
seconds: 10
condition:
- condition: state
entity_id: input_boolean.nik_fed_breakfast
state: 'off'
for:
hours: 0
minutes: 0
seconds: 10
- condition: time
after: 07:00:00
weekday:
- sat
- fri
- thu
- wed
- tue
- mon
- sun
before: '15:00:00'
action:
- service: notify.[your-mobile-address-here-without-brackets]
data:
message: Cat is hungry and just tried to eat :(
title: Nik hasn't been fed breakfast yet and he has just tried to eat something
in his bowl!!
mode: single
This one lets me know if either the dry or wet bowl has dipped below 15g
- id: '[yours here 8]'
alias: Food bowl low
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.feeder_niks_bowl_bowl_0
below: 15
id: dry_low
- platform: numeric_state
entity_id: sensor.feeder_niks_bowl_bowl_1
below: 15
id: wet_low
condition:
- condition: time
after: 07:00:00
before: '21:00:00'
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
action:
- service: notify.[person1]
data:
title: Cat hungry - low food
message: "{% if states('sensor.feeder_niks_bowl_bowl_0') | int <= 15 -%} \n
\ {% if states('sensor.feeder_niks_bowl_bowl_1') | int <= 15 -%}\n Both
bowls are low! \n {% else -%}\n Dry bowl is low! \n {%- endif -%}\n{%-
else -%}\n {% if states('sensor.feeder_niks_bowl_bowl_1') | int <= 15 -%}\n
\ Wet bowl is low! \n {% else -%}\n No bowl is low. \n {%- endif -%}\n{%-
endif -%}\n{{''}}\nDry: {{states('sensor.feeder_niks_bowl_bowl_0') | int }}g
\ Wet: {{states('sensor.feeder_niks_bowl_bowl_1') | int }}g\n"
data:
push:
sound:
name: default
volume: 1
group: Cats
- condition: state
entity_id: person.[person2]
state: home
- service: notify.mobile_app_[person2]
data:
title: Cat hungry - low food
message: "{% if states('sensor.feeder_niks_bowl_bowl_0') | int <= 15 -%} \n
\ {% if states('sensor.feeder_niks_bowl_bowl_1') | int <= 15 -%}\n Both
bowls are low! \n {% else -%}\n Dry bowl is low! \n {%- endif -%}\n{%-
else -%}\n {% if states('sensor.feeder_niks_bowl_bowl_1') | int <= 15 -%}\n
\ Wet bowl is low! \n {% else -%}\n No bowl is low. \n {%- endif -%}\n{%-
endif -%}\n{{''}}\nDry: {{states('sensor.feeder_niks_bowl_bowl_0') | int }}g
\ Wet: {{states('sensor.feeder_niks_bowl_bowl_1') | int }}g\n"
data:
push:
sound:
name: default
volume: 1
group: Cats
mode: single
This not very tidy, and lots of extra stuff in here you don't need to show but I had there as i was debugging. And there's something funny going on in my apex-cards at the crossover from June to July - the flatline data there shows up properly on my mobile app but not on web desktop for some reason.
Note: I have a few custom lovelace frontends installed through HACs - e.g. apexcharts
@magicmega on my sureha install I'm not getting the _bowl_0 and _bowl_1 entities you are showing above, I recently installed SureHA through HACS.
Also, I can confirm you do need the Variables+History integration, but I think you had typos in your suggested addition to confiiguration.yaml (sensors/var but should be senor/variable) - this worked for me, again on a fresh install of Variables_History:
Summary
This code takes the detailed attributes from the SureHA bowl entities to track daily consumption for the cat and also set up some notifications.
Integrations
Sure Petcare has the following entities exposed. I don't think I use any of these in the code below, but they are in the lovelace frontend code below so including them for completion
SureHA integration (installed through HACS)
SureHA entities
Config entry:
Sensors & vars
Set up the following sensors
sensors.yaml
Set up the following 'var'. I have variables+history added in HACS - i think this is using this.
var.yaml
Optional - use utility meter to view consumption over time:
Also make sure you're including the above sensor and var entities in your recorder.
Some input helpers
Sorry not sure how to show these in Yaml as i set them up in the UI
Automations and scripts
This is triggered when the weight of the bowls change. It works out if it is added to (fed) or subtracted from (ate). I've included this as one automation as previously I had them separately and both were changing similar variables so ended up both running.
When the cat eats, it adds the recent feed to the daily consumption variables and sets the time of the feed
When the cat is fed, it sets the time that the cat was last fed (i.e. the bowls were filled by a human), updates the variables measuring how much is left in each bowl, and sets the booleans for 'fed dinner' or 'fed breakfast' based on the time
This next one resets the dinner and breakfast flags at 2am.
This next one notifies me if Nik hasn't been fed breakfast by 8.30am, and again at 10am and 11am
This one does the same but for dinner - 7.30pm etc.
This one tells me if its after 6pm, nik hasn't been fed dinner, and he has come in and tried to eat (usually if i'm nearby i won't feed him until he comes in, to make it as fresh as possible
Same for breakfast
This one lets me know if either the dry or wet bowl has dipped below 15g
This one resets the Nik food counter at 2am
Lovelace
This not very tidy, and lots of extra stuff in here you don't need to show but I had there as i was debugging. And there's something funny going on in my apex-cards at the crossover from June to July - the flatline data there shows up properly on my mobile app but not on web desktop for some reason.
Note: I have a few custom lovelace frontends installed through HACs - e.g. apexcharts
The text was updated successfully, but these errors were encountered: