Restful API URL

Hi All,

I am using two teckin sp22 Powerplug with homeassistant and esphome to control them.

Now these two devices have one button included. i want to use the button to turn the other plug on or off.
As i got told the only way to switch a plug from another plug is over MQTT or RestFULL API.

Here is how i imagine to switch the device via HTTP API command

In the plug1.yaml i include the following sensor:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO1
      inverted: True
    name: "${plug_name}_button"
    on_press:
      then:
       - url: "https://homeassitant/api/services/homeassistant/toggle/{“entity_id”:“switch.p1_relay”}?api_password=myapipass"

but that url doesent work. if i try it in the browser i get the message: 405: Method Not Allowed

If i do a test with the homeassistant dev tools the switch toggles.

has anyone an idea how the url should look like ?

You can’t use api_password any more

if i try https://homeassistant/api/ i get 401: Unauthorized
if i try https://homeassistant/api/?api_password=myapipass i get message “API running.”
i use Home Assistant Version 0.88.2

Yeah, if you upgrade to 90 or 91, you will not be able to use it

ok and what can i use instead of api_password?

Long lived token

i found another solution

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO1
      inverted: True
    name: "${plug_name}_button"
    on_press:
      then:
        - homeassistant.service:
            service: homeassistant.toggle
            data:
              entity_id: switch.p2_relay