Here is my code where ${remote_id} is my entity in Home Assistant.
binary_sensor:
- platform: gpio # DEFINE ESP External On/Off button
name: ${esp_id} ON/OFF Button
id: s1
pin:
number: D7
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 20ms # debouncing
on_press:
- logger.log:
format: "${esp_id} ON/OFF Button : ON "
level: INFO
- homeassistant.service:
service: switch.turn_on
data:
entity_id: ${remote_entity}
I receive an error message in the log
Dev D1mini-06: Service call switch.turn_on: with data {'entity_id': 'switch.lampe_salon'} rejected; If you trust this device and want to allow access for it to make Home Assistant service calls, you can enable this functionality in the options flow
I cannot find anything about this rejection and how to avoid it in the ESPHome documentation homeassistant.service
Action.
I found a way around it, using NodeRed I can call the service when Home Assistant identify that the button has been press.
However, I would prefer a direct service call to HA directly to eliminate on extra layer of processing (NodeRed) and simplify the maintenance.
Does it have to do with API encryption, mi connection is not encrytped.