Wiki source for PetFeedingTracking
======Tracking Pet Feeding with Home Automation======
=====Changes=====
2021-08-30 V1 - Started Documenting
2021-09-13 V2 - Updated with notification (Outside light blink) & tidied code
2021-10-10 V3 - Now added voice notifications if not fed
=====Summary=====
A method to track whether the cat and dog have been fed in a busy household.
I think about Home Automation as being 'what things are repeated constantly by people, that don't need to', and this in our house was the question of 'Hey, has anyone fed the pets?"
The solution needed to be cheap, and simple for anyone to use. I decided to use buttons at the pet feeding station to determine when feeding happened - the family know to press once when they feed the dog, feed the cat or top up the water.
I have a touch screen display in the lounge to display results, but I am planning on adding a simple LED display ++and some voice notifications for a few 'alarm' type events, such as 'pets not fed recently'.++
**Update 13 Sep:** There were a couple of times the buttons were pressed and the zigbee coordinator picked them up, but nothing was pushed to MQTT for some reason. Also, there are times people aren't sure if they pressed the button properly. I could have given some voice/sound feedback but this isn't great for early morning feeds so I now flash the outside light when a button is pressed (either 1, 2 or 3 times depending on which button was pressed)
**Update 10 Oct:** I haven't added to the Node Red flows below, but my setup now announces over a couple of Google Home devices (one in Miss 10's room) if the peds haven't been fed in the afternoon. It starts around 4:30pm and keeps announcing every 40mins (about 5 times total) until the pets have been fed.
=====Input Method=====
I managed to get some Zigbee Mi buttons for $10 each. Zigbee is simple, and for non critical applications and in areas where running cables is a pain, so is a good solution. The feeding area is outside, but under cover.
https://zigbee.blakadder.com/Xiaomi_WXKG01LM.html
https://www.aliexpress.com/item/32825685057.html
I use a bunch of methods to coordinate the zigbee signals (including Zigbee2MQTT), but for this example I'm using a Sonoff Zigbee Bridge, flashed with Tasmota. The Bridges are around $25.
https://www.aliexpress.com/item/4000986091188.html
https://sonoff.tech/product/smart-home-security/zbbridge/
https://www.youtube.com/watch?v=dC1AEyFhmnc
=====Calculations & Output=====
Calculations were done using Node Red & some javascript. Currently it waits for the buttons to be pressed and stores variables such as time when buttons are pressed. It does some simple calculations to determine hours since feeding happened, and if a button isn't pressed it updates the status every 5 mins with a repeating injection node.
Node Red outputs values to my MQTT server and I also pull those values into Home Assistant. Home Assistant uses this to update a display I have on a touch screen.
=====Images=====
**Mi Zigbee Buttons**.
I had thought about placing them in a nice wooden panel at some stage, but at the moment they are fine stuck to the wall.
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLX8j9MyBU1QwV8AkP8hs6jjRISgRu9qP9RxP0EEoMhMBAMvvz4I1c4t8eeKksjmK2atmttYQv94DH6rEZ-zs53U_lUV2s7W7B8-d5eeOsIpDLW27c2MpvzlE5XphUzVCZo7C4V0CxKxH-7_Lhd7rJE4yQ=w1200-h901-no?authuser=0" title="text" alt="text"}}
**Button Stickers**
I designed some simple labels and a friend who runs a signage business printed me out some on vinyl.
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLUzlxS6Z_oIG5i3U7JcHFcaXdQ8UJ5JF3QCECl6AZnzgQNA4BJxgnr_aOgDdYtCD_hw8Dlls5rmeIJ1-kNviViVUnsukZ6fNVOntRJaqjpH7n-K622QSvee_RX66OvMEyT8MS0UcMGOSCvEienXQCXMZg=w600-h515-no?authuser=0" title="text" alt="text"}}
**Touch Screen Display**
The whole 19" touchscreen isn't displayed here (it is a work in progress recessed into our lounge wall) and this is the first iteration of the pet feeding display on the touch screen. It will show orange and red as the time extends out more than half a day. At the moment, it averages when the cat/dog button is pressed, but I'll account for the possibility that only one button is pressed for some reason.
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLVYV3_CzayvAIPbNitsqNKJx20mXnKZkzYLwCxS84b9smkk9m2x4SwdvvWQMsTSXJaK9SVKxvb1__4oHG7KQVifEkk00I3YfTzi6boWmaoKim_6H9TdlhPLQwKNAwbnDpMRGGlnuimzAGVXSGlrBwtGmw=w1471-h696-no?authuser=0" title="text" alt="text"}}
More notes on the touchscreen: ViewSonicTouchscreen implementation.
**Node Red Flow**
The full code is [[https://zorruno.com/wp-content/uploads/2021/09/zorruno_pet_feeding_node_red_flow_v2.json.txt here to download]]
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLVkR-xXGDo-m0KedCRgfBq-x9RC2u6eHb-DUb2s2SX6KXP5yOeXOIzjJhcMs2HCdHWIXEH7d0oWzcZrXGpShmI5c1p-cwCWP5PCU_OpwphwWJC72998Hc6pP5UzOY6kZdvEbvIotAuzkhY731pwz1uKVw=w1109-h900-no?authuser=0" title="text" alt="text"}}
**Buttons In place**
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLWQhIIZTa-wP21TYMoVi5idwE4Fize2yzDJUYGxm3AM4V2-YzpVLEKS12J4neWwbXVClGw90JdBnhz5ByKnys2MHsEVXYV1R8Sz8xWF3QVbtfdRoz2EzgjF3dH-oBu1ZJX_3Wja1k6OtpatTLAsi_rpLg=w630-h900-no?authuser=0" title="text" alt="text"}}
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLVapvV4SPcKplglq60QjoxkVw3WJ9U4ZAgJx4zOgX3MPebVSGSu2XWGEB1J4UHpahpSjcswRSgunhYpjXLwNdJ71R5IMrWmdMdwT224TIPt8JjisKr1Gv7JfcIpqwx1jXrVTKKlZcKxMDY0eKa8iFTbyQ=w635-h901-no?authuser=0" title="text" alt="text"}}
=====Future Plans/Improvements=====
-- some alarm info if it goes too long between feeds (morning and afternoon)
-- a Q/A to google home so you can ask it if the pets need feeding.
-- notifications ++using google homes and++ pushover including warnings if they haven't been fed
-- some tidyup code for the zigbee to ensure batteries get replaced and errors are caught.
I could add...
-- Snapshot image from the cameras to show who fed them (could be sent to pushover)
-- Some extra data, eg a double press of the button could indicate that the petfood is running low of something. The buttons can account for 1,2,3,4, and 'multi' press, as well as 'held' so they are being underutilised as is.
{{lastedit show="3"}}
----
CategoryHomeAutomation
CategoryMQTT
CategoryHomeAssistant
CategoryNodeRed
CategoryZigbee
CategoryPets
=====Changes=====
2021-08-30 V1 - Started Documenting
2021-09-13 V2 - Updated with notification (Outside light blink) & tidied code
2021-10-10 V3 - Now added voice notifications if not fed
=====Summary=====
A method to track whether the cat and dog have been fed in a busy household.
I think about Home Automation as being 'what things are repeated constantly by people, that don't need to', and this in our house was the question of 'Hey, has anyone fed the pets?"
The solution needed to be cheap, and simple for anyone to use. I decided to use buttons at the pet feeding station to determine when feeding happened - the family know to press once when they feed the dog, feed the cat or top up the water.
I have a touch screen display in the lounge to display results, but I am planning on adding a simple LED display ++and some voice notifications for a few 'alarm' type events, such as 'pets not fed recently'.++
**Update 13 Sep:** There were a couple of times the buttons were pressed and the zigbee coordinator picked them up, but nothing was pushed to MQTT for some reason. Also, there are times people aren't sure if they pressed the button properly. I could have given some voice/sound feedback but this isn't great for early morning feeds so I now flash the outside light when a button is pressed (either 1, 2 or 3 times depending on which button was pressed)
**Update 10 Oct:** I haven't added to the Node Red flows below, but my setup now announces over a couple of Google Home devices (one in Miss 10's room) if the peds haven't been fed in the afternoon. It starts around 4:30pm and keeps announcing every 40mins (about 5 times total) until the pets have been fed.
=====Input Method=====
I managed to get some Zigbee Mi buttons for $10 each. Zigbee is simple, and for non critical applications and in areas where running cables is a pain, so is a good solution. The feeding area is outside, but under cover.
https://zigbee.blakadder.com/Xiaomi_WXKG01LM.html
https://www.aliexpress.com/item/32825685057.html
I use a bunch of methods to coordinate the zigbee signals (including Zigbee2MQTT), but for this example I'm using a Sonoff Zigbee Bridge, flashed with Tasmota. The Bridges are around $25.
https://www.aliexpress.com/item/4000986091188.html
https://sonoff.tech/product/smart-home-security/zbbridge/
https://www.youtube.com/watch?v=dC1AEyFhmnc
=====Calculations & Output=====
Calculations were done using Node Red & some javascript. Currently it waits for the buttons to be pressed and stores variables such as time when buttons are pressed. It does some simple calculations to determine hours since feeding happened, and if a button isn't pressed it updates the status every 5 mins with a repeating injection node.
Node Red outputs values to my MQTT server and I also pull those values into Home Assistant. Home Assistant uses this to update a display I have on a touch screen.
=====Images=====
**Mi Zigbee Buttons**.
I had thought about placing them in a nice wooden panel at some stage, but at the moment they are fine stuck to the wall.
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLX8j9MyBU1QwV8AkP8hs6jjRISgRu9qP9RxP0EEoMhMBAMvvz4I1c4t8eeKksjmK2atmttYQv94DH6rEZ-zs53U_lUV2s7W7B8-d5eeOsIpDLW27c2MpvzlE5XphUzVCZo7C4V0CxKxH-7_Lhd7rJE4yQ=w1200-h901-no?authuser=0" title="text" alt="text"}}
**Button Stickers**
I designed some simple labels and a friend who runs a signage business printed me out some on vinyl.
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLUzlxS6Z_oIG5i3U7JcHFcaXdQ8UJ5JF3QCECl6AZnzgQNA4BJxgnr_aOgDdYtCD_hw8Dlls5rmeIJ1-kNviViVUnsukZ6fNVOntRJaqjpH7n-K622QSvee_RX66OvMEyT8MS0UcMGOSCvEienXQCXMZg=w600-h515-no?authuser=0" title="text" alt="text"}}
**Touch Screen Display**
The whole 19" touchscreen isn't displayed here (it is a work in progress recessed into our lounge wall) and this is the first iteration of the pet feeding display on the touch screen. It will show orange and red as the time extends out more than half a day. At the moment, it averages when the cat/dog button is pressed, but I'll account for the possibility that only one button is pressed for some reason.
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLVYV3_CzayvAIPbNitsqNKJx20mXnKZkzYLwCxS84b9smkk9m2x4SwdvvWQMsTSXJaK9SVKxvb1__4oHG7KQVifEkk00I3YfTzi6boWmaoKim_6H9TdlhPLQwKNAwbnDpMRGGlnuimzAGVXSGlrBwtGmw=w1471-h696-no?authuser=0" title="text" alt="text"}}
More notes on the touchscreen: ViewSonicTouchscreen implementation.
**Node Red Flow**
The full code is [[https://zorruno.com/wp-content/uploads/2021/09/zorruno_pet_feeding_node_red_flow_v2.json.txt here to download]]
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLVkR-xXGDo-m0KedCRgfBq-x9RC2u6eHb-DUb2s2SX6KXP5yOeXOIzjJhcMs2HCdHWIXEH7d0oWzcZrXGpShmI5c1p-cwCWP5PCU_OpwphwWJC72998Hc6pP5UzOY6kZdvEbvIotAuzkhY731pwz1uKVw=w1109-h900-no?authuser=0" title="text" alt="text"}}
**Buttons In place**
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLWQhIIZTa-wP21TYMoVi5idwE4Fize2yzDJUYGxm3AM4V2-YzpVLEKS12J4neWwbXVClGw90JdBnhz5ByKnys2MHsEVXYV1R8Sz8xWF3QVbtfdRoz2EzgjF3dH-oBu1ZJX_3Wja1k6OtpatTLAsi_rpLg=w630-h900-no?authuser=0" title="text" alt="text"}}
{{image url="https://lh3.googleusercontent.com/pw/AM-JKLVapvV4SPcKplglq60QjoxkVw3WJ9U4ZAgJx4zOgX3MPebVSGSu2XWGEB1J4UHpahpSjcswRSgunhYpjXLwNdJ71R5IMrWmdMdwT224TIPt8JjisKr1Gv7JfcIpqwx1jXrVTKKlZcKxMDY0eKa8iFTbyQ=w635-h901-no?authuser=0" title="text" alt="text"}}
=====Future Plans/Improvements=====
-- some alarm info if it goes too long between feeds (morning and afternoon)
-- a Q/A to google home so you can ask it if the pets need feeding.
-- notifications ++using google homes and++ pushover including warnings if they haven't been fed
-- some tidyup code for the zigbee to ensure batteries get replaced and errors are caught.
I could add...
-- Snapshot image from the cameras to show who fed them (could be sent to pushover)
-- Some extra data, eg a double press of the button could indicate that the petfood is running low of something. The buttons can account for 1,2,3,4, and 'multi' press, as well as 'held' so they are being underutilised as is.
{{lastedit show="3"}}
----
CategoryHomeAutomation
CategoryMQTT
CategoryHomeAssistant
CategoryNodeRed
CategoryZigbee
CategoryPets