Time/string formatting

I am trying to format the string from sun.sun.next_rising but I keep getting the error

TypeError: entity.attributes.next_rising.strftime is not a function
    at eval (eval at evaluate (floorplan.js:49), <anonymous>:3:86)

How should I format this string?

for reference this is my ha-floorplan.yml

views:
  - title: Home
    path: home
    icon: 'mdi:floor-plan'
    theme: ''
    panel: true
    badges: []
    cards:
      - type: vertical-stack
        cards:
          - type: horizontal-stack
            cards:
              - type: 'custom:floorplan-card'
                full_height: true
                config:
                  image: /local/floorplan/home/home.svg
                  stylesheet: /local/floorplan/home/home.css
                  log_level: info
                  console_log_level: info
                  defaults:
                    hover_action: hover-info
                    tap_action: more-info
                  rules:
                    - entity: weather.home
                      state_action:
                        - service: floorplan.text_set
                          service_data:
                            element: outside.temp
                            text: >
                              > return (entity.attributes.temperature !==
                              undefined) ? entity.state + " °F" : "unknown";
                    - entity: sun.sun
                      state_action:
                        - service: floorplan.text_set
                          service_data:
                            element: sun.sun
                            text: >
                              > return (entity.attributes.next_rising !==
                              undefined) ?
                              entity.attributes.next_rising.strftime('%b %d,
                              %Y') : "unknown";
title: Home

Hi @Telmo,

I believe strftime is available in Python, but floorplan code is executed in JavaScript.

If you remove .strftime from your rule, does your floorplan work OK?

In the next version of floorplan, we will be including a JavaScript version of strftime.

If you have any questions related to floorplan, best way is to use the discussions on the GitHib page:

@pkozul Thanks for the reply, I ended up creating sensor specifically for this, I am sure there is a more elegant way to go about it but as I explore HomeAssistant I’ll update

- platform: template
  sensors:
    sun_raise:
      friendly_name: 'Sun Rise Time'
      value_template: '{{ as_timestamp(state_attr("sun.sun", "next_rising")) | timestamp_custom("%I:%M:%S %p", True) }}'
      icon_template: mdi:weather-sunset-up
    sun_set:
      friendly_name: 'Sun Set Time'
      value_template: '{{ as_timestamp(state_attr("sun.sun", "next_setting")) | timestamp_custom("%I:%M:%S %p", True) }}'
      icon_template: mdi:weather-sunset-down

@Telmo
We have released a new version of Floorplan (v1.0.19), which has built-in support for strftime.

In your floorplan rules, you can use it like this:

util.date.strftime('%B %d, %Y %H:%M:%S', entity.last_changed)
1 Like