hassio-addons / addon-firefly-iii

Firefly-III - Home Assistant Community Add-ons
https://addons.community
MIT License
17 stars 11 forks source link

Recurring transactions & automatic budgets do not get triggered #11

Closed marecabo closed 4 years ago

marecabo commented 4 years ago

Problem/Motivation

Certain features of Firefly III (like recurring transactions and automatic budgets) require a daily cron job.

See https://docs.firefly-iii.org/advanced-installation/cron

Expected behavior

It would be great, if this add-on would contain a mechanism to trigger the creation of recurring transactions / rollover of automatic budgets by itself.

Actual behavior

Recurring transactions do not get created on their designated dates. Automatic budgets do not roll over.

Steps to reproduce

Create a recurring transaction and observe it not getting created on its designated day.

External Workaround

  1. Create a personal access token at http://your-ha-ip:3473/profile and put it into your secrets.yaml
  2. Setup the following automation, adapt it whether you use SSL or not

    configuration.yaml

    shell_command:
      firefly_cron: "/usr/bin/curl -X GET http://localhost:3473/cron/run/{{access_token}}"
    #  firefly_cron_ssl: "/usr/bin/curl -X GET https://localhost:3473/cron/run/{{access_token}} --insecure"

    automations.yaml

    - alias: 'Firefly III Cron Job'
      description: 'Creates recurrent transactions in Firefly III'
      trigger:
        - platform: time
          at: "00:00:01"
      action:
        - service: shell_command.firefly_cron
          data:
            access_token: !secret firefly_access_token
    #     - service: shell_command.firefly_cron_ssl
    #       data:
    #         access_token: !secret firefly_access_token

Proposed changes

Would it fit into the add-on architecture to add cron to the add-on with a crontab as proposed in the Firefly III documentation?

# cron job for Firefly III (daily at 00:01)
1 0 * * * /usr/bin/php /var/www/firefly-iii/artisan firefly-iii:cron
sinclairpaul commented 4 years ago

HA supports automations, which I believe you should be able to use a REST command https://www.home-assistant.io/integrations/rest_command/

Is there any reason that wouldn't do it?

Home Assistant
RESTful Command
Instructions on how to integrate REST commands into Home Assistant.
marecabo commented 4 years ago

Ah, I should have been clearer, that there are two ways in Firefly how to trigger recurring transactions:

In the workaround, I was using the latter and I think, using a REST service would just replace the curl command but also not remove the necessity to write some automation outside of the add-on to get these Firefly features to work.

In general, I would prefer to not need an automation in HA, but the add-on to be self-sufficient, so I'd suggest to implement the cron job solution inside the addon. If you are fine with that, I will attempt to implement it, but let me know what you think.

sinclairpaul commented 4 years ago

Sorry, I don't think adding the cron option is worth the effort. It will raise issues around configuration (i.e. when to run, and dealing with UTC) and troubleshooting (how to tell its working). I don't see using an automation in HA as a workaround, as the addon can only run on a Home Assistant instance, and it would be far easier for the user to configure the task there.

Thanks for the input though 👍

addons-assistant[bot] commented 4 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.