strautomator / core

Strautomator Core
MIT License
41 stars 5 forks source link

I have to set End time -1 hr for the automation to trigger correctly #42

Closed OleksiyRudenko closed 9 months ago

OleksiyRudenko commented 10 months ago

Thank you for the great tool with great value at great price.

I have the following automation defined:

{
    "conditions": [
        {
            "property": "weekday",
            "value": "1,2,3,4,5",
            "operator": "=",
            "friendlyValue": "Monday or Tuesday or Wednesday or Thursday or Friday"
        },
        {
            "property": "dateEnd",
            "value": 30600,
            "operator": ">",
            "friendlyValue": "08:30"
        },
        {
            "property": "dateEnd",
            "value": 63000,
            "operator": "<",
            "friendlyValue": "17:30"
        }
    ],
    "actions": [
        {
            "type": "prependName",
            "value": "Active break "
        }
    ]
}

What I actually wanted is to have the automation triggered on activity end time between 9:30 and 18:30. Had to subtract 1 hr in conditions for the trigger to work within expected time range. Not sure if it is a bug or a user is expected to define the time as if they were in UTC TZ.

P.S. Great UX. Defining automations is intuitively clear. I realized the benefits just after setting two automations. Was able to discard another single job Strava App. --- Yours sincerely happy subscriber.

The only UX thing I'd suggest is that Logical operators section followed the Conditions sections immediately if not come first. There must be a reason it follows Actions for, but lmk if you want me to submit a proposal as an issue here.

igoramadas commented 10 months ago

First of all, thanks for the great feedback, really appreciate it :-)

User facing input always expects local timezones, as some people won't even know what UTC means. I will investigate it tonight and update this issue with my findings ok?

igoramadas commented 10 months ago

Hi @OleksiyRudenko can you please give me your Strava account ID? I made some tests with random timezones and could not find any issues. I'll have to check the logs specifically for your account and see what Strava is returning there.

OleksiyRudenko commented 10 months ago

Hi @igoramadas, thank you for looking into this. My acc is https://www.strava.com/athletes/121765792

This activity ended before 9:30 my local time (according to the info available to me - 8:09 started + 41'30" elapsed time, moving time was 25'41"): https://www.strava.com/activities/10134503463 I had to adjust this recipe https://strautomator.com/automations/edit?id=r6540cbb4 conditions and re-run automation manually to have the expected effect (meaning actions are not applied).

        {
            "property": "dateEnd",
            "value": 30600,
            "operator": ">",
            "friendlyValue": "08:30" // originally, this was set to 9:30
        }

Hope the above helps.

Upd 11:12 UTC: Apologies for any confusion due to the inital content of this message.

Upd: So, I expected the automation above to trigger between 9:30 and 18:30 my local time prepending the activity name with a specified prefix. One of the activities ended before 9:30, yet the recipe has been triggered and actions taken. I changed the endTime in the recipe, have manually re-run automations and the result was as expected (the activity name was reset with a different automation and automation in question didn't add anything, just as expected). I tried to reproduce this now by changing endTime to 9:30 and actions of this automation were not applied, as expected. I changed back to 8:30 and they again were not applied (however, should have been if respected, as end time for this activity definitely falls into 8:30-17:30 range). I am confused now myself and probably confused you. My apologies for this. I might have really missed something important or simply misusing the tool. I will revert to you with a more consistent test and accurate steps to reproduce if any issues arise.

OleksiyRudenko commented 10 months ago

hi @igoramadas , I guess I caught it redhanded :)

This activity started at 18:33 and ended at 19:00 my local time (CET).

This automation triggering conditions are: If ALL these conditions are met:

I wouldn't expect it being triggered, but it was. Please correct me if I am wrong.

igoramadas commented 10 months ago

Ah pesky little bug, I found you: https://github.com/strautomator/core/blob/master/src/recipes/conditions.ts#L195

The timezone offset is being added for the activity starting time, but not the end time. Will be fixed and deployed on the weekend ok?

Once again, thanks for the report!

github-actions[bot] commented 9 months ago

Issue flagged as stale for being inactive for 28 days, please report status if this is still relevant.

github-actions[bot] commented 9 months ago

Issue closed due to inactivity, feel free to update and re-open it if necessary.