Command line sensor - friendly name attribute?

Looks like command line sensor doesn’t have friendly name attribute. This would be useful for making automation trigger with multiple sensor.

  - alias: Announce_Door_Window_Automation
    initial_state: true
    trigger:
      platform: state
      entity_id:
        - sensor.Zn_1stFrontDr_Current_Status
        - sensor.Zn_1stKitDr_Current_Status
        - sensor.Zn_BmtFrontDr_Current_Status
        - sensor.Zn_1stLivLTWin_Current_Status
        - sensor.Zn_1stLivRTWin_Current_Status
        - sensor.Zn_1stKitRTWin_Current_Status
        - sensor.Zn_1stKitLTWin_Current_Status
        - sensor.Zn_1stKitMDWin_Current_Status
        - sensor.Zn_BmtLivLTWin_Current_Status
        - sensor.Zn_BmtLivRTWin_Current_Status
        - sensor.Zn_BmtPanRTWin_Current_Status
        - sensor.Zn_BmtPanLTWin_Current_Status
      to: 'OPEN'
    action:
      service: script.announce_script
      data:
        delay: '00:00:07'
        message: "{{ trigger.to_state.attributes.friendly_name }} is {{ trigger.to_state.state }}"

I guess there is a way to do this via customize option:

I tried the customize option, the commandline sensor listed in group are now showing up with their friendly name but the automation action announce message using attribute variable are not recognize. The spoken words just read the code not what the code is suppose to translate to.

You want data_template:, not data:

That instructs HA to parse a template.

You can also set friendly_name in the sensor setup. IE:

  - platform: command_line
    name: SSL cert expiry
    unit_of_measurement: days
    scan_interval: 86400
    command: "ssl-cert-check -b -c /etc/letsencrypt/live/ih8gates.dyndns.org/cert.pem | awk '{ print $NF }'"

yields a friendly_name of SSL cert expiry

1 Like

Thank, that works perfectly.