Attempts at selector

Working with a blueprint where I want some actions pre-selected.
I get error: Incorrect type. Expected “object” at the row “within_deadzone_actions:” but I can’t wrap my head around why

below_deadzone_actions:

      name: Low prices and temperature BELOW thermostat deadzone

      description: Actions to perform.

      default: []

      selector:

        action:

          - service: climate.set_temperature

            target:

              entity_id: !input climate.entity

            data_template:

              temperature: "{{ states('input_number.heating_deadzone') | float + states('input_number.thermostat_entity') | float }}"

          - service: climate.set_hvac_mode

            target:

              entity_id: !input climate.entity

            data:

              hvac_mode: 'heat'  # Replace with the appropriate HVAC mode

          - service: climate.set_fan_mode

            target:

              entity_id: !input climate.entity

            data:

              fan_mode: 'low'  # Replace with the appropriate fan mode

    within_deadzone_actions:

      name: Low prices and temperature WITHIN thermostat deadzone

      description: Actions to perform.

      default: []

      selector:

        action: {}

    above_deadzone_actions:

      name: Low prices and temperature ABOVE thermostat deadzone

      description: Actions to perform.

      default: []

      selector:

        action: {}

Is that an input? If so it cannot use an input in it’s definition. Also that list needs to be delimited, or HA interprets it as yaml. If you want to have a default, that is not the syntax, nothing after action: is allowed. Lots of formatting problems. Perhaps look at other examples in the exchange for inspiration.

It’s very hard to put code snipits like this into context. I don’t like guessing on answers like that. Also why the extra spaces?

Sorry about the formatting. I didn’t realize it got scewed copypasting from Studio Code Server.

    below_deadzone_actions:
      name: Low prices and temperature BELOW thermostat deadzone
      description: Actions to perform.
      default: []
      selector:
        action:
          - service: climate.set_temperature
            target:
              entity_id: !input climate.entity
            data_template:
              temperature: "{{ states('input_number.heating_deadzone') | float + states('input_number.thermostat_entity') | float }}"
          - service: climate.set_hvac_mode
            target:
              entity_id: !input climate.entity
            data:
              hvac_mode: 'heat'
          - service: climate.set_fan_mode
            target:
              entity_id: !input climate.entity
            data:
              fan_mode: 'low'

This part is what I’m messing up (I just started playing with the section to see what was possible or not.

The whole blueprint

blueprint:
  name: V6 HVAC Control Based on Electricity Price
  description: V6 Control HVAC based on electricity price and temperature.
  domain: automation
  input:
    price_sensor:
      name: Price Sensor
      description: Select the electricity price sensor.
      selector:
        entity:
    price_threshold:
      name: Electricity price threshold
      description: When to consider prices low. (Tibber "Price Level")
      default: CHEAP
      selector:
        select:
          options:
          - label: Very expensive
            value: VERY_EXPENSIVE
          - label: Expensive
            value: EXPENSIVE
          - label: Normal
            value: NORMAL
          - label: Cheap
            value: CHEAP
          - label: Very cheap
            value: VERY_CHEAP
          custom_value: false
          multiple: false

    thermostat_entity:
      name: Thermostat
      description: Select the thermostat input_number helper
      selector:
        entity:

    heating_deadzone:
      name: Heating Deadzone
      description: Select the heating deadzone temperature input_number helper
      selector:
        entity:

    cooling_deadzone:
      name: Cooling Deadzone
      description: Select the cooling deadzone temperature input_number helper
      selector:
        entity:

    hvac_entity:
      name: HVAC Entity
      description: Select the HVAC entity to control.
      selector:
        entity:

    temperature_entity:
      name: Temperature Entity
      description: Select the temperature sensor entity.
      selector:
        entity:


#
    below_deadzone_actions:
      name: Low prices and temperature BELOW thermostat deadzone
      description: Actions to perform.
      default: []
      selector:
        action:
          - service: climate.set_temperature
            target:
              entity_id: !input climate.entity
            data_template:
              temperature: "{{ states('input_number.heating_deadzone') | float + states('input_number.thermostat_entity') | float }}"
          - service: climate.set_hvac_mode
            target:
              entity_id: !input climate.entity
            data:
              hvac_mode: 'heat'
          - service: climate.set_fan_mode
            target:
              entity_id: !input climate.entity
            data:
              fan_mode: 'low'
#
    within_deadzone_actions:
      name: Low prices and temperature WITHIN thermostat deadzone
      description: Actions to perform.
      default: []
      selector:
        action: {}
#
    above_deadzone_actions:
      name: Low prices and temperature ABOVE thermostat deadzone
      description: Actions to perform.
      default: []
      selector:
        action: {}


trigger:
  - platform: state
    entity_id: sensor.electricity_price
  - platform: state
    entity_id: !input temperature_entity

condition:
  - condition: template
    value_template: >-
      {{ price_levels.index(states('sensor.last_known_price_level')) <= price_levels.index('VERY_CHEAP') }}

action:
- variables:
    levels: ['VERY_CHEAP', 'CHEAP', 'NORMAL', 'EXPENSIVE', 'VERY_EXPENSIVE']
    price: !input price_sensor
    price_threshold: !input price_threshold
    price_changed: '{{ trigger.alias == "price" }}'
    price_level: '{{ states("sensor.last_known_price_level") }}'
    price_is_low: '{{ price_level in levels and levels.index(price_level) <= levels.index(price_threshold) }}'
    thermostat: !input thermostat_entity
    thermostat_changed: '{{ trigger.alias == "thermostat" }}'
    temperature: !input temperature_entity
    temperature_changed: '{{ trigger.alias == "temperature" }}'
    temperature_is_low: '{{ states(temperature) | float < states(thermostat) | float }}'
    temperature_is_ok: '{{ states(temperature) | float >= states(thermostat) - states(heating_deadzone) | float and states(temperature) | float <= states(thermostat) + states(cooling_deadzone) | float }}'
    temperature_is_high: '{{ states(temperature) | float > states(thermostat) + states(cooling_deadzone) | float }}'

- choose:
  - conditions:
    - condition: and
      conditions:
      - '{{ price_changed }}'
      - '{{ levels.index(trigger.to_state.attributes.price_level) <= levels.index(price_threshold) }}'
      - '{{ levels.index(trigger.from_state.attributes.price_level) > levels.index(price_threshold) }}'
      - '{{ temperature_is_low }}'
    sequence: !input below_deadzone_actions
  - conditions:
    - condition: and
      conditions:
      - '{{ price_changed }}'
      - '{{ levels.index(trigger.to_state.attributes.price_level) > levels.index(price_threshold) }}'
      - '{{ levels.index(trigger.from_state.attributes.price_level) <= levels.index(price_threshold) }}'
      - '{{ temperature_is_ok }}'
    sequence: !input within_deadzone_actions
  - conditions:
    - condition: and
      conditions:
      - '{{ price_changed }}'
      - '{{ levels.index(trigger.to_state.attributes.price_level) > levels.index(price_threshold) }}'
      - '{{ levels.index(trigger.from_state.attributes.price_level) <= levels.index(price_threshold) }}'
      - '{{ temperature_is_high }}'
    sequence: !input above_deadzone_actions
mode: restart

That is code formatted for the forum much better, but did you read this?

I’ve probably looked at some poor examples and drifted off from reality at that point ◑﹏◐

The goal was to create a “pre-set” actions setting to make the setup and use of the blueprint easier - not having to manually choose call service, entity etc.

I’ll have to reevaluate the possibilities

You are adding a default. All the stuff after action: goes in the default key instead of default: []

You can put anything you want in there, it doesn’t have to actually work.

Just know that the !input key will show as !input and not render.

I almost understand. I’m a bit out of my comfort zone at this point :slight_smile:

It doesn’t help that the guidelines aren’t up-to-date with quite a few deprecated examples :smiley:

such as

I just found your post on the matter of Studio Code Server flagging various things as wrong erroneously so I take it back :slight_smile:

The point is I find problems all the time and I push issues to whomever to fix them or get them fixed. If there was a problem we can get it fixed.

It’s all part of open source.

From what I gather then, I cannot create a blueprint with multiple different selectors to achieve what I want.

The goal was, from my wild code, to narrow down the choices and pre-define suitable actions for each scenario.

You could. Just put a working action in an action selector when you generate the automation that will be run using the BP.

Your next question will be can you put !inputs in there, possibly, I haven’t tried it. You should test that if you want to use it.

1 Like

I’m looking at template, but that’s a whole new world to me:

    below_deadzone_actions:
      name: Actions to Perform When Below Deadzone
      description: Actions to perform when temperature is below deadzone.
      selector:
        template: |
          {{
#          Listing a bunch of selectors here.
            - service: climate.set_temperature
              target:
                entity_id: !input climate_entity
              data_template:
                temperature: "{{ states('input_number.heating_deadzone') | float + states('input_number.thermostat_entity') | float }}"
          }}
      default: []

You mentioned to put a working action in an action selector, could you provide some sample of such a layout?

I played around with this because curious. Apparently the code segment you plug in does have to render. and as I suspected !inputs cannot go in the default because they will not render. So you can do this…

    tap_1:
      name: Single click on Button 1 action
      default:
        - service: climate.set_temperature
          target:
            entity_id: climate.entity
          data_template:
            temperature: "{{ states('input_number.heating_deadzone') | float + states('input_number.thermostat_entity') | float }}"
        - service: climate.set_hvac_mode
          target:
            entity_id: climate.entity
          data:
            hvac_mode: 'heat'
        - service: climate.set_fan_mode
          target:
            entity_id: climate.entity
          data:
            fan_mode: 'low'
      selector:
        action: {}
    doubletap_1:

Then you have most of your code that you can edit when you set up the automation that you will run. change the climate entity and delete the ones you don’t want.

Basically just like you figured out how to do for the rest of the defaults in your code.

Defaults go into defaults: key section, not random places in your code.

Thank you!

This opened up ideas.
Base idea is that many (most?) Home Assistant users require more pre-defined automation setups.

Every BP I do has it’s own helper file in Markdown and a long (short version) of that in the description. It fends off a lot of stupid questions. I just make sure everything they need to know and samples of what they need to add for this or that are there. I even wrote some script blueprints that they can use to build scripts because people were having trouble telling a script and an automation apart.
After that, whe I still get a ‘stupid’ question I thought was obvious, I edit things based on that question to prevent the question again, and look left-right to make sure my other BP’s won’t have that question.

Basically I don’t want to have questions that need answer. Less stress. Answering the same one over and over is definitely not an activity on my good list.

If you think I have helped solve your problem in one of my posts, would you be so kind as to click solution?