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

Setup

Updated on 11/17/19 for v0.101.3

Please refer to this page: https://github.com/Fusion/pywhistle/tree/master/examples/homeassistant

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.

2 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):
[email protected]:~# 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
[email protected]:~#

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.

[email protected]:/# 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