Input datetime as start or stop Flux integration time

Hello.

I’d like to use input_datetime as start_time and stop_time Flux integration config options. So I have:

input_datetime:
  morning_time:
    name: Morning time
    has_time: true

  night_time:
    name: Night time
    has_time: true

switch:
  platform: flux
  lights: group.light_hall
  start_time: "{{ states('input_datetime.morning_time') }}" # Version 1
  # start_time: input_datetime.morning_time # Version 2, also not working
  stop_time: "22:00:00"

None of version 1 or 2 doesn’t work. It complain about:

Version 1:

Invalid config for [switch.flux]: Invalid time specified: {{ states('input_datetime.morning_time') }} for dictionary value @ data['start_time']. Got "{{ states('input_datetime.morning_time') }}". (See ?, line ?).

Version 2:

Invalid config for [switch.flux]: Invalid time specified: input_datetime.morning_time for dictionary value @ data['start_time']. Got 'input_datetime.morning_time'. (See ?, line ?).

I think, the problem is input validation, which is done here. I’m not sure, but it probably try static validate original option value.

Am I right? Is there any other way, to use input_datetime value in Flux?

Create an automation using Time trigger to turn switch.flux on or off.

Pretty wise, but it seems like workaround. The lights actually will be controlled only in the defined time range, however the Flux start and stop time options will be sunrise and dusk. It doesn’t really fit in my needs.

It doesn’t accept templates. Only some options permit the use of templates.

You may wish to consider the following alternative and see if it meets your needs:

2 Likes

Thanks. Proposed component seems good!