Can't Register Services But Can Subscribe To Them (ESP Home Native API)

I’m either having a mental block or doing something wrong. I’m prepping for a project on ESP home so I am just running through some features that I will need which include both subscribing and registering services. I’ve created a test component that inherits public CustomAPIDevice. I have no issue subscribing to a service.

I cannot get a registered service on the ESP board to appear in HA. From what little documentation I can find, the register_service call should take care of everything and it should show up in the entity in HA.

 void setup() override {
    // This will be called by App.setup()
    register_service(&HotTub::on_hello_world, "hello_world");
    subscribe_homeassistant_state(&HotTub::on_state_changed, "switch.window_fan");
  }

on_state_changed works fine, hello_world never appears in HA.

  void on_state_changed(std::string state)
  {
    ESP_LOGD("custom", "Window fan state changed");
  }
  
  void on_hello_world() {
    ESP_LOGD("custom", "Hello World!");
  } 

I assume you are writing a custom component and thus calling the api service in code rather than yaml?

The devs may be better to ask - find them on Discord:

Yes this is going to be a highly customized component.

There was a breaking change not long ago which makes it necessary for new esphome (node) integrations to manually allow service calls :point_down:

1 Like

Thank you so much for the information, I honestly would have never found that. So my takeaway is that somewhere I either need to define “allow_service_calls” or allow_service_calls: True? I have no idea where though. I would assume in the yaml for that specific ESP device. Is there any documentation to go with this change?

you have to tick a box in the device config page for the integration

Ok this has unveiled some new information. My version of HA was old enough that the option didnt exist. I updated to the latest and now I see the option “Allow the device to make Home Assistant service calls”. Since I set up the ESP home on the old HA version this box was already checked. That makes sense since the breaking change mentions that it only applies on new devices going forward.

So I guess this brings me back to my original question of how to get registered services to show up in HA. The breaking change seems to have not been relevant.

Developer Tools > Services :point_left:

If you start type esphome into the box only esphome services will show :raised_hands:

I’m still lost here, where in the Esphome integration did you find this option ?

I have a new test device using Esphome 2023.7.1 and it is configured in HAOS 2023.8.1 and can’t find it.

Once you have the latest HA. Its in setting → devices & services → ESP home → configure

Thanks, I was going too far and clicking on the 3 dots and going to system options