Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automations with value_template get corrupted by the Automation Editor #5038

Closed
3 tasks done
marcelvandongen opened this issue Mar 1, 2020 · 3 comments
Closed
3 tasks done
Labels
Bug Current Bug in UI - Extra Attention stale

Comments

@marcelvandongen
Copy link

Checklist

  • I have updated to the latest available Home Assistant version: 0.107.0dev20200222
  • I have cleared the cache of my browser.
  • I have tried a different browser to see if it is related to my browser: Chrome and Edge.

The problem

I use automations for the Xiaomi Magic Cube, with a condition that uses a value_template. When I use the Automation Editor in the Frontend and save the automation, the value_template get corrupted. From this:

- alias: Brightness up with Cube
  id: '1585630664465'
  description: ''
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube_woonkamer
  condition:
    condition: template
    value_template: >
      {{ trigger.event.data.gesture == 7 }}
  action:
  - data:
      brightness_step_pct: 10
    entity_id: light.71448200bcddc29c5799
    service: light.turn_on

To this:

- alias: Brightness up with Cube
  id: '1585630664465'
  description: ''
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube_woonkamer
  condition:
    condition: template
    value_template: '{{ trigger.event.data.gesture == 7 }}

      '
  action:
  - data:
      brightness_step_pct: 10
    entity_id: light.71448200bcddc29c5799
    service: light.turn_on

If the value_template contains multiple, longer lines (e.g. flip90) it goes from this:

  condition:
    condition: template
    value_template: >
      {% set valid_events = [1002, 1003, 1004, 1005, 2001, 2003, 2004, 2006, 3001, 3002, 3005, 3006, 4001, 4002, 4005, 4006, 5001, 5003, 5004, 5006, 6002, 6003, 6004, 6005] %}
      {{ trigger.event.data.event in valid_events }}

to this:

  condition:
    condition: template
    value_template: '{% set valid_events = [1002, 1003, 1004, 1005, 2001, 2003, 2004,
      2006, 3001, 3002, 3005, 3006, 4001, 4002, 4005, 4006, 5001, 5003, 5004, 5006,
      6002, 6003, 6004, 6005] %} {{ trigger.event.data.event in valid_events }}

      '

So it will also break off any lines longer than about 80 characters. Even worse, it corrupts all the automations in my yaml file.

Expected behavior

The Automation Editor should be aware of value_templates and the '>' sign and not add the extra lines at the end, and also not split up lines longer than about 80 characters.

Steps to reproduce

  1. Add the first automation in the problem description to your automation.yaml file
  2. From Server Controls, choose RELOAD AUTOMATIONS
  3. Edit an automation using the Automation Editor and be sure to change something and save it
    (just add an 'a' somewhere and delete it)
  4. Reopen your automation.yaml file

Environment

  • Home Assistant release with the issue: tested 0.103.6 and 0.107.0
  • Last working Home Assistant release (if known): unknown
  • UI Type (States or Lovelace): Lovelace
  • Browser and browser version: Chrome 79 and Edge 42
  • Operating system: Windows 10 1803

Problem-relevant configuration

automation:
- alias: Brightness up with Cube
  id: '1585630664465'
  description: ''
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube_woonkamer
  condition:
    condition: template
    value_template: >
      {{ trigger.event.data.gesture == 7 }}
  action:
  - data:
      brightness_step_pct: 10
    entity_id: light.71448200bcddc29c5799
    service: light.turn_on

Javascript errors shown in your browser console/inspector

No errors.

Additional information

Xiaomi Magic Cube gesture 7 is clockwise rotation (8 is counter clockwise).

@stale
Copy link

stale bot commented May 30, 2020

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 30, 2020
@TheEris
Copy link

TheEris commented Jun 3, 2020

This is still a problem in the 0.110.4

@stale stale bot removed the stale label Jun 3, 2020
@stale
Copy link

stale bot commented Sep 2, 2020

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 2, 2020
@stale stale bot closed this as completed Sep 9, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Current Bug in UI - Extra Attention stale
Projects
None yet
Development

No branches or pull requests

2 participants