Another Newbie / Config Question

Hi All,

New to HA and just getting started, I grabbed an R-Pi3B+ (thus Hassbian, not HASS.IO), Aeotec Multisensor and SmartSwitch to start my learning. Also, been looking at openHab as a comparison.

I quite like HA so far, but the thing that’s making me scratch my head a little is how I get around not having variables available to use.

For example, I’d like to set a variable of some sort to indicate “Bedtime” hours as I can see this being used in several automations - but at the moment it seems I’d have to set this as a fixed condition in each automation and if I wanted to change it, I’d have to change them all.

Is there a better way of handling this? I’ve seen one or two extensions that provide some vars, but not sure this will help in this case.

Apologies if this is already covered somewhere - trying to absorb as much as possible.

Thanks in advance.

You can create input numbers and expose them on the front end.

Like @flamingm0e said, there are several input_xxx types that can be used as variables. A little different, but you eventually get used to it. You can either expose them in the frontend or not as needed.

The input_datetime component sounds like it would be best suited to your requirement.

There is also this custom component:

1 Like

Thanks - I’ll check it out. I did find and read the linked article attached also, but thanks for re-posting.

Thanks @pnbruckner and @flamingm0e - I’ll look in to it!

…just as a follow up to this, in my automations, can I use the input_datetime in a condition like this:

condition:
  condition: time
  after: '{{ states.input_datetime.time_bed.attributes.timestamp }}'

Or, can I only use them in a value_template like this:

  condition:
    condition: template
    value_template: '{{ states.input_datetime.time_bed.attributes.timestamp > as_timestamp(now()) }}'

The former would be easier as I can quickly put in the range using “after” and “before”, the latter is a little more messing around and not as tidy, but seems to work!

Thanks…