Why wont this sensor template run?

This Code works correctly

  • alias: weather test
    trigger:
    platform: time
    at: ‘08:15:00’
    condition:
    condition: and
    conditions:
    - condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
    action:
    • service: media_player.alexa_tts
      data_template:
      entity_id: media_player.seans_echo_dot
      message: “Good Morning, the Weather Outside it feels like {{ states.sensor.met_office_feels_like_temperature.state | int }} Today”

But for some reason this one doesn’t run

  • alias: weather test
    trigger:
    platform: time
    at: ‘08:15:00’
    condition:
    condition: and
    conditions:
    - condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
    action:
    • service: media_player.alexa_tts
      data_template:
      entity_id: media_player.seans_echo_dot
      message: “Good Morning, the Weather Outside it feels like {{ states.sensor.met_office_feels_like_temperature.state | int }} and it is currently {{ states.sensor.met_office_weather.state | int }}.state | int }}”

Please edit your post and format your pasted code as per the blue banner at the top of the page. Use the code highlighting button not the quote button (as you appear to have done). This preserves indentation which makes it a lot easier for us to help you.

hi,

yes like what tom_l said, please format your code, because it also can be a code formating problem.

what say your log ? do you have an error message ?

You’re formatting your code wrong.

You need to Copy your code from yaml. DO NOT COPY FROM A POST ON HERE.

Then paste the code into your post.

use 3 ` symbols before and after your code (upper left button on keyboard below esc):

proper:
  fromat:
    without:
      - bullets:
        all_described_in_blue_link_at_top_of_page

message: "Good Morning, the Weather Outside it feels like {{ states.sensor.met_office_feels_like_temperature.state | int }} and it is currently {{ states.sensor.met_office_weather.state | int }}.state | int }}"

Mismatched braces?

1 Like

Also, just looking at your code here are a few pointers:

  1. You don’t need the and in your conditions. You only have 1 condition.
  2. Even if you had more than 1 condition, you don’t need the and. By default, conditions listed in condition will be anded together.
  3. You have a typo at the end of your template. You have an extra .state | int }} that shouldn’t be there.
  4. If you are grabbing the state in a template, its safer to use the method. You are using states.x.x.state, you should be using states('x.x') so you can avoid startup issues.
- alias: weather test
  trigger:
    - platform: time
      at: '08:15:00'
  condition:
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  action:
    - service: media_player.alexa_tts
      data_template:
        entity_id: media_player.seans_echo_dot
        message: "Good Morning, the Weather Outside it feels like {{ states('sensor.met_office_feels_like_temperature') | int }} and it is currently {{ states('sensor.met_office_weather') | int }}"
1 Like

Thank you for that petro, very helpful tips! after taking your advice and cleaning up my other codes its all working perfect.

Thank you