michielpost / Q42.HueApi

C# helper library to talk to the Philips Hue bridge
MIT License
411 stars 114 forks source link

Schedules - Recurring Days #150

Closed Deery5000 closed 6 years ago

Deery5000 commented 6 years ago

Hi,

Im working with Schedules and I believe ive hit a bug

I can create a schedule when I do NOT use recurring days however when I set this parameter the result is always null.

Not working schedule.LocalTime = new HueDateTime() { DateTime = alarmTime, RecurringDay = RecurringDay.RecurringMonday };

I want my users to be able to select the days then pass these days to RecurringDate Parameter RecurringDay recurringDays = RecurringDay.RecurringNone; if (viewModel.Monday == true) recurringDays |= RecurringDay.RecurringMonday; if (viewModel.Tuesday == true) recurringDays |= RecurringDay.RecurringTuesday; if (viewModel.Wednesday == true) recurringDays |= RecurringDay.RecurringWednesday; if (viewModel.Thursday == true) recurringDays |= RecurringDay.RecurringThursday; if (viewModel.Friday == true) recurringDays |= RecurringDay.RecurringFriday; if (viewModel.Saturday == true) recurringDays |= RecurringDay.RecurringSaturday; if (viewModel.Sunday == true) recurringDays |= RecurringDay.RecurringSunday;

schedule.LocalTime = new HueDateTime() { DateTime = alarmTime, RecurringDay = recurringDays };`

michielpost commented 6 years ago

The current implementation needs a TimerTime instead of a DateTime if you use a recurring date or time. Can you check if that works?

I'm not sure if this is correct or if setting a DateTime with a recurring day should also work? Might be a bug in Q42.HueApi. There are a lot of different DateTime variantions that Hue supports.

Q42.HueApi implementation for creating the DateTime json https://github.com/Q42/Q42.HueApi/blob/master/src/Q42.HueApi/Converters/HueDateTimeConverter.cs#L70-L87

Hue documentation: https://developers.meethue.com/documentation/datatypes-and-time-patterns

michielpost commented 6 years ago

I've made a possible bugfix for this issue. If you update the Q42.HueApi package to 3.6.6 it should be possible to use RecurringDay and DateTime. Let me know if it works.

Deery5000 commented 6 years ago

Hi Michiel,

I upgraded and did a quick test, still seeing the same issue with using Datetime.

Ill give a TimerTime a go tonight and let you know

Thanks Kevin

Deery5000 commented 6 years ago

Hi Michiel,

TimerTime worked for me to create the schedule however RecurringDays is not being set correctly.

I can set the RecurringDays without issue however when I GetSchedule(), RecurringDays is always coming back as RecurringNone.

Days are set like so RecurringFriday | RecurringTuesday

Any Idea what this could be?

Kevin

michielpost commented 6 years ago

Maybe @koenvanderlinden can help us out here. He contributed most of the code in the HueDateTimeConverter, probably because he needed the functionality in a personal project? Is the RecurringDay still working for you?

michielpost commented 6 years ago

I did some local testing and found the bug. Setting the TimerTime and RecurringDays should work now when you update to version 3.6.7.