Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Help with passing position to script

$
0
0

@Felix8806 wrote:

Hi All,

I have made an automation to close blinds half way when the sun is too intensive and UV index is above 1 in two sunny rooms (each has its own cover). I would like to close the blinds half way from where they are, each time the automation starts. Ultimately, either the temperature in the sunny rooms stabilizes, or the automation would completely close the blinds.

Here is the automation entry (automation.yaml).

I have spent hours searching for the error and cannot find it. If I put a number in the first action service, such as 50, it works very well. But as soon as I set the expression, it fails with the following error:

Error executing script script.1583004153017. Invalid data for call_service at pos 1: expected int for dictionary value @ data['position']

In the template editor screen, the expressiion : {{ ((0 + states.cover.kitchen_blinds_controller.attributes.current_position )/2)| int}} gives the value 23.

- id: '1570981684762'
  alias: BLINDS DOWN - All, Partial - On_Strong_Light_or_Too_Hot
  description: Both covers (SOMFY and Kitchen) down partially when light too high
  trigger:
  - above: '1200'
    entity_id: sensor.terrasse_nord_illuminance
    for: 00:03:00
    platform: numeric_state
  condition:
  - condition: and
    conditions:
    - condition: or
      conditions:
      - condition: template
        value_template: '{{  states.cover.kitchen_blinds_controller.attributes.current_position  |
          int > 40 }}'
      - condition: template
        value_template: '{{ states.cover.time_based_cover_2.attributes.current_position
          | int > 40 }}'
    - above: '1'
      condition: numeric_state
      entity_id: sensor.dark_sky_uv_index
    - above: '25.0'
      condition: numeric_state
      entity_id: sensor.terrasse_nord_temperature
  action:
  - data:
      mycover: cover.kitchen_blinds_controller
      set_position: '"{{ ((0 +  states.cover.kitchen_blinds_controller.attributes.current_position
        )/2)| int}}"'
    service: script.1583004153017
  - data:
      mycover: cover.time_based_cover_2
      set_position: '"{{ ((0 +  states.cover.time_based_cover_2.attributes.current_position
        ) /2)|int}}"'
    service: script.1583004153017
  - data:
      message_title: BLINDS DOWN - All, Partial - On_Strong_Light_or_Too_Hot
    service_template: script.{% if states.input_select.notify_fh_on_events.state ==
      'info'%}1582713804730{%else%}1582707732926{%endif%}
  - data:
      option: weather_dependant
    entity_id: input_select.blinds_auto_close
    service: input_select.select_option

Any help to figure where the error is would be great…

Thanks in advance,
Felix

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>