TemplateError('UndefinedError: 'state' is undefined') while processing template 'Template("{% if state('cover.shutter_malte_window', 'open')

Hi,
I use an api from mygekko to control my covers. Its works fine but I want to get ride of the errors in my log:

Template variable error: 'state' is undefined when rendering '{% if state('cover.shutter_tim_window', 'open') %} mdi:blinds-open {% else %} mdi:blinds {% endif %}'

my code is:

sensor:
  - platform: rest
    name: mygekko_rollos
    resource: http://192.168.178.33/api/v1/var/blinds/status
    username: admin
    password: xxxxx
    authentication: basic
    json_attributes:
      - item0
      - item1
      - item2
      - item3
      - item4
      - item5
      - item6
      - item7
      - item8
      - item9
      - item10
      - item11
    value_template: "OK"
    scan_interval: 1
  - platform: rest
    name: mygekko_temps
    resource: http://192.168.178.33/api/v1/var/roomtemps
    username: admin
    password: xxx
    authentication: basic
    json_attributes:
      - item0
      - item1
      - item2
      - item3
      - item4
      - item5
      - item7
      - item8
    value_template: "OK"
    scan_interval: 1
  - platform: template
    sensors:
      test_temperature:
        device_class: temperature
        unit_of_measurement: "°C"
        value_template: >-
         '{{ states.sensor.mygekko_temps.attributes["item7"]["sumstate"]["value"].split(";")[1] }}'

shell_command:
  shutter_up:        "curl 'http://192.168.178.33/api/v1/var/blinds/item{{ device_id }}/scmd/set?value=1&username=admin&password=xxx'"
  shutter_down:      "curl 'http://192.168.178.33/api/v1/var/blinds/item{{ device_id }}/scmd/set?value=-1&username=admin&password=xxx'"
  shutter_stop:      "curl 'http://192.168.178.33/api/v1/var/blinds/item{{ device_id }}/scmd/set?value=0&username=admin&password=xxxxx"
  shutter_position:  "curl 'http://192.168.178.33/api/v1/var/blinds/item{{ device_id }}/scmd/set?value=P{{ position }}&username=admin&password=xxx'"
  change_temp:       "curl 'http://192.168.178.33/api/v1/var/roomtemps/item7/scmd/set?value=K%2$s&username=admin&password=xxxxx'"

cover:
  - platform: template
    covers:
      shutter_tim_window:
        friendly_name: "Timfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item8"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 8
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 8
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 8
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 8
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if state('cover.shutter_tim_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}

what I’m doing wrong?

you need to use is_state instead of state in that template.

thx that was it.