[CHALLENGE] GUI vs Hand Crafted

This could read ‘newbies’ vs ‘old-farts’ (with myself in the ‘old fart’ category) but this does not sum up the two camps.
Decide for yourself. (note there was some heavy editing to acheive this from my system, there ‘may’ be mistakes :hot_face: which I shall try to correct).

I belong to the group who believe that the GUI AE (Automation Editor / Device Editor - whatever the official term) is a tool to allow people who do not want to ‘get too involved’ in the ,nitty gritty, to set up simple automations etc. – turn this light on at this time, turn this on at sunset, turn this off two hours before dawn etc.
From this it will generate code that the user looks at, so that when their needs become greater they can work out what ‘could’ be the possible ways of achieving that. (This assumes they look). And that by learning in this way they read other people’s examples and ‘extend’ into more complex arrangements (in line with their growing need for it)
I apologise to Mobisat for using him as an example of the ‘newbie effect’ but his recent thread crystallised my thoughts and was the trigger for this topic.

He has grown since he first appeared and is less adversarial to the ‘traditional coding methods’ but I still feel that he comes across as affronted / frustrated / resentful that he can’t do what he wants to do and that we are pushing him down a path that he does not want to adopt.

So my challenge is “Can any GUI Guru replicate the functionality he requires in that thread ?
If not, it seems that we are acknowledging that the GUI Editor is a crutch to help newbies BUT they should be advised of such so they do not exclusively rely on it and actively learn how to support themselves. And also not annoy the people who are trying to help them. (i.e. – read Tinkerer’s Sticky).
So to restate the problem; he wants to know how to record when his boiler was last ‘on’ and also when it was last ‘off’ – further, he wants to display it a particular format.
So stealing from the work that Taras and I did on that thread : -
(I’m sure that these could probably be polished further (feel free to suggest any improvements :smiley: ) )
Capturing the event times -

input_datetime:
  id_boiler_last_on:
    name: Boiler Last On Time
    has_date: true
    has_time: true
  id_boiler_last_off:
    name: Boiler Last Off Time
    has_date: true
    has_time: true

automation:
  - alias: 'Boiler state time'
    trigger:
      platform: state
      entity_id: switch.boiler
    action:
      service: input_datetime.set_datetime
      data_template:
        entity_id: input_datetime.id_boiler_last_{{ trigger.to_state.state }}
        datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"

The ‘times’ then appear as “2020-05-17 18:51:48” and will remain fixed until updated by the automation

Okay, this got the ‘times’ but it’s not very easy to work out how long ago each of those were so you ‘could’ set up a sensor to display that information, Along the lines of : -

sensor:
  - platform: template
    sensors:
      s_boiler_last_on:
        entity_id: sensor.time, input_datetime.id_boiler_last_on
        friendly_name: Boiler Last On
        value_template: >
          {% set dif = as_timestamp(now()) - as_timestamp(states('input_datetime.id_heat_last_on')) %}
          {% set ds = (dif // (24*60*60)) | int %}
          {% set sdif = dif | timestamp_custom('%H:%M' ,false) %}
          {{ ds ~ ' days ' ~ sdif }}
        icon_template: "{{ 'mdi:clock' }}"
      s_boiler_last_off:
        entity_id: sensor.time, input_datetime.id_boiler_last_off
        friendly_name: Boiler Last Off
        value_template: >
          {% set dif = as_timestamp(now()) - as_timestamp(states('input_datetime.id_heat_last_off')) %}
          {% set ds = (dif // (24*60*60)) | int %}
          {% set sdif = dif | timestamp_custom('%H:%M' ,false) %}
          {{ ds ~ ' days ' ~ sdif }}
        icon_template: "{{ 'mdi:clock-outline' }}"

These give you time since last on/off e.g. “2 days 14:06” and will update every minute to re-evaluate.
(I think, if I wrote this again I’d take the ‘year’ subtract 1970 and multiply by 365 and add %j -1 (not 100% sure though) - Edit: I changed it to accomodate years (i.e. allow days > 365, well, you never know ! ).

But Mobisat wanted a specific format so let’s go with that, either way we need to capture the result in some way, we used input_datetime’s above (but we ‘could’ have used input text’s and populated the result in there). So the sensors become : -

sensor:
  - platform: template
    sensors:
      s_boiler_last_on:
        entity_id: input_datetime.id_boiler_last_on
        friendly_name: Boiler Last On
        value_template: >
          {% set tstmp = as_timestamp(states('input_datetime.id_boiler_last_on')) %}
          {{ tstmp | timestamp_custom('%d-%m-%Y %H:%M') }}
      s_boiler_last_off:
        entity_id: input_datetime.id_boiler_last_off
        friendly_name: Boiler Last Off
        value_template: >
          {% set tstmp = as_timestamp(states('input_datetime.id_boiler_last_off'))) %}
          {{ tstmp | timestamp_custom('%d-%m-%Y %H:%M') }}

This gives you : “17-05-2020 17:51:13” and will remain fixed until updated by the automation

And for the input_text’s (with just minor adjustments to the original automation) becomes : -
input_text:

input_text:
  it_boiler_last_on:
    name: Boiler Last On Time
        icon_template: "{{ 'mdi:clock' }}"
  it_boiler_last_off:
    name: Boiler Last Off Time
        icon_template: "{{ 'mdi:clock-outline' }}"

automation:
  - alias: 'Boiler state time'
    trigger:
      platform: state
      entity_id: switch.boiler
    action:
      service: input_text.set_value
      data_template:
        entity_id: input_text.it_boiler_last_{{ trigger.to_state.state }}
        value: "{{ as_timestamp(now()) | timestamp_custom('%d-%m-%Y %H:%M') }}"

This gives you : “17-05-2020 17:51:13” and will remain fixed until updated by the automation

Can Anyone Do Any Of That With The GUI ???
If you can (or maybe especially if you can’t) then point people at this thread and get them to understand that ‘hand written’ is sometimes the only way OR Prove Me Wrong (I like to be educated) (other than just by pasting these templates into gaps in the relevant box ! )
So learning templates gets you a LONG way. And the GUI editor is not a panacea.
AND the Template Editor is “your best friend”

Edit: Though finity’s EPIC time manipulation thread is A pretty damn good resource too
Though maybe could do with a follow up topic to simplyfy translating ‘this to that’ with HA entities and attributes.

Read only half-ish of the post then saw your question then mostly skimmed through the rest, sorry about that but my son is in the bath.

But the answer is no.
You can not do it all in the GUI.
I know since I’m still in the GUI and slowly try to work my way out.
I have some automations that works fine but when I open them in GUI there is stuff missing since the equivalent method in GUI does not exist.

I’ll see if I can find that later when I’m done with bath and all other chores.

EDIT I see now that the new version of HA blocks me from opening the automation in GUI instead. I used to be able to open it then not everything was visible.

Wow. Just wow. That kind of elitist and high horse attitude would instantly turn me off if I was a new user. That type of attitude is a main reason why so many open source projects end up failing. Just because it’s free software doesn’t give us the right to act like complete jerks towards newcomers.

FWIW, I like the GUI. I personally think it is the clearly the way forward if we intend to establish HA as a platform available to everybody rather than the ‘geek only, avoid otherwise’ reputation is still has. It’s still too limited at this time, but HA is progressively getting there. When creating a new automation, I always use the GUI first and only fall back to this abomination that is YAML if I absolutely have to.

Oh and I’m a professional software engineer. I write code for a living.

2 Likes

That was not what the point of the topic was. I do not classify myself as an advanced ‘cognoscenti’ or anything like that, merely aware of the issues being faced by ‘newbies’ as I help out on the forum (look at my profile).
If you read “what I said”, I’m pointing out that there is an expectation gap (from the users) and given the current level of the AE (I was also helping out here before it was even launched, and have seen just how far it’s come) it will not be met without a ‘mix and match’ attitude, which is not what we are seeing.

I think you have displayed the ‘wow’ attitude here, I’m trying to advise new users that they ‘may’ not get everything they want from the AE and that they need to commit to learn. As SO many here have had to (including me !) This is about managing expectations.

I’m not impressed that you are a ‘professional software engineer’ I’ve worked with dozens and I can count the ‘good’ ones on the fingers of one hand (and they were VERY good) but I would rate some of the guys here in that league, without any formal training.

Edit: I wish I had such a crutch when I started. BTW we now train assistance dogs so do not consider ‘crutch’ to be a pejorative term, but a tool to achieve ‘more’ than you would unassisted in the same way glasses help me see.

1 Like

And that goes both ways. If your goal is to make a project mainstream, then you will get users that ‘annoy the people who are trying to help them’, as you eloquently put it. That’s why commercial businesses have level 1 support. If you don’t want to be annoyed by these new users, then clearly mark your project as expert only. But that’s not what HA is about, thankfully.

And that wasn’t my intent anyway. I was pointing out that not only newbies use that ‘crutch’. People who know what they’re doing and who are perfectly fine in coding everything manually if needed, will still use the GUI if possible. I don’t think I’m the only one in that respect. We do it because it is convenient. And it will only become more convenient and powerful in the future. And that’s a good thing. Sometimes ‘old farts’ have to learn to let obsolete things go and try to adapt to new ways, even though they might not consider them ideal.

Assistance dogs. Right. It’s really hard to read through your posts keeping on open mind and not be offended to be honest. So I think I’m out of this discussion.

I think you are easily offended then, friend.

Your posts were also offensive, in my opinion.

I agree with OP, the UI is not capable enough at this time to fully replace YAML and PY. And I agree with you, it’s possible to get there eventually. I don’t however understand your attitude toward the OP in this thread, maybe previous encounters?

1 Like

I have grown accustomed to using YAML (Home Assistant was my first exposure to it). My preference is to compose automations in YAML using VS Code with the Home Assistant extension (“Config Helper”). It allows me to do things that the Automation Editor cannot currently do:

  • I can compose complex templates.
  • I can include comments.
  • I can organize my automations by category in separate files.

In addition, the YAML in my automations is organized according to logical flow (triggers then conditions then actions) whereas the Automation Editor sorts YAML statements alphabetically. So if you have a “hand-made” automation file and then use the Automation Editor to add an automation, upon saving, it will erase all your comments and sort everything alphabetically (I learned this empirically). It’s like having the chapters of a novel sorted alphabetically by their title. The information is still there but harder to understand.

If the Automation Editor were able to do the things I listed above, especially the part about creating complex templates, then I would be more amenable to using it (I appreciate the convenience of editing automations via the UI). However, it cannot so that’s why it’s often suggested for use by newcomers, not to be demeaning to them or to disparage Automation Editor, but because it currently has limitations that prevent you from creating anything beyond fairly boiler-plate automations.

1 Like

Now it’s not possible but I can see how it will be possible in future, only thing missing in GUI to set your example is template-sensor

When sensors will be configured from GUI it will look like “Helpers” page but we’ll have field for template and it will work the same

Behind the scenes it will still work same way, but you will only need to think of how to configure template field cause all other settings are obvious

1 Like

When I started HA (for the second time) about a month or two ago, I watched some YouTube videos of Frenck and some of drZzS. One of the tips Frenck gave to learn YAML is to create automations through the GUI and then look at the code. I did that, and couldn’t work with it. The order of the items is irritating and the fact it uses device_id’s instead of entity_id’s is impossible to work with (from a yaml programming perspective). Everybody should know that a GUI is never going to be capable of doing all possible automations people think of. Yaml and jinja is always going to be there for the more complex stuff. So why do they make a GUI that doesn’t create “normal” yaml? Like it is documented on the HA website. Why make it more difficult?

That’s why my vote goes to the Wenite editor instead of the current GUI editor. Wenite creates “normal” yaml. And besides that a node-red like editor, with a visible flow, makes more sense (in my eyes) for newbies then a IFTTT editor.