Custom component: Timers for controlling devices

Hello, I am absolutely new in this area and still learning with method try & error. I am posting my first custom component which I use for my garden :).

2 Likes

Is it possible to use entities as the parameters for the start times and duration? ie: use an input.datetime instead of an actual value for the start time? and in input_number for the duration?

I was thinking about. There is a service for setting, integration with input.datetime I did not tested yet, I think it will not work, I am using format HH:MM. Good idea for improving.


New time interval is stored in memory.

What I was hoping for was more like this:

input_datetime:
  sprinkler4_starttime:
    has_date: false
    has_time: true

input_number:
  sprinkler4_runtime:
    min: 0
    max: 59
    step: 1
    unit_of_measurement: min

turnoffon:
    sprinkler_4:
      action_entity_id: input_boolean.sprinkler_4
      name: Area 4
      timers: { "input_datetime.sprinkler4_starttime":input_number.sprinkler4_runtime }

You are right. This is what I had in my previous version. However when I used it in my daily life what happened: very long configuration. If I want something change - many cards and entities - mistakes in defining new intervals etc. Maybe that app will created that automatically on demand in config (input_datetime, input_number)

I have just properly read your idea. It is wrong because, in that case you are creating only one entity. It is not necessary to do some special component for that.
‘sprinkler_4’ with timers :{“10:00”:20, “12:00”:30, “15:30”:“18:00”}
will create:
turnoffon.spinkler_4 as parent and his children:
turnoffon.sprinkler_4_01 with interval 10:00-10:20
turnoffon.sprinkler_4_02 with interval 12:00-12:30
turnoffon.sprinkler_4_03 with interval 15:30-18:00

@OMM, may i ask why i got mentioned in the __init__.py?
I can’t remember that i did anything for your component. :slightly_smiling_face:

Hello @VDRainer, you did. I am totally new in python and I have used your input_datetime for learning :). If you do not agree I can remove.

Ahh, that was only the services.yaml file, has nothing to do with the code.
I’m a python noob to, so please remove me.

Fixed :handshake:

I don’t think you quite understand my use case. I want to be able to adjust the start times and duration’s from the GUI. Having them hard-coded as you suggest removes that ability. Thats why I wanted to be able to use input_datetime and input_number in place of teh hard-coded values. That way they can be adjusted using entities in Lovelace.

Hello.

Take a look on my previous project: Timer with python script. I am sorry that it is in Czech, I can translate but I think it is only consuming time to work on that. I left this solution for the reason that there is a sandbox python script limitation. But it was working on my garden with no issue.
Let’s talk about current solution. Turnoffon I made just for my garden and post it here if it has some feedback. If somebody as you is saying “hey it is fine but it is hardcoded” - no problem I know it. ¨

If I am thinking about - user should have possibility to define number of time intervals. Number it means _01, _02, …_n. To add there input_datetime, input_number is easy and as I mentioned there exists service for that. However, I prefer if application should create this entities automatically. And it needs more tests more time and it is on the edge if start with that or not.

Your opinions are important for me in any case.

AC_example
Hello, there is an example with a “little hard-coded” values :yum: