Does Ha have a built in day/night cycle?

Based on your use case, do you really want “day/night”, or maybe it would be better to check if it was “dark/light” outside? So your lights would turn on to 80% if it was very cloudy even in the middle of the day. So, since everyone’s approach to this is slightly different, it’s a feature, not a limitation, of HA that you need to make your own - so you can do it exactly the way that works best for you.

I’m afraid that my needs are literal and arbitrary. I need to set a period during which all lights will default to a dimmer setting regardless of actual light levels.

Then you will have to define an arbitrary and literal custom trigger for your case :slight_smile:

1 Like

Or you can look at installing adaptive lighting to help with this.

All of this complexity, and I just need it to something different between two times.

When it comes to this platform, if you ask a vague or general question it is very likely you will receive responses with a variety of general methods that may accomplish what you have described. We don’t know anything about the structure, constraints, options, or needs of your automation or devices unless you share it…

Community Guide: Asking a Good Question

1 Like

We don’t know anything about the structure, constraints, options, or needs of your automation or devices unless you share it…

I was referring to HA having a half a dozen different ways to determine what is constituted as day\night, but not the obvious one of having a field that you fill in to tell it directly.

The problem that I’ve found with HA is that it’s exceedingly good at letting you create bespoke solutions that are tailored to your exact needs, but rather poor when it comes to simply giving you a button to press to do something.

Personally, I’d consider asking if something had a built in day\night cycle to be a pretty direct question that doesn’t have much nuance. The system might be simple or complex, it just needs to be a built in system that will return “Day” based on a series of variables, or “Night” based on another series of variable. What the variables are could be a follow up question.

Community Guide: Asking a Good Question

Ironically, I asked one of the big AI chat bots this, and it wrote me a template that returned day\night based on the time helper.

The bot gave me the best answer.

I have a feeling that AI capable of writing simple code may be a game changer for people like me who just want simple solutions to clearly defined problems.

Glad it worked. Don’t lean too hard on them, they have proven inaccurate with HA quite a few times already. Personally I would rather learn the system myself because then when I want to do something the AI can’t handle I know how - but to each their own and no judgement.

This is actually a very accurate and fair assessment of HA.

Though whether this is a good thing or a problem entirely depends on your individual situation and expectations.

I was more suggesting that the bots were better at answering my questions than the community, because the bots didn’t over complicate things.

For example, in this instance the bot gave me some code that had two outputs, day and night. Because my question had binary choice in it.]

it didn’t talk about variable light levels, or suggest that I might want to use light sensors. It just gave code that split the day into two sections.

I’m curious, what was the answer of AI?

I would create a boolean (on-off) and create a automation around that.
If time is 22:00 then turn boolean off, if time is 06:00 then turn boolean on.
Off = Night
On = Day

There is no need for all that.

You’ve already been given this very simple solution:

It can be set up via the UI, no need for YAML.

  • Give it a name.
  • Give it an on time.
  • Give it an off time.
  • Done.

You can then use the state of this binary sensor wherever you want, including in conditions.

4 Likes

A couple of observations, now that the original question has been answered several different ways.

First, I’m surprised AI gave the right answer here. I’d be curious to see it. For me, so far, AI has always confidently given a very simple and straightforward answer which looked ideal. But each time it was totally incorrect and unworkable. In AI terms, a pure hallucination.

Second, I’m impressed by the depth of the answers in this thread. In some other environments the OP would have gotten the direct and technically correct answer to the specific question: No. HA doesn’t have that exact option built in.

Instead, even without knowing the specific use case, a number of workable solutions were offered. HA is very flexible and you can make things as simple or as complex as you’d like. Most of us think of that as a benefit. But if all you want is a simple “set it and forget it” appliance which requires no tinkering, then there are better options for you.

In hindsight, the obvious answer

Create a time helper to store an AM and a PM time, create a temple that returns a pre defined text value based on whether or not you’re currently between the two times.

Then simply read it from the automation using conditions.

The bit that I appreciate the most is that rather than just suggesting what to do it actually generated the code for me. So that I could copy and paste it right in. It was fully commented, too.

I’d like it if more people would simply post code to this forum. I’ve had trouble before with armchair experts telling me to “read the manual” and making out that I was simply making a mistake somewhere in the code when something didn’t function as expected, and when I asked them if they could replicate the solution on their own systems they just linked to the manual again. Eventually it turned out that I was going going down the wrong path, and that the armchair experts hasn’t understood the error message any more than I had, and were leading me down the wrong path because they hadn’t even tried to replicate the problem on a system that they knew was properly set up.

Eventually someone came along who understood what the error was, and it took about 10 seconds to fix everything.

1 Like

I’ve been on the HA forums almost daily for over 7 years now and I will say that in my experience that is very far from true. I would bet money that if you look in almost every thread someone will have posted some code (of course if that is the appropriate to the topic).

But (caveat) that might also depend on the way the question is being posed.

If you post the use case you are trying to achieve with the code that you tried that is giving the error and along with the error message if there is one the vast majority of the time you will get a great response and with corrected code.

If you post an error without any code you will most likely get a response of “post the code you tried that isn’t working and what do you expect it to do”.

If you post a general question on “how do I…” and no other context you are more likely to get a link to the documentation. This is not a Nabu Casa help desk (or an AI bot) that will do all of the work for you. we generally expect you to at least put in the initial work to try to figure it out on your own first. Then if it still doesn’t work and you post what you tried then most of the time you will get more specific help.

Remember, all of the help you get here is unpaid. So in effect we are all “armchair experts”. Tho some are more “experts” than others. An in fact it is exceedingly rare for any true “experts” to be on this forum ever at all since most Nabu Casa employees never come on here to provide any help at all.

4 Likes

The problem that I had was that I already had the code, but it was giving me an error message, and I wanted to correct it.

Nobody would even touch it, they just told me to “read the manual” and kept making these vague suggestions that ended up leading me in completely the wrong direction.

Eventually, maybe after a couple of weeks, someone turned up who actually understood what the error message meant and that the fix was very simple (I was trying to call what I thought was function using arguments from an automation, but it turned out to be a command that cannot be called using arguments).

If you post a general question on “how do I…” and no other context you are more likely to get a link to the documentation.

Yeah, please don’t do that.

One of the reasons why the open source community is seen as being so closed and elitist by non-coders is when people come to a forum like this they’ve usually already read the manual and not been able to solve their problem, and they ask generic questions because they’re not familiar enough with the system to ask a detailed technical question. So linking to the documentation is the equivalent of someone asking their couch how to become a better runner and being told “run faster”.

in effect we are all “armchair experts”

Sorry, I wasn’t clear, this is an idiom in my language. It means someone who talks about something as if they were an expert, but in truth they never get out of their chair to actually do it.

Like, someone posting a hundred comments telling people to “read the manual”, because they don’t have the knowledge to solve the problem themselves.

Anyway, 'I’m getting off topic.

The answer to my question seems to be that there is no day\night cycle in HA, but there are several ways to write your own.

So point us to the post you are referring to. If we agree with you, we will apologise for not helping as you hoped we would.

That sounds like a really bad idea.