Toggle Opnsense Unbound Blacklist from HA

!!!Deprecated!!!
The API of Opnsense has changed. This doesn’t work any more.

I wanted to be able to toggle the blacklist function of Unbound in Opnsense from Home Assistant. The reason is simple: TVNow (a German TV streaming service) doesn’t work with my blacklists and I still haven’t figured out what all to whitelist for it to work. Logging into my OpnSense takes longer than simply clicking a switch in Home Assistant. I wanted to use the Restful Switch, but for the state I have to use GET and for changing the state I have to use POST with different URLs. I didn’t work for me, but maybe somebody can help me out there.
The button:
grafik
It toggles the blacklist function on of of.

My configuration:

switch:
  - platform: template
    switches:
      unbound:
        friendly_name: 'Unbound'
        value_template: "{{ is_state('sensor.unbound_status', '1') }}"
        turn_on:
          service: rest_command.enable_unbound
        turn_off:
          service: rest_command.disable_unbound

rest_command:
  enable_unbound:
    url: https://router/api/unbound/dnsbl/set
    method: post
    content_type:  'application/json; charset=utf-8'
    username: 'key'
    password: 'secret'
    payload: '{"dnsbl":{"enabled":"1"}}'
  disable_unbound:
    url: https://router/api/unbound/dnsbl/set
    method: post
    content_type:  'application/json; charset=utf-8'
    username: 'key'
    password: 'secret'
    payload: '{"dnsbl":{"enabled":"0"}}'

sensor:

  - platform: rest
    resource: https://router/api/unbound/dnsbl/get
    name: 'Unbound Status'
    value_template: '{{ value_json.dnsbl.enabled }}'
    username: 'key'
    password: 'secret'
    authentication: basic

Pressing the button immediately turns the black list on or of, but it takes a second for the sensor to register the new state