Are YAML statements static or dynamic?

I’m a completely NOOB, and trying to read and understand all the moving parts of Home Assistant.

I have an automation to turn off lights at 11PM plus a random delay of 1-20 Minutes 1-59 seconds. It works great (in testing anyhow).

Since I understand YAML to be a configuration / compiled “language”, will my delay statement below be re-evaluated each time the automation triggers, or just every time Home Assistant restarts?

Sorry if this seems like a stupid question, but I couldn’t find it anywhere here, on google, or in the documentation.

-Eric

# Random timer to turn off lights.
- alias: 'turn_lights_off'
  trigger:
  - platform: time
    at: '23:00:00'
  action:
    - delay: '00:{{ (range(1, 20) | random | int) }}:{{ (range(1,59) | random | int) }}'
    - service: light.turn_off
      entity_id: light.living_room
    - service: light.turn_off
      entity_id: light.office

The template you have assigned to delay is evaluated each time the automation’s action is executed at 23:00.

Perfect! Thank you!

Regards,
-Eric

You can call light.turn_off once to turn off both lights.

# Random timer to turn off lights.
- alias: 'turn_lights_off'
  trigger:
  - platform: time
    at: '23:00:00'
  action:
    - delay: '00:{{ range(1, 20) | random }}:{{ range(1,59) | random }}'
    - service: light.turn_off
      entity_id: light.living_room, light.office

EDIT

In addition, the int filter isn’t needed. The result produced by random is already an integer value.

These lights are X10 controlled using Heyu. I have had trouble with X10 in the past if commands weren’t serialized. Maybe Home Assistant will take care of batching the commands. I will have to test it.

Thanks, good do know the multiple entity_id syntax.

Regards,
-Eric

X10? I used Smarthome Smartlinc X10 switches for many years. Over time they all failed due to one reason or another (broken rocker button, loses programming, fails to respond to commands, etc). Otherwise, communications reliability was acceptable after I installed a phase-coupler.

I recently replaced all of them with UPB switches and performance is excellent (and they are easier to program and manage). However, I still use X10 plugs (I have over a dozen of them) to control holiday lighting (they sit in drawer the rest of the year). The one X10 plug that is used throughout the summer is a heavy-duty 220V plug that controls the pool pump (for well over a decade).

Whether you turn off the two lights using two separate service calls or just one, it won’t make a difference in how Home Assistant sends commands to HeyU

Yes, I have a ton of X10 modules (use them for holiday lights too), and they still work great thanks to all the help from the open source community. I control it all from a RPI.

I wouldn’t use x10 for anything critical, because basically anytime somebody plugs in or unplugs something, it changes the network, and introduces risk. But for non-critical items it works great.

-Eric

Like I said, I have been using it to reliably control a 220VAC 1.5 HP pool pump for over ten years. The pump’s operation is fairly critical, more so than lighting, and has a proven track record.

Can you elaborate on what you mean when you say it ‘changes the network’?

If I unplug an X10 module, its absence only affects whatever device is connected to it (much like a Wi-Fi based module). Its disconnection doesn’t impact any other X10 device.

I’m certainly not an expert in this area, but X10 signals travel through the A/C network of your home, not just to the X10 modules. All devices have the ability to weaken the X10 signal. Also, typical homes in US are wired on 2 phases of the incoming AC line, so you will sometimes need a phase coupler to bridge from on phase to the other.

I have had situations where everything works, and somebody plugs in a surge protector, and all of a sudden some X10 modules are no longer functioning. I then have to move the X10 transceiver to another outlet until I find one that works.

There is quite a bit of info on the web on these issues, and I think Insteon solved many of them (maybe with synchronous, stateful communication, I don’t know).

Here is one piece of info on it.

http://kbase.x10.com/wiki/Troubleshooting_X10_Home_Automation

-Eric

I guess the fact that at one time I had over two dozen X10 devices all working fairly well (for X10), including one critical device that never missed a beat in over ten years over operation, has failed to make an impression on you. :man_shrugging:

If you review my previous post, you’ll see I do (did) have an X10 phase coupler installed (it’s a UPB phase coupler now). Unless you have the controller and all X10 devices on the same phase (unlikely), to reach the other phase the X10 signal must travel out of your home to the nearest transformer and back to your home on the other phase. By the time it returns it has been attenuated and possibly even altered. That’s why it’s recommended to install a phase coupler for any powerline-bus based communications protocol (X10, UPB, etc) to ensure reliability.

Yes, X10 signals are attenuated by each X10 device, especially on the same circuit. The nth module on the same circuit (last one in the chain) is likely to receive the weakest signal.

The CM11A controller doesn’t produce a very strong signal. The only other controller I have experience with is the PSC05 and it’s hardly better than the CM11A (I have no experience with other models, such as the CM15A and CM17A). It’s important that whatever circuit it’s plugged into has no source of electrical noise or else the CM11A’s weak signal will be swamped. I have an X10 Maxi Controller (SC503) which is a remote-control that lets you manually control any X10 device (on any House Code) Without fail, the command it sends is received by any device including marginal ones (in the case of too many X10 devices on the same circuit). In contrast, the CM11A’s command might be missed occasionally by the same marginal devices.

All powerline-bus based communication systems benefit from isolating sources of electrical noise. Switching power supplies are common and a usual source of electrical interference. For example, a microwave oven not only interferes with Bluetooth and Wi-Fi communications (via its EM emissions in the 2.4 GHz range) but also with powerline-bus systems (via its internal switching power supply).

Both UPB and Insteon are powerline-bus based (Insteon also support RF) and correct X10’s deficiencies by using stronger signal voltages (and other things). My preference was UPB mostly because I started looking at the two technologies around 2008 when Insteon was in its infancy and proving to be far less capable and reliable then what was promised (at the time). In addition, even my oldest UPB switch (from Simply Automated; over ten years old) still works reliably, whereas most of my Smarthome Smartlinc switches developed failures (same company that developed Insteon).

The problems you’ve described are the same ones I had. I resolved most, but not all, of them using the techniques I’ve described. However, I ultimately chose to retire all my X10 light switches in favor of UPB. The only X10 devices that remain are the dozen or so modules that come out once or twice a year to control holiday lighting and the module that controls the pool pump twice daily for 4 months a year.

All my working/sort-of-working/not-working X10 switches now reside in a box of tangled devices. I can’t be bothered to post them on Kijiji so I will eventually need to visit my community’s recycling depot …

Good luck with your X10 adventure. :slight_smile:

Thanks. I appreciate your help. I will check out UPB, as I need to get off this X10 stuff at some point. For now it is free, but if I start to have a lot of HW failures, I will have to consider alternatives.

One nice thing about the new alternatives, including UPB from what I’ve read, is that they are stateful. That is nice, since X10 could not be polled for state, and anything turned on/off via another method, Home Assistant wouldn’t know about it.

-Eric