Set state of Homematic switch (HM-LC-Sw1-Pl-DN-R1)

I am currently trying to control a switchable plug from Homematic (HM-LC-Sw1-Pl-DN-R1) via the python_scripts integration:

switchable_plug = data.get("eid_switchable_plug", "")

sp = hass.states.get(switchable_plug)
state = sp.state

if state == "off":
    hass.states.set(switchable_plug, "on")
elif state == "on":
    logger.info("Switch is on")
else:
    logger.info(state)

However, only the state in the frontend changes, but not on the plug itself.

What am I missing here?

Thanks for your help in advance!

I have found the solution myself. Of course, I don’t need to set the state, but turn on the switch:

switchable_plug = data.get("eid_switchable_plug", "")
sp = hass.states.get(switchable_plug)
state = sp.state


if state == "off":
    hass.services.call("switch", "turn_on", { 'entity_id': switchable_plug })
elif state == "on":
    logger.info("Switch is on")
else:
    logger.info(state)