I am trying to call an API from my sensor, thus I need to use requests.post() function and add payload to it. I get an error if I call the function straight and the error description tells me to use async_add_executor_job(), but I cannot find the correct way to add the payload. Tried to use a dict, but it didn’t work for me.
@jugla
Add them as parameters ie:
async_add_executor_job(self.func, param1, param2, param3, etc)
but this way I would need give all parameters and I would not be able to skip some of the optional ones
Then do something like this with partial:
from functools import partial
f_kwargs = {}
f_kwargs["param1"] = value
f_kwargs["param2"] = value
result = await self.hass.async_add_executor_job(
partial(func, **f_kwargs)
)