Invalid automation: Device_Id required in Condition

Hello,

I am trying to create my first Blueprint. But I have a Problem with one of my conditions, I think :thinking:.

I used this blueprint as a template to just add my stuff and change it so it works better with my Nest thermostat.

Here is my Blueprint:

blueprint:
  name: Thermostat Control
  description: Control your thermostat with options for group home, and heating between specific times.
  domain: automation
  input:
    thermastat:
      name: Thermastat Device
      description: The Thermastat device to use.
      selector:
        entity:
          domain: climate
    group_presence:
      name: Person Group
      description: The group of people that have to be home.
      default: []
      selector:
        entity:
          domain: group
    group_not_present_offset:
      name: Not present offset
      description: Set to Eco if Person of Group was not present for a given amount of time
      default: 01:00:00
      selector:
        time: {}
    heating_boolean:
      name: Heating Boolean
      description: Check if Boolean is on for automation
      default: true
      selector:
        entity:
          domain: input_boolean
    hvac_mode:
      name: HVAC Mode
      description: Will run only if thermostat is in given HVAC mode.
      default: heat
      selector:
        select:
          options:
            - heat
            - cool
    set_temp:
      name: Temperature Target
      description: Sets the thermostat to this temperature.
      default: 20
      selector:
        number:
          min: 10.0
          max: 25.0
          step: 0.5
          mode: slider
    eco_temp:
      name: Energy Saving Temperature
      description: When away, keep the Energy Saving Temperature
      default: 17
      selector:
        number:
          min: 14.0
          max: 25.0
          step: 0.5
          mode: slider
    time_after:
      name: Time After
      description: After this time the heating turns on, so it's warm in the morning
      default: 07:30:00
      selector:
        time: {}
    time_before:
      name: Time Before
      description: After this time the heating turns off, This to prevent the heating is on in the middle of the night
      default: '21:30:00'
      selector:
        time: {}
  # source_url: https://gist.github.com/f45tb00t/eab416909ff6d125d7f3c6170ab017a9
variables:
  set_temp: !input 'set_temp'
  eco_temp: !input 'eco_temp'
  hvac_mode: !input 'hvac_mode'
trigger:
  - platform: homeassistant
    event: start
  - platform: event
    event_type: automation_reloaded
  - platform: time_pattern
    minutes: /5
  - platform: device
    domain: climate
    entity_id: !input 'thermastat'
    type: hvac_mode_changed
  - platform: state
    entity_id: !input 'heating_boolean'
    to: 'on'
condition:
  - condition: state
    entity_id: !input 'heating_boolean'
    state: 'on'
  - condition: device
    domain: climate
    entity_id: !input 'thermastat'
    type: is_hvac_mode
    hvac_mode: '{{ hvac_mode }}'
  - condition: time
    after: !input 'time_after'
    before: !input 'time_before'
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: !input 'group_presence'
            state: not_home
            for: !input 'group_not_present_offset'
        sequence:
          - service: climate.set_temperature
            target:
              entity_id: !input 'thermastat'
            data:
              temperature: '{{ eco_temp }}'
    default:
      - service: climate.set_temperature
        target:
          entity_id: !input 'thermastat'
        data:
          temperature: '{{ set_temp }}'

and here is the error I get when I create an automation with this blueprint:

Logger: homeassistant.components.automation
Source: components/automation/init.py:638
Integration: Automation (documentation, issues)
First occurred: 12:00:04 (12 occurrences)
Last logged: 12:24:03
Blueprint Thermostat Control generated invalid automation with inputs OrderedDict(
[(‘hvac_mode’, ‘heat’),
(‘thermastat’, ‘climate.living_room_thermostat’),
(‘group_presence’, ‘group.somebody’),
(‘heating_boolean’, ‘input_boolean.thermostat_auto’),
(‘set_temp’, 22),
(‘eco_temp’, 18),
(‘time_after’, ‘07:45:00’)]
): required key not provided @ data[‘condition’][1][‘device_id’]. Got None

I think, I need a “device_id” in the condition with the type “device” but how do I get it from my input?

I did not test yours as I am lacking time.

But “required key not provided @ data[‘condition’][1][‘device_id’]. Got None”
Condition 1 is:

  • condition: state
    entity_id: !input ‘heating_boolean’
    state: ‘on’

Also you did not declare the variable.

variables:
set_temp: !input ‘set_temp’
energy_temp: !input ‘energy_temp’
window_sensor_1: !input ‘window_sensor_1’
heating_boolean: !input ‘heating_boolean’

If you do not want to use the boolean, you must remove it.

I think it is the condition:

  - condition: device
    domain: climate
    entity_id: !input 'thermastat'
    type: is_hvac_mode
    hvac_mode: '{{ hvac_mode }}'

because they are counted starting “0” not “1”. I just testet it by removing the condition with the “heating_boolean” and got the messaege:

Logger: homeassistant.components.automation
Source: components/automation/init.py:638
Integration: Automation (documentation, issues)
First occurred: 12:18:27 (1 occurrences)
Last logged: 12:18:27

Blueprint Thermostat Control generated invalid automation with inputs OrderedDict([(‘hvac_mode’, ‘heat’), (‘thermastat’, ‘climate.living_room_thermostat’), (‘group_presence’, ‘group.somebody’), (‘heating_boolean’, ‘input_boolean.thermostat_auto’), (‘set_temp’, 22), (‘eco_temp’, 18), (‘time_after’, ‘07:45:00’)]): required key not provided @ data[‘condition’][0][‘device_id’]. Got None

I also don’t get it why you want to have a condition for the device itself. What would be the goal there?

if time between x.y.z then,…
if person not home then,…
if person there then,… (default)

I want to check if the device (Nest thermostat) is in specific mode (heat, or cool) select variable “hvac_mode”. And only if the device is in the selected mode it should turn the temperature based on presence and time.

In the blueprint I used as a template the thermostat was turned off and on by the automation, that doesn’t work with Nest. With Nest thermostats you turn heating on once and you let it on until it is warm outside. You just adjust the temperature and the thermostat ist doing the rest by itself. But I want to set different temperatures during the day and at night. I also want to have different temperatures set if the thermostat mode changes to cool and therefore, I want to check the mode of the thermostat itself.

I would have 4 Automation

  • Heating during the day
  • Heating during the night
  • Cooling during the day
  • Cooling during the night
  • and when the Thermostat mode ist “off” it should do nothing.

I can create the whole automation without a blueprint, and it works but I wanted to do it with one and for this I had to remove the “device_id”, because it wouldn’t work for someone else if I would share it.

Is there a reason why you can’t use an input for the device?

 - condition: device
    domain: climate
    device_id: !input 'thermostat_device'
    type: is_hvac_mode
    hvac_mode: '{{ hvac_mode }}'

And then add thermostat_device to your inputs.

If I change the input to a “device” and in code everything to “device_id: !input ‘thermastat’” than I get

required key not provided @ data[‘entity_id’].

Or do I need to keep both inputs “entity” and “device” and select in both the same Device/Entity?

I changed the condition to a state condition and not a device condition and it works now.

Thanks to everyone!!!

1 Like