Variable not working from automation but in development console

Hi Forum!

I ran into a rather strange error where I’m completely out of my league - maybe somebody can help. I used to run a old installation of hass.io which is now completely outdate (over a year) and I decided to start fresh. (direct installation in docker etc.)

I used and would like to use again the great variables by @rogro82 (https://github.com/rogro82/hass-variables) This worked in the old installation. Now I try to rerun my old automation but i cant get it to work.

I have a rather simple counter which is increased each night (for a notification to change my water filter)

The following (test) section in my configuration.yaml works (turnes on the light) but does not increment the counter.

variable:
  bfilter:
    value: 42
    #restore: true
    attributes:
      icon: mdi:filter
      friendly_name: "Brittafilter Alter"

automation:
  - alias: Test_auto
    description: ''
    trigger:
      - device_id: 94d39c5b36b862bf2d0995f1d6a3ce04
        domain: deconz
        platform: device
        type: remote_button_short_press
        subtype: turn_on
    condition: []
    action:
      - type: turn_on
        device_id: 6ba48e9a23a7a8f779f835b17808228d
        entity_id: light.tf_lab_status
        domain: light
        brightness_pct: 90
      - service: variable.set_variable
        data:
          variable: "bfilter"
          value_template: '{{ (variable.state | int) + 1 }}'
    mode: single

running the same stuff in the development tool works!
grafik

(it increments the variable)

Executing the automation yields the following execptions:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 144, in async_prepare_call_from_config
    service_data.update(template.render_complex(config[conf], variables))
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 91, in render_complex
    return {
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 92, in <dictcomp>
    render_complex(key, variables): render_complex(item, variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 96, in render_complex
    return value.async_render(variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 353, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'variable' is undefined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 433, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1010, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 245, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 253, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 432, in _async_call_service_step
    domain, service, service_data = async_prepare_call_from_config(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 146, in async_prepare_call_from_config
    raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'variable' is undefined

Anybody a idea what I’m doing wrong?

see here for the fix: