Convert minutes into hours and minutes

I have been trying to convert the time remaining using the .msg.duration in Big Timer so I can display the hours and minutes in HA. Disclaimer. I am not a programmer, so I am behind the 8 ball. I have watched numerous videos and hours of researching, but to no avail. What I want is what is displayed under BigTimer. It will display “On for 8 hours 10 minutes”.

I know this is not a game changer but I would like to have it display so it looks nice in HA.
Actually, I would like to eventually use a switch node (monitoring the duration) to format the text so if duration is < 1minute, display"minute" but if it is > 1, display “Hours” and “Minutes”.
Below is a couple of screenshots of the AC control for my shop Mini Split AC. The bottom line is the BigTimer Control.
All advice and suggestions appreciated.

const [hours, minutes, seconds] = new Date(msg.duration* 1000).toISOString().substr(11, 8).split(":");

msg.payload = `${msg.payload} for ${hours > 0 ? `${hours} hour and ` : ''} ${minutes > 0 ? `${minutes} minutes` : "1 minute"}`;

return msg;

Thank you, sir for the quick reply. I copied your code into the function node, and this is what I get. “On for 1 minute”. Actually, Big Timer is on for another 37 minutes, and the resulting msg. isn’t changing.

I don’t use bigtimer, what is msg.duration? seconds minutes?

minutes.

Have you tried using a status node? You can connect it to the Big Timer node, and then every time the big timer’s status changes, you can get it and do something with the status. An example of how to do this is here.

change msg.duration* 1000 to msg.duration* 60000

status node is another good option like stated above

Winner, winner, chicken dinner. Thank you so much. I abbreviated ‘hours’. Everything else looks great.


33

Thank you. That will come in very handy on other flows.

Would you please the flow and the card. Thanks.