0.113: Automations & Scripts, and even more performance!

A couple of quick optimizations:

  trigger:
  - entity_id: sensor.remote2
    platform: state
  - entity_id: sensor.remote4
    platform: state

can be:

  trigger:
  - entity_id:
    - sensor.remote2
    - sensor.remote4
    platform: state
          - condition: template
            value_template: "{{ states[trigger.to_state.domain][trigger.to_state.object_id].state  == 'Button A' }}"

can be:

          - condition: template
            value_template: "{{ trigger.to_state.state == 'Button A' }}"
1 Like

Partial echo. :wink:

1 Like

Probably a better way to implement this is:

- trigger:
  - platform: state
    entity_id: binary_sensor.laundry_door_sensor
    to: 'on'
  action:
  - service: light.turn_on
    entity_id: light.laundry_lights
- trigger:
  - platform: state
    entity_id: binary_sensor.laundry_door_sensor
    to: 'on'
    for: '00:05'
  - platform: state
    entity_id: binary_sensor.laundry_door_sensor
    to: 'off'
  action:
  - service: light.turn_off
    entity_id: light.laundry_lights
1 Like

Thank you, I appreciate the feedback.

Thatā€™s the first time Iā€™ve seen multiple triggers defined that way. Thatā€™s always been available? How have missed this?!? :man_facepalming: Iā€™m going to have to experiment with it.

No, those are two automations.

Great tip!!

Well OK then. At least I didnā€™t sleep through some major enhancement.

If thatā€™s two separate automations, why are the trigger options hyphenated?

To clarify, by hyphenating the two trigger statements, it gives me the impression I can have a single automation that supports multiple ā€œsub-automationsā€ where each has its own set of trigger/condition/action.

The assumption was the original code snippet (and hence my suggested change) was in the default automations.yaml file, which must contain a list of automations, where the start of each automation begins with a dash, which delineates a new list element.

I could have suggested this:

automation:
- trigger:
  ...
- trigger:
  ...

to try and make it clearer, but then people try putting the first line (automation:) into automations.yaml, too, and of course, that doesnā€™t work.

You canā€™t win here! :wink:

OK, I see what you did there now.

I jumped the gun and assumed that was all part of a single automation, something like this:

- alias: this does not work
  - trigger:
    - platform: state
      entity_id: input_boolean.test
      to: 'on'
    action:
    - service: light.turn_on
      data:
        entity_id: light.test
        brightness_pct: 50
  - trigger:
    - platform: state
      entity_id: input_boolean.test
      to: 'off'
    action:
    - service: light.turn_off
      entity_id: light.test

That fails to pass Configuration Check (as one would expect). Nope, ā€œsub-automationsā€ are just me misinterpreting what you posted.

Tried this and nothing in the logs as to what failed.

not sure if itā€™s related to this bug :bug: here

Can you be sure it doesnā€™t open or ist maybe just hidden behind another pop-up/modal?

Could this not be further contracted to ? : -

  trigger:
    - platform:state
      entity_id: sensor.remote2, sensor.remote4

Again using pre gui ordering ?

A few notes regarding 0.133.1 not starting up for me. I gave it a retry with the debug logging enabled, and here are notes from my log.

2020-07-25 10:36:56 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=camera.radar, old_state=None, new_state=<state camera.radar=idle; access_token=<snip>, friendly_name=Radar, entity_picture=/api/camera_proxy/camera.radar?token=<snip>, supported_features=0 @ 2020-07-25...>>
2020-07-25 10:36:56 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1684740016] Error handling message: Unknown error
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/connection.py", line 95, in async_handle
    handler(self.hass, self, schema(msg))
  File "/home/homeassistant/.homeassistant/custom_components/browser_mod/connection.py", line 36, in handle_update
    devices[deviceID].update(msg.get("data", None))
  File "/home/homeassistant/.homeassistant/custom_components/browser_mod/connection.py", line 76, in update
    self)
  File "/home/homeassistant/.homeassistant/custom_components/browser_mod/helpers.py", line 30, in create_entity
    adder = hass.data[DOMAIN][DATA_ADDERS][platform]
KeyError: 'sensor'

I see the error is from browser_mod. Iā€™m using 1.1.1 which was apparently updated for 0.113 so obviously I canā€™t be sure this is a ā€œcoreā€ issue or a custom component issue. The camera is an image from a web link:

camera:
  platform: generic
  still_image_url: https://<url>/current.png
  name: Radar

I do have Kodi elements but them seem to come up. I didnā€™t try remote use, but the entities were created and no issues logged.

I get these for zwave in the logs, but the network doesnā€™t start:

2020-07-25 10:36:51 INFO (MainThread) [homeassistant.components.zwave] Z-Wave USB path is /dev/ttyACM0
2020-07-25 10:36:51 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=zwave, service=start_network>
2020-07-25 10:36:52 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=zwave>
2020-07-25 10:36:52 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.zwave
2020-07-25 10:36:52 INFO (MainThread) [homeassistant.components.cover] Setting up cover.zwave
2020-07-25 10:36:52 INFO (MainThread) [homeassistant.components.light] Setting up light.zwave
2020-07-25 10:36:52 INFO (MainThread) [homeassistant.components.switch] Setting up switch.zwave
2020-07-25 10:36:52 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=config.zwave>
2020-07-25 10:36:55 INFO (MainThread) [homeassistant.components.climate] Setting up climate.zwave
2020-07-25 10:36:55 INFO (MainThread) [homeassistant.components.fan] Setting up fan.zwave
2020-07-25 10:36:55 INFO (MainThread) [homeassistant.components.lock] Setting up lock.zwave

This is the only other error I see ā€“ Iā€™m using an alarm decoder and Iā€™ll have a look at all the sensors derived from this to make sure theyā€™re gated with availability.

2020-07-25 10:36:35 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=alarm_control_panel.alarm_panel, old_state=<state alarm_control_panel.alarm_panel=unknown; code_format=number, changed_by=None, code_arm_required=True, ac_power=None, backlight_on=None, battery_low=None, check_zone=None, chime=None, entry_delay_off=None, programming_mode=None, ready=None, zone_bypassed=None, friendly_name=Alarm Panel, supported_features=7 @ 2020-07-25...>, new_state=<state alarm_control_panel.alarm_panel=disarmed; code_format=number, changed_by=None, code_arm_required=True, ac_power=True, backlight_on=True, battery_low=False, check_zone=False, chime=False, entry_delay_off=False, programming_mode=False, ready=True, zone_bypassed=False, friendly_name=Alarm Panel, supported_features=7 @ 2020-07-25...>>
2020-07-25 10:36:36 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1712658256] Error handling message: Unknown error
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py", line 229, in async_render
    return compiled.render(kwargs).strip()
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/srv/homeassistant/lib/python3.7/site-packages/jinja2/sandbox.py", line 407, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'None' has no attribute 'attributes'

Yes, that would save a couple of lines, but itā€™s still one trigger vs two.

Two.?
No, Iā€™m not going where Taras may have been (to be honest I think he was just commenting on they way you answered another post (canā€™t remember and too busy/not interested to check :rofl))
Two trigger keys are definitely not allowed
Two trigger entities under one trigger key : good

I feel like Iā€™m quoting Animal Farm
4 legs good, two legs bad
:rofl:

Does anyone know how to style the font in recently updated elements (popup header, popup history, popup attributes & Configure UI menu)?

screenshot
configureUI

no it really is an error:

somehow this code in the card doesnt work anymore:

      card.querySelector('#temp').addEventListener('click', event => {
        fireEvent(this, "hass-more-info", { entityId: aplSensor.config });
      });

(this is for another, manually added, querySelector, but the doesnā€™t matter, even the ā€˜officialā€™ cards coded selectors donā€™t work (do nothing but throw an error) where they before opened the more-info with the specified sensor.)

Yeah, thatā€™s an option. However, I need the light to turn off if the door is closed. Yours would still wait 5 mins before the light is turned off when the door is closed.

What I would like to do is to set the delay or a for condition against the trigger sensor itself. This way, I can add a condition in the choose section to determine if I should turn the light off based on the door being left open or another condition (such as no motion in the room for 3 min using a motion sensor).

Anyone seeing this when clicking through the tabs in dev tools?

2020-07-26 00:05:30 ERROR (MainThread) [frontend.js.latest.202007160] http://192.168.77.67:8123/frontend_latest/chunk.cf565e41b8a8dce0642a.js:133:204 TypeError: this.shadowRoot.querySelector(...) is null

Everything works, just a hint.