Issue with proximity-based AppDaemon app

Edit: Problem solved. Was calling the wrong service. Once again, AppDaemon wins. :laughing:

Hello all – I’m working on an app that uses the HASS Proximity component. Although the listeners are working correctly, the service call doesn’t disable “away mode” on my thermostat.

class SomeoneComesHome(appapi.AppDaemon):
    """Define a class to represent the app."""

PROXIMITY_THRESHOLD = 3

def initialize(self):
    """Initialize."""
    self.active = False
    self.listen_state(self.proximity_cb, 'proximity.home')

def proximity_cb(self, entity, attribute, old, new, kwargs):
    """Perform "coming home" actions """
    if new == 'not set':
        return

    if self.active and int(new) >= self.PROXIMITY_THRESHOLD:
        self.log('Far enough away - resetting')
        self.active = False

    if not self.active and int(new) < self.PROXIMITY_THRESHOLD:
        self.log('Within geofence - activating')
        self.call_service(
            'climate/set_away_mode',
            entity_id='climate/thermostat',
            away_mode='false')
        self.active = True

Calling the same service from HASS itself works as expected:

2 Likes