Appdaemon call_service() results in strange HA error

I’m setting up a manual alarm component and it looks like this:

  - platform: manual
    name: Home Alarm
    code: !secret alarm_code
    pending_time: 30
    delay_time: 20
    trigger_time: 4
      trigger_time: 0
      pending_time: 0
      delay_time: 0
      pending_time: 0
      delay_time: 0

In my appdaemon python script, I make the folliwing call:

    self.call_service('alarm_control_panel/alarm_arm_night', entity_id='alarm_control_panel.home_alarm', code='1234')

This results in the following error in HA:

2018-06-15 20:58:29 WARNING (MainThread) [homeassistant.core] Unable to find service sensor/turn_off

To me, it appears that the appdaemon call references a sensor domain rather than an alarm domain when the call is made. Is this something I’m doing wrong?

I have just tried out your configuration, but I can’t replicate your results. The service seems to be called correctly.

Perhaps you could paste more of your app, so I could get a closer test to what you are attempting.

You also might get more help if you moved the thread to the appdaemon category.

Thanks for the reply. I didn’t know that there was a dedicated appdaemon category. I don’t see it in the pull-down list. How do I transfer this topic over there?

In the meantime, here is the bulk of the script where I’m having problems:

import appdaemon.plugins.hass.hassapi as hass
import datetime

upstairs_sleeping_temp = 72
upstairs_waking_temp = 73
downstairs_sleeping_temp = 75
downstairs_waking_temp = 74

class Scenes(hass.Hass):

  def initialize(self):
    self.listen_event(self.scene_activated, event='call_service', domain='scene', service='turn_on')

  def scene_activated(self, event_name, data, kwargs):
    if data['service'] == 'turn_on':
      # A scene was activated; check to see which one
      if data['service_data']['entity_id'] == 'scene.bedtime':
      elif data['service_data']['entity_id'] == 'scene.good_night':
      elif data['service_data']['entity_id'] == 'scene.good_morning':
        self.log("__module__:__function__() Unhandled scene activation.  Scene was {}". format(data['service_data']['entity_id']))

  def bedtime(self):
    Set up everything for moving up to the bedroom.
    self.call_service('climate/set_temperature', entity_id='climate.downstairs', temperature=downstairs_sleeping_temp)
    self.call_service('alarm_control_panel/alarm_arm_night', entity_id='alarm_control_panel.home_alarm', code='1234'

I’m testing for which scene was activated manually because I could never figure out how to select a scene in the listen_event() call. There is a thread on this forum where Rene tried to help me. No matter what parameters I specified, ANY scene activation would trigger ALL callbacks that listen for

event='call_service', domain='scene'

Also, I’m running appdaemon 3.0.0 and HASS 0.70.1.

There was a change to listen_event in v3.0.1, so I would take the time to upgrade to that, before doing anything else.

I updated to 3.0.1 and tried it again. Got the same error:

Tue Jun 19 2018 12:17:11 GMT-0500 (Central Daylight Time)

Unable to find service sensor/turn_off

Could it make sense to turn on debug logging in HASS and see if there is any additional information in HASS or is there more to learn from appdaemon?

I have just tried these service calls from a listen_event callback, and I don’t see any errors.

Are you sure it is actually hitting this piece of code rather than something else?

Adding some debug to HA to confirm the correct event is being sent would certainly help, as would some log output in your app.