Disable iphone polling if detected home via another method

Regarding icloud_set_interval, how does it work? I find the documentation unclear. Interval isn’t specified as a parameter in any of the services for iCloud in the documentation. Presumably, under the hood, some of them take it. It feels like you’re saying that I have to call this every time I make a call to a service, and that it resets occasionally in situations that are beyond my control. Basically, my phone is dying within hours every day, and it feels like I should be able to fix this with a global change to the polling interval, but that is not available to me.

You could have an automation set to always put the interval at a certain time no matter what. Is that what you are looking to do?

That would probably work. To give some more context, I am using the icloud component for the icloud_lost_iphone service, which doesn’t require polling the device location. I think that long term, the iCloud component should not be a device_tracker. Device tracking is one of the things that the icloud component can do, but not all of the services require polling the location of the phone. And in practice, the default polling scheme is unusable for me, since it takes my battery to zero in a few hours.

I also think that there could be a better polling strategy which, for example, increases the polling interval a little if you haven’t moved toward a known zone since the last poll was taken, capping off at 30 minutes or something.

Finally, a simple first step would be to allow an option to disable polling or set a global, constant, polling interval.

could you also set track to no in the known devices? or does that disable the lost iphone service as well?

Here is an automation that will set it back to something if it changes. I wonder if you set it to 0 if that disabled updates?

- alias: Icloud set_interval to 60
  trigger:
    platform: template
    value_template: '{{states.device_tracker.ryaniphone.attributes.interval != 60 }}'
  action:
    - service: device_tracker.icloud_set_interval
      data:
        interval: 60

I set mine to 0 and it appears to disabled updates but only because there is a bug in the code to handle 0. So now my error log is filling up.

2017-09-29 16:14:44 ERROR (Thread-7) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/icloud.py", line 313, in keep_alive
    if ((currentminutes % interval == 0) or
ZeroDivisionError: integer division or modulo by zero

Thank you for your help, that is very kind of you!

I want the same, just to use the icloud_lost_iphone service to trigger some notifications, but no device location. How could I deactivate it?

I ended up using pyicloud to write a web service that connects to iCloud, triggers the find my iphone sound, and closes.