Newbie in templating

I know I am quite a newbie when it comes to templating :frowning: but cannot accomplish the following:

1 of my sensors produces the following data:

<template state switch.wemo_tv=on; on_latest_time=00d 01h 54m 14s, today_energy_kwh=0.09, on_today_time=00d 00h 00m 00s, friendly_name=Wemo TV, power_threshold_w=40.0, on_total_time=03d 01h 05m 06s, current_power_w=7.61, state_detail=standby @ 2017-12-04T10:38:27.019561+01:00>

Now I want to capture only the current_power_w part in a template sensor, but I keep on getting no data even though I am sure the sensor is producing data. I am currently trying with the following configuration.

   - platform: template
         friendly_name: "Energie TV"
         unit_of_measurement: 'W'
         value_template: "{{ states.switch.wemo_tv.current_power_w }}"

Can anyone help this newbie to solve his problem?

To test this put it into the frontend side menu under templates.

However it look s like you need .state on the end -
{{ states.switch.wemo_tv.current_power_w.state }}

Try it in the template tester :slight_smile:

If I test {{ states.switch.wemo_tv.current_power_w.state }} in the template tester I get the following:
Error rendering template: UndefinedError: ‘homeassistant.core.State object’ has no attribute ‘current_power_w’

EDIT: got it :slight_smile: {{ states.switch.wemo_tv.attributes.current_power_w }}

1 Like

If you look in the states table what does it say about the wemos you probably need {{ state.attributes.current_power_w }}