Creating switch to turn on/off d-link DSP-W118 via Google Assistant

So im trying to make a switch to turn on and off a DSP-W118 going trough Google assistant.
In switch.yaml

test:
        value_template: "{{ is_state_attr('switch.test', 'sensor_state', 'on') }}"
        turn_on:
          service: rest_command.assistant_relay
          data:
            command: turn on test
            entity_id: switch.test
            from: 'off'
            to: 'on'
        turn_off:
          service: rest_command.assistant_relay
          data:
            command: turn off test
            entity_id: switch.test
            from: 'on'
            to: 'off'

In configuration.yaml

test_activity:
        friendly_name: test
        value_template: >
          {% if is_state("switch.test", 'on') %}
            {{ states.switch.test.attributes.current_activity }}
          {% else %}
            Off
          {% endif %}

This i have taken from my Logitech remote setup. The main problem is that the switch does not change state. When the first command is sendt it turns the ligth on, but the lovelace card returns to off. If i go to “developer” tool and changed the state of the switch_test to on, i can go back into lovelace, see that the switch now is on, and then trigger it, and my DSP-W118 goes off.

Was making this too hard…
SOLVED :

    spotlys:
      turn_on:
        service: rest_command.assistant_relay
        data:
          command: turn on spotlys
      turn_off:
        service: rest_command.assistant_relay
        data:
          command: turn off spotlys
1 Like

Hi, I also have two 118 smart plugs, and so far this is the only post i found mentioning that can be used for something. I triednto added it, and is added but not possible to turn on/off at all (HA said the device is not available). Could you please guide me to what is needed to make it work? At least without Google assistant active. Thanks in advance