So I trying to set up a service call for a custom component I am working on, it appears in the list of services as and extension of the root DOMAIN service but every time I call it it just says failed to call service, and never executes the function even with the json {“ssid”:“ssid”,“password”:“password”,“sectype”:1} in the service call , any idea what I am doing wrong, any help is appreciated ?
This is and example of my code
CONF_WIFI_SSID = "ssid"
CONF_WIFI_PASSWORD ="password"
CONF_WIFI_SECTYPE = "sectype"
SERVICE_SET_WIFI = "test.config_wifi"
SET_WIFI_SCHEMA = vol.Schema({
vol.Required(CONF_WIFI_SSID): cv.string,
vol.Required(CONF_WIFI_PASSWORD): cv.string,
vol.Required(CONF_WIFI_SECTYPE): cv.positive_int,
})
async def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
async def async_set_test_wifi(call):
ssid = call.data.get(CONF_WIFI_SSID)
password = call.data.get(CONF_WIFI_PASSWORD)
sectype = call.data.get(CONF_WIFI_SECTYPE)
_LOGGER.error("%s,%s,%s",ssid,password,sectype)
return True
hass.data[DOMAIN].async_register_entity_service(
SERVICE_SET_WIFI, SET_WIFI_SCHEMA,
async_set_test_wifi
)