0.103 - Undocumented Breaking Change?

One of the first things I did nearly two years ago in HA was my garden irrigation. We have plenty of rain here at the moment so I am not currently using it but other people it seems, are.

Yesterday I saw someone posted that it had broken in a small easily fixed way after upgrading to v0.103.

I’m just wondering if this is a (un)known breaking change because I didn’t see anything about it and in any case I thought everything passed between scripts were strings.

I call a script like this:

      - service: script.update_next_runtime
          cycle: 1

the called script might use the cycle number like this:

      - service: input_text.set_value
          entity_id: 'input_text.cycle{{ cycle }}_current_zone'

Which I am told is causing a type error:

TypeError: can only concatenate str (not "int") to str

And that changing it to

      cycle: '1'

fixes the problem.

Maybe you’ll say it is just something that has been rectified and that I shouldn’t have been doing that way in the first place (which I suppose could be a fair comment). But I’m interested if something changed?

Anyway as I said I haven’t checked this directly but the original post is here: My Garden Irrigation

I can’t tell if you’re saying you’re actually getting a TypeError, or if you’re just worried that you might run into a problem.

The value passed into the script, given the way you’re calling it, will be an int. However, once you do {{ cycle }}, that will return a string, which will be substituted into the larger string. I don’t see where you are or will have a problem.

I personally haven’t had a problem but then I haven’t run this for a couple of months.

The person who posted in the topic I linked to had the problem and says he fixed it by changing the value passed, to a string.

I was surprised there was a problem too which is why I’m asking. The other poster does show the error message…

I’d have to look at the code. I see reference to a file named garden_irrigation.yaml, but the topic is too long for me to try and find it. If you can point me at it maybe I can explain why they got that TypeError.

You can find it on my GitHub (which is a snapshot of some of my code at a moment in time purely as a convenient way to share it, not a true ‘live’ repository).

Ok, I can see where passing cycle as in int would cause a problem with this:

      #=== Turn off schedule if run 'Once' selected
      - service_template: >
            {% if states('input_select.cycle' + cycle + '_watering_days') == 'Once' %}
            {% else %}
            {% endif %}
          entity_id: input_boolean.cycle{{ cycle }}_enable
'input_select.cycle' + cycle + '_watering_days'

should be

'input_select.cycle' ~ cycle ~ '_watering_days'

As far as I know, that would always have caused a problem if the cycle argument was an int.

I can’t check now to be 100% sure but think I probably used ‘+’ instead of ‘~’ a lot in that package and there are a few other people using it as well so I’m surprised the error hasn’t come up before now…

If you called the script with cycle as a string, it would not have caused an exception.

Bottom line, you can’t concatenate a str and an int using +. In Jinja you can do it with ~, which means convert the operands to str first, then concatenate. This is not new, no matter how “lucky” you might have been before. :wink:

1 Like

Another one? remote.toggle was working partially. But now it stopped working almost at all.

in docs example:

  - service: remote.turn_on
    entity_id: remote.bed_room_hub
       activity: "Watch TV"

In my code:

    action: call-service
    service: remote.toggle
    entity: remote.logitech_harmony
       activity: TV

return error:

Failed to call service remote/toggle. must contain at least one of entity_id, area_id.

In Dev Tolls

return error:

Failed to call service remote/toggle. extra keys not allowed @ data[‘data’]

Can find no word about this Breaking Change. Only about some docs changings (replacement from remote to harmony).

In “my code” you have entity instead of entity_id.

In “Dev Tolls” you have one too many data:'s. Under “Service Data” you should just have:

entity_id: remote.logitech_harmony
activity: TV

In DevTools it works, thank You.
But in code switching to entity_id do not help. Still the same error. Moreover, I double checked in backup and previously, when it worked, I had entity.

Full new code:

  action: call-service
  service: remote.toggle
  entity_id: remote.logitech_harmony
    activity: Audio

Oh, that’s Lovelace. I think it should be:

  action: call-service
  service: remote.toggle
    entity_id: remote.logitech_harmony
    activity: Audio

Oh, yes. It does work. Thank You.
But meantime I double checked how it was previously when it work. This is screenshot from backup file:

Anyway, thanks for the help. Pity that remote.toggle do not work still in 100% but at least works as previously.