megakid / ha_octopus_intelligent

Apache License 2.0
86 stars 10 forks source link

Automation Service Call #7

Closed macray76 closed 1 year ago

macray76 commented 1 year ago

Executing the select_option service to set the target ready time does not work for half past the hour settings.

My test code looks like this...

service: select.select_option
data:
  option: "08:30"
target:
  entity_id: select.octopus_target_ready_by_time

Automation runs but the time is set to 08:00 instead.

Exactly the same code works if setting "09:00" for example. Feels like it is ignoring the :30 part.

macray76 commented 1 year ago

I've also used the UI device select option and it produces the same result...

device_id: 939174e695844fa490d21e99d7d1dfd6
domain: select
entity_id: select.octopus_target_ready_by_time
type: select_option
option: "08:30"
joeljeffery commented 1 year ago

Happens for me too! :)

joeljeffery commented 1 year ago

Think I've got it. 😄

Line 138 int graphql_client.py.

Currently:

readyByHoursAfterMidnightMinutes = round(30 * (readyByHoursAfterMidnight % 0.5))

I think it should be:

readyByHoursAfterMidnightMinutes = round(60 * (readyByHoursAfterMidnight % 1))

I've swapped that in, and now I can set Ready By Time with to the hour or half-hour.

Please validate my logic before applying! 😁