Whistle V3 API

About this Component

Whistle is a gadget you attach to your dog’s collar and it tracks exercise and location (GPS)

Previous versions had a web interface so it was pretty easy to figure out what the API was like. Version 3, though, only works with Whistle’s mobile apps.

No problem: after a bit of sniffing, I created a Python package that consumes this API (Pypi package)

I can now display my dog’s status in Home Assistant, using a custom component: Source Code

v1.1.1 (July '21)

New version: 1.1.1 – thanks to Josh and Robert! (joshvazquez · GitHub RobertD502 · GitHub)

  • Daily stats and better install linking

Setup

Updated on 11/17/19 for v0.101.3

Please refer to this page: pywhistle/examples/homeassistant at master · Fusion/pywhistle · GitHub

Note that an additional attribute is supported: entity_picture which can be used to match one of the Whistle service’s picture sizes (default: 60x60) – I am not sure how to use this one right now and I am using a gravatar instead to display my dog’s picture, in the view itself.

If you look at the Pypy source file you will see that the library can retrieve much more information. I have not figured out what would make sense to integrate in HA, yet, beyond device location, so let me know if you have suggestions.

5 Likes

Update: I have now updated the homeassistant tracker to support activity-related summary data.

So, how do we use this with Lovelace?

In configuration.yaml you can create a few templates (yes, I have a dog named Charlie):

  - platform: template
    sensors:
      charlie_goal_minutes:
        friendly_name: "Activity Goal"
        icon_template: mdi:trophy-outline
        value_template: '{{ state_attr("device_tracker.whistle_charlie", "activity_goal") }}'
        unit_of_measurement: "minutes"
      charlie_goal_streak:
        friendly_name: "Activity Streak"
        icon_template: mdi:chart-timeline
        value_template: '{{ state_attr("device_tracker.whistle_charlie", "activity_streak") }}'
        unit_of_measurement: "days"
      charlie_active_minutes:
        friendly_name: "Active For"
        icon_template: mdi:dog-side
        value_template: '{{ state_attr("device_tracker.whistle_charlie", "activity_minutes_active") }}'
        unit_of_measurement: "minutes"
      charlie_rest_minutes:
        friendly_name: "Rest For"
        icon_template: mdi:sleep
        value_template: '{{ state_attr("device_tracker.whistle_charlie", "activity_minutes_rest") }}'
        unit_of_measurement: "minutes"
      charlie_battery_level:
        friendly_name: "Battery Level"
        icon_template: mdi:battery
        value_template: '{{ state_attr("device_tracker.whistle_charlie", "battery_level") }}'
        unit_of_measurement: '%'

In ui-lovelace.yaml I am using the awesome fold-entity-row card to make this data available, but not in your face:

              - type: custom:fold-entity-row
                head: device_tracker.whistle_charlie
                items:
                  - sensor.charlie_battery_level
                  - sensor.charlie_goal_minutes
                  - sensor.charlie_goal_streak
                  - sensor.charlie_active_minutes
                  - sensor.charlie_rest_minutes

Here is the end result:

Charlie

3 Likes

Just want to chime in to say that this is a great project, and it has worked flawlessly for me. Thanks for your work!

1 Like

signed up for the forums just to offer thanks! this is great!

One question - where exactly does one put the templates? I keep getting a config error when I try and use it.

1 Like

sensor.yaml file

bummer, didn’t work. I created that file, didn’t get any errors, but still don’t see the sensors available.

This is amazing! My dog does not run, but she’ll feel free to wander given the opportunity. The Whistle 3 has afforded us peace of mind for nearly 2 years. I’ve asked the company via email to allow access to the API, with no response, so I really appreciate the work by @Fusion and hope that this can evolve into a very useful project.

Unfortunately, I’m not able to get this working. I’ve installed pywhistle via pip:

% pip install pywhistle

And put whistle.py at

/home/homeassistant/.homeassistant/custom_components/device_tracker/whistle.py

My configuration.yaml contains:

device_tracker:
  - platform: whistle
    username: !secret whistle_username
    password: !secret whistle_password
    monitored_variables:
      - WHISTLE

But I get this error message when trying to use the platform:

Integration whistle not found when trying to verify its device_tracker platform.

Any thoughts? And thanks again!

I suspect this has to do with some breaking changes in HA. I am still running 83.3 but googling similar errors I am seeing references to similar issues with other components in releases >= 89

I will try an upgrade and see how well/poorly things shake out.

Any luck @Fusion? I’ve attempted to call the service and was able to obtain an access token, but not able to access /pets (404) or anything else.

Chiming in to say that I’d be more than happy to chip in on a bounty or beer fund for an updated version :slight_smile: - broke for me when I went from .85 to .95

I just upgraded to the latest version. I am trying to figure out the changes now.

It’s ready!

Now with its own README, too.

Nice! How can we buy you a beer/coffee?
everything is working for me - including the templates. Really nice work! thanks Chris!

Eh… no need.

On the other hand, if anyone has any idea how I could get a discount on a replacement Whistle device…my stupid dogs keep trying to catch a skunk and, not too surprisingly, the device doesn’t seem to enjoy being regularly bathed in sulfur!

Thanks for a great addition to Home Assistant. I recently setup a new instance and I’m running into an issue. After cloning from Github and adding to my sensors.yaml I get the following in my logs. I’m new to Python and I’m not even sure where to start looking.

2019-08-13 20:23:32 ERROR (MainThread) [homeassistant.config] Failed to get platform sensor.whistle
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/config.py", line 795, in async_process_component_config
    platform = p_integration.get_platform(domain)
  File "/usr/src/app/homeassistant/loader.py", line 235, in get_platform
    "{}.{}".format(self.pkg_path, platform_name)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_components.whistle.sensor'

Hi Brandon, not much information to go on in that trace, but I am sure we can figure it out (eventually)

Couple questions for now:

  • What version of HA are you running?
  • Does your file hierarchy look like this (if you have a pycache feel free to ignore it):
root@96d39c7309b1:~# ls -lR .homeassistant/custom_components/whistle
.homeassistant/custom_components/whistle:
total 16
-rw-r--r-- 1 root root   31 Jul 26 04:40 __init__.py
-rw-r--r-- 1 root root 3479 Jul 26 04:20 device_tracker.py
-rw-r--r-- 1 root root  268 Jul 26 04:39 manifest.json
root@96d39c7309b1:~#

Hey Chris, I was hoping for more information in the trace as well but that’s all I could find. To answer your questions I’m running 0.97.2 in a Docker container. My hierarchy does match.

root@docker:/# ls -lR /config/custom_components/whistle
/config/custom_components/whistle:
total 20
-rw-r--r-- 1 root root 3071 Aug 13 19:59 README.md
-rw-r--r-- 1 root root   31 Aug 13 19:59 __init__.py
drwxr-xr-x 2 root root 4096 Aug 13 20:03 __pycache__
-rw-r--r-- 1 root root 3478 Aug 13 20:25 device_tracker.py
-rw-r--r-- 1 root root  268 Aug 13 19:59 manifest.json

Firstly - I just want to say that this plugin is freaking amazing. My partner has no interest in home automation but even she couldn’t help but be impressed to see our dogs activity in HA. I would be delighted to chip in to a fund or buy you a virtual coffee for your work on this.

I was wondering how I could track “Last walked…” based on the Away status. Has anyone done this? It would be cool to not only have alerts for “if doggo has not been walked for n hours” but also to be able to show that in the status board.

(If whistle is listening - this API is far more valuable to me than the GPS monitoring features!)

I just put this on my HA and I have to say - I love it. I have two dogs and I love to track their daily activity to see who is getting more and when.

If you set up the dog as a known device, you can copy the URL that comes from the base integration data and it will automatically pick up the image of whatever you have stored in the Whistle profile!

Now I just wish that I could somehow re-direct the account to connect to the beta test tracker that I have been using for one of my dogs.

Thanks again for the work on this - I love it.

Technically - if you are tracking your presence from your cell phone, coupled together with tracking presence of your dog from Whistle, you could set up a group in your groups.yaml where it determines if you are both away from the house. Then you could build an automation that would trigger based on the status of the group (which is saying you are away from the house together) and do something. Then you can build another automation that tracks and triggers based on how long it has been since the “Group” was away, and send an alert like your quote above. Pretty easy I would think, and can be done in HA with the groups and automation capabilities. You could even have HA track how many walks occur over time…

Hope this helps.

Michael