Timestamp_custom "%" issues

I’m working on some calculations with the Xfinity usage add-on and having trouble with the timestamp_custom portion of date formatting. I’ve got the following code in as a sensor:

    xfinity_bill_end_date:
      value_template: '{{ as_timestamp(strptime(states.sensor.xfinity_usage.attributes.end_date, "%m/%d/%Y")) | timestamp_custom('%A, %B %d') }}'
       friendly_name: 'Xfinity Billing Period Start'

and am getting an error during configuration check:

while scanning for the next token found character '%' that cannot start any token in "/config/sensors.yaml"

Fairly certain I am using the timestamp_custom integration correctly, and have had success with the same code with the template developer tool.

Without verifying if this is correct, the first error is your mix of single quotes inside of single quotes.

If you wrap the entire template string in single quotes, use double quotes everywhere inside. Or use double outside and single inside.

so, change timestamp_custom(‘%A, %B, %d’) to

timestamp_custom("%A, %B, %d")

1 Like

That was it. Didn’t know that rule, thanks!

… or two single quotes consecutively :wink:

1 Like