Write to log - Not sure how to get state

Trying to write the state of a sensor to the log.

automation:

- id: python_test_on
  alias: Python Test  On
  hide_entity: false
  initial_state: true
  trigger:  
    - platform: state
      entity_id: sensor.livingroom_presense_desk
      to: 'True' 
  action:
    - service: python_script.opened_door_time
      data_template:
         entity_id: sensor.front_door_ctl_dist_time

python_script:

entity_id  = data.get('entity_id')
states     = hass.states.get(entity_id)
logger.info("entity_id = {}".format(states))
current_level = states.attributes.get('state')
logger.info("Front door opened at {}".format(current_level))

log output:

entity_id = <state sensor.front_door_ctl_dist_time=Wed Dec13 14:18:02; friendly_name=Front Door Trip Time, icon=mdi:clock @ 2017-12-13T14:18:02.098857-05:00>
Front door opened at None

I only want to log:

Wed Dec13 14:18:02

What am I doing wrong. Just point me in the right direction - I can’t find an example or docs that is simple enough for me!!!

The part you want to extract will be available on the .state property of your states variable.

So, you’d just need to change the line:

current_level = states.attributes.get('state')

to

current_level = states.state