Need help on weather platform condition in automation

Using YR as weather platform. Want to trig car heater in the morning when degrees fall below 2 C and it’s not weekend.

The automation works perfect if I go for an OR statement instead of AND so the weekday condition seems to work. But the temp condition I just can’t get to function. Wrong entity_id?

Haven’t found any good example on this so I’m lost… Please advice. =)

# begin snippet - hass config

sensor weather:
  - platform: yr
    monitored_conditions:
      - temperature
      - symbol
      - precipitation
      - windSpeed
      - cloudiness

automation:
- alias: 'Turn on car heater at 07:30'
  initial_state: True
  hide_entity: False
  trigger:
    platform: time
    after: "07:30:00"
  condition:
    condition: and
    conditions:
      - condition: numeric_state
        entity_id: 'sensor.weather_temperature'
        below: '2'
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
  action:
    service: homeassistant.turn_on
    entity_id: switch.r01_b1

# end snippet

With my numeric_state conditions, I don’t have quotes around the number. I wonder if that makes a difference.

And I don’t quote entity_id’s.

Tried it - removed the quotes around the number and the entity_id. Still no luck.

Wonder if the entity_id is the problem?..

Hmmm. What happens if you only use the numeric_state condition?

Are you sure about the entity_id (sensor.weather_temperature)? I use Dark Sky and all of the entity_id’s allude to that (sensor.dark_sky_temperature).

(You prob know, but you can click the “trigger” button on an automation in the HASS UI so that you don’t need to keep tweaking times. I suspect the issue here is diagnosing the condition, not the trigger)

(also - yeah, my first recommendation was rubbish. Just looked at the conditions page and quotes are fine)

Thanks for hinting at the trigger button in the hass ui. But that seems to trigger without taking the condition into account for me. Always fires the action.

Oh. Sorry - I thought that I remembered that that would simulate a trigger. I’m full of crappy advice.

Am I at least on the right track with the entity_id? You can check those on the states dev tool (button at bottom of sidebar).

1 Like

Hehe… Actually you were right on the entity_id. It was wrong, now it works - thanks for pointing me to the states dev tool. Appreciate it! =)

Woo-hoo! Glad I got something right today.

Thanks for the code, using it for my car to by changing sensors and switches! How are you making it to turn off tough, would it be possible to use a “delay” action or should I make a second automation?

I typically use scripts when I need a delay. Use the script as your action (service: script.whatever_name). Scripts can include delays and conditions.

I use the following delay conf - not perfect but it works in most of my use cases. Simply listens for a change on a switch, sets a delay, and when the delay runs out turns the switch off.

- alias: 'Turn off car heater after 30 min'
  initial_state: True
  hide_entity: True
  trigger:
    platform: state
    entity_id: switch.r01_b16
    from: 'off'
    to: 'on'
    for:
      minutes: 30
  action:
    service: homeassistant.turn_off
    entity_id: switch.r01_b16

You could do a more advanced delay that could be reset if someone trigs the switch during the delay period. Not handled in my code above currently.

Hi

May I ask you how have you configured your car to work with HA that enables you to turn on the car heater?

Thanks.

It’s just a 433 MHz RF controlled outlet. Nothing fancy. I pull temperature from an online source. Could have used a local - might complement the solution going forward.

Thanks !

Is it possible if you could post your configuration of the whole system (car heating) for me to try and implement it?

Thanks.

Below is the automation part - that should do it.

- alias: 'Turn on car heater at 07:45 [mon-fri, temp<1C]'
  initial_state: True
  hide_entity: False
  trigger:
    platform: time
    after: "07:45:00"
  condition:
    condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.yr_temperature
        below: 2.0
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
  action:
    service: homeassistant.turn_on
    entity_id: switch.r01_b16
1 Like

The comment is incorrect - it should be “temp<2C”.

thanks for that !
may I know what brand/make is your 433 MHz RF outlet and how was you connected it up in your car?

It’s a NEXA 433 MHz plug. Connects via power cable to DEFA inlet on car; http://www.defa.com.