Very good, this is exactly what I was looking for!
The code is easy to understand and new instances of the StopWatch can be created with one click using “Search and Replace”.
Cool implementation, thanks!
Hi! I am trying to create a second stopwatch. I followed your instructions and almost everything else. What does not work is just the visual part of when you toggle the start/stop button.
The code refers to the button.start entity. When is this one created? I need a separate one for the second timer. When I use the “input_boolean.start_stopwatch2” instead, the button works but the icon toggling does not. I suppose this is a very basic question but I do not know how to solve this.
So I am wondering when and how the button.start entity is created, why this one is used even though it is not referred to in the stopwatch.yaml and for resetting the code refers to “input_boolean.reset_stopwatch” and how I can create a new one for the stopwatch2, stopwatch3 and so on. Do I need to add a helper and an automation manually or is there an easier way to do it when creating a new stopwatch?
I’m looking at the entities created and you’re right, I create a button with unique_id start_stop_stopwatch, but the name of the button afterwards is button.start which is one of the names given to the button depending it’s state, but afterwards changing the name really changes its friendly_name, but not its name.
I changed the name of the button from the first time I started as you suggested above. I changed all the entity names to stopwatch2 at the end.
It is a bit strange because I can see a button.resume entity, not button.start as you wrote. At the same time, when I wrote my previous post, I am pretty sure that I could see a button.start entity since that’s why I wrote. What is stranger is that there is no button.start_stop_stopwatch2 or as a matter of fact, there are no other button entities related to the stopwatch at all. Just one.
In the code for the card, in the section for the button I have:
As I wrote before, the functionality is there after I changed the code to: input_boolean.start_stopwatch2 but the icon does not change with the state. Or to be precise it does but from mdi:stop-circle-outline to a circled tick icon or however I should call it, instead of changing from mdi:play-circle-outline to mdi:stop-circle-outline.
The only difference between the stopwatch and stopwatch2 code for the card is that the original one refers to button.start while the second one refers to input_boolean.start_stopwatch2.
When I change the button.start or now in my case button.resume to input_boolean.start_stopwatch (without the “2”) the first stopwatch also switches from the correct icons to the wrong ones.
I’ve created a new card using Mushroom integration (you can install it through HACS). You won’t need the button section of the stopwatch code, so you can safely remove and create several stopwatches without problems (I hope).
Hi @miguelpucela,
hope you might be able to help me.
when i start the stop watch via input_boolean.start_stopwatch the tic tac starts. but the stop watch only moves from Unknown to Unavailable?
if i template
{{states('sensor.stopwatch')}}
all i get is unavailable. not any number what so ever. perhaps i have made a mistake in setup?
your code was pasted under a package like this:
homeassistant:
packages:
stop_watch:
input_boolean:
start_stopwatch:
# It triggers stopwatch to start/stop(pause)
name: Start/Stop Stopwatch
# initial: off
reset_stopwatch:
# It triggers stopwatch to reset
....................................
Thanks very much for this. I’ve been looking for a way to create a job-timer thing with a physical button and whilst I can sort the electronic and Tasmota side out, I was struggling with how to do it in HA. This does the trick and I shall have fun integrating it. - All the best!
hello, and thank you for this work. I was looking for a timer to start work, be able to take breaks and finally stop. the goal was to count the working time over the day…
I’m a little new to HA and I would like to be able to switch the daily data into influxdb (I already have an HA database in there with consumption reports for example). And also know if once transferred to influx the HA database can be cleaned? in any case, the timer and what I was looking for!
I cannot help you here. I’m not expert in dababase and I don’t know anything about influxdb. I don’t know if anybody else can help you, or you can try creating a new topic about your question in configuration thread, as this is not directly related with the stopwatch, but with database management.