Getting current date and time for call-service in a button card
I’m trying to set up a button that logs an event with my hosted BabyBuddy api.
I currently have a button card set up and working if I hard code the current date in this format: 2021-08-17T20:06:00+01:00. What I need to do is have the card pick up the current date and time in the required format whenever the it is pressed.
Here’s my card configuration:
type: button
tap_action:
action: call-service
service: babybuddy.services_changes_add
service-data:
child: sensor.baby
time: 2021-08-17T20:06:00+01:00
wet: true
color: Green
target: {}
name: 'Change: Wet & Green'
icon: mdi:human-baby-changing-table
show_name: true
show_state: false
The above button has been tested to successfully log a wet, green nappy in my BabyBuddy instance. But for full WAP I need the button to be automatic. My plan is to have a dashboard of all the permutations in buttons so me or my wife can just press the required button in HA and all the logging is done in BabyBuddy. It’s just this issue with the time I can’t fathom - and the new arrival is in 5 weeks (eek!)
For extra bonus points, if anyone is able to tell me how to do this and also add 15 minutes onto the time, that would be incredible (the feeds need an end time, but I’m fine with this being a static 15 minutes rather than start messing around with start/stop timers).