Self.run_in for a service

HI,
my alexa dots need some time delay before calling a service.
time.sleep(2) works but is the whole framework alerts that…

self.run_in(self.call_service , 2 , "media_player/volume_set", entity_id = "media_player.marc", volume_level = 0.2)

Here I am in a pity situation:

The self.run_in takes 3 arguments:

  • the methodname for callback
  • the time 2 secs
  • and **kwargs

The unhappy self.call_service

forces me to use 1 positional argument with the service name…

  • service name (unnamed!!!)
  • named entity
  • named volume_level

So how to callback a service if this expects to a positional argument as well… do not tell me I need a wrapper method that is called back and feeds the service…do I ?
That would be sooooo odd

Regards Marc

def service_wrapper(self, **kwargs):
        service = kwargs.get("service")
        entity_id = kwargs.get("entity_id")
        volume_level=kwargs.get("volume_level")
        self.call_service(service, entity_id = entity_id, volume_level = volume_level)

This works but hey… I can’t be the first one trying to delay a build in service_call()

What do I miss?

Marc