Notify/turn on light when temperatur becomes to low

Hi, im trying to make a script that for starters will turn on a lamp when the temperatures drops below a certain point.
So far i have this:
trigger:
platform: numeric_state
entity_id: sensor.temperature
# Optional
#value_template: ‘{{ state.attributes.battery }}’
# At least one of the following required
below: 12.8

# If given, will trigger when condition has been for X time.
#for:
#  hours: 0
#  minutes: 0
#  seconds: 5

action:
service: light.turn_on
entity_id: light.lys_under_trappe

but nothing happens, can anyone guide me the right way?
The temperatur is at the moment of writing below 12.3 degress

Did you make this a script or an automation? Scripts have to be ‘turned on’ to execute automations will run automatically unless turned off

automation: 
  - alias: "Light on below 12.8"
    initial_state: true
    trigger:
      - platform: numeric_state
        entity_id: sensor.temperature
        below: 12.8
    action:
      service: light.turn_on
      entity_id: light.lys_under_trappe

and it also depends on if your sensor really is returning a numeric state or if it’s a number represented by a string.

if it’s not a true number being returned then try:

    trigger:
      - platform: state
        entity_id: sensor.temperature
        below: '12.8'

At least I think that’s correct.

And please try to properly format your code snippets when posting by following the instructions in the blue box at the top of the page. It makes it impossible to see syntax (indents and such) if you don’t.

What was the temperature when you started? I think it has to be above 12.8 then dip below it. That’s the trigger point. If it’s always below 12.8 it won’t be triggered. I could be wrong on this though.

Try forcing a higher number via the states tab them let the sensor read again.

Thanks all. I have writen it in the automation.yaml file, and im getting the temperatur from the YR component.
I will try your suggestions as soon as i get home from work.
Is it possible to later change it to turn on a switch?
then i would have to change platform and entity_id right?

Yep, you’d just need to use switch.turn_on.

this did not work, getting error saying that below is not allowed
error:

Log Details (ERROR)

Wed Oct 10 2018 19:03:41 GMT+0200 (Centraleuropæisk sommertid)

Invalid config for [automation]: [below] is an invalid option for [automation]. Check: automation->trigger->0->below. (See /config/configuration.yaml, line 80). Please check the docs at https://home-assistant.io/components/automation/

Tried your suggestion, but no luck, did not turn on the light

double check your entity_ids.
try putting ‘12.8’ instead of 12.8

Yeah I thought you could do that but apparently I was wrong. Sorry about that.

You can also try a template trigger

trigger:
  platform: state
  value_template: "{{ states.sensor.temperature.state < '12.8' }}"

tried your suggenstions, but im getting the following error:
Invalid config for [automation]: expected float for dictionary value @ data[‘trigger’][0][‘below’]. Got None. (See /config/configuration.yaml, line 80). Please check the docs at https://home-assistant.io/components/automation/
2018-10-11 16:37:21 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

i did double check the entity_ids

Did also try this, but no luck. Getting the following error:
Invalid config for [automation]: [value_template] is an invalid option for [automation]. Check: automation->trigger->0->value_template. (See /config/configuration.yaml, line 80). Please check the docs at Automation - Home Assistant

And this is how my automation looks like:

automation: 
  - alias: "Light on below 18.9"
    initial_state: true
    trigger:
      platform: state
      value_template: "{{ states.sensor.temperature.state < '12.8' }}"
    action:
      service: light.turn_on
      entity_id: light.lys_under_trappe

Try this:

trigger:
  platform: numeric_state
  entity_id: sensor.temperature
  below: 12.8

EDIT: I just realised this exact code has already been posted. See below:

If that doesn’t work, there’s a chance the sensor isn’t returning a true numeric value for some reason. To check that go to the Template Editor and paste this:

{{states.sensor.temperature.state > 0}}

If it returns true or false it means the state is numeric and the code I posted above should work.

If it’s not numeric the result will be blank and you’ll have to use a template to convert it first.

tried the templated editor and got the following error:
Error rendering template: UndefinedError: 'None' has no attribute 'state'
so guessing that the sensor isn’t returning a true numeric value

Actually that means something’s gone wrong with the name of the sensor. Go to States in dev tools (the <> at the bottom of the left side pane) and double check that the sensor exists and that you’ve written the name correctly.

I had made a mistake in the name sorry. now its returning nothing. So i guess I need to use a template. Can you point me in the right direction/help me with that?

What do you see in the template editor when you try the template I gave you above?

{{ states.sensor.temperature.state < '12.8' }}

I thought about this a bit. It shouldn’t need to go from above to below. It would have to update the state through. For example if you start home assistant and the temp is 12.7 Im not 100% sure it would trigger, but I think it would.

However, whenever the state engine updates the state of the sensor it should cause the automation to evaluate the trigger. If it is 12.7 it should fire even if it was previously 12.6.

It returns false