Notification when truenas app update available

Hi All,

I have recently added the Truenas integration via hacs and wanted to set up an automation that would send me a notification when there is an update for an app that I have running on truenas.

However when I test the condition it does not pass. When I look at the attributes in the developer tools it shows there is an update.

please see the attached images.


can you download the trace and post it here? please use the proper preformatted text option to post it properly (hit the </> button).

This is the trace:

{
  "trace": {
    "last_step": "action/0/choose/0/conditions/0/entity_id/0",
    "run_id": "70709d80a6136d12d17c418f4c775a1a",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-07-28T11:56:35.334855+00:00",
      "finish": "2024-07-28T11:56:35.335453+00:00"
    },
    "domain": "automation",
    "item_id": "1722001115960",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2024-07-28T11:56:35.334890+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.truenas_app_update",
              "state": "on",
              "attributes": {
                "id": "1722001115960",
                "last_triggered": null,
                "mode": "single",
                "current": 0,
                "friendly_name": "Truenas app update"
              },
              "last_changed": "2024-07-28T11:36:17.890139+00:00",
              "last_reported": "2024-07-28T11:36:17.890139+00:00",
              "last_updated": "2024-07-28T11:36:17.890139+00:00",
              "context": {
                "id": "01J3WJ12Q2BAJXEMRCH055WRXB",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-07-28T11:56:35.335136+00:00",
          "changed_variables": {
            "context": {
              "id": "01J3WK67M62NK4X8TB6H9154SV",
              "parent_id": "01J3WK67M6PP06QBP8WG0TA68F",
              "user_id": null
            }
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-07-28T11:56:35.335261+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-07-28T11:56:35.335279+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0/entity_id/0": [
        {
          "path": "action/0/choose/0/conditions/0/entity_id/0",
          "timestamp": "2024-07-28T11:56:35.335294+00:00",
          "result": {
            "result": false,
            "state": 0,
            "wanted_state": "1"
          }
        }
      ]
    },
    "config": {
      "id": "1722001115960",
      "alias": "Truenas app update",
      "description": "Send a notification if there is an app update for truenas apps",
      "trigger": [],
      "condition": [],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "state",
                  "entity_id": "binary_sensor.truenas_apps_photoprism",
                  "attribute": "Container images update available",
                  "state": "1"
                }
              ],
              "sequence": []
            }
          ]
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01J3WK67M62NK4X8TB6H9154SV",
      "parent_id": "01J3WK67M6PP06QBP8WG0TA68F",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Truenas app update",
      "message": "triggered",
      "source": null,
      "entity_id": "automation.truenas_app_update",
      "context_id": "01J3WK67M62NK4X8TB6H9154SV",
      "when": 1722167795.3349257,
      "domain": "automation"
    }
  ]
}

could u go to yaml and post the code for this automation? From the trace it looks like you are looking for the wrong attribute:

See that the attribute here is looking for ‘Container images update available’

I will update it with a new trace as I was playing around with it

Here is the new trace:

{
  "trace": {
    "last_step": "action/0/choose/0/conditions/0/entity_id/0",
    "run_id": "f7d657bb15df217b45c93d314a77cd94",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-08-02T16:39:48.406061+00:00",
      "finish": "2024-08-02T16:39:48.406630+00:00"
    },
    "domain": "automation",
    "item_id": "1722001115960",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2024-08-02T16:39:48.406200+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.truenas_app_update",
              "state": "on",
              "attributes": {
                "id": "1722001115960",
                "last_triggered": "2024-08-02T16:14:11.975833+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Truenas app update"
              },
              "last_changed": "2024-08-02T16:39:44.430736+00:00",
              "last_reported": "2024-08-02T16:39:44.430736+00:00",
              "last_updated": "2024-08-02T16:39:44.430736+00:00",
              "context": {
                "id": "01J49ZC9HEKSMYRNV6WWGP7HEF",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-08-02T16:39:48.406391+00:00",
          "changed_variables": {
            "context": {
              "id": "01J49ZCDDPQK0TSQSB5QVS6AJ1",
              "parent_id": "01J49ZCDDNXRMF4WGE930CY69G",
              "user_id": null
            }
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-08-02T16:39:48.406491+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-08-02T16:39:48.406507+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0/entity_id/0": [
        {
          "path": "action/0/choose/0/conditions/0/entity_id/0",
          "timestamp": "2024-08-02T16:39:48.406519+00:00",
          "result": {
            "result": false,
            "state": 1,
            "wanted_state": "On"
          }
        }
      ]
    },
    "config": {
      "id": "1722001115960",
      "alias": "Truenas app update",
      "description": "Send a notification if there is an app update for truenas apps",
      "trigger": [],
      "condition": [],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "state",
                  "entity_id": "binary_sensor.truenas_apps_photoprism",
                  "attribute": "Update available",
                  "state": "On"
                }
              ],
              "sequence": []
            }
          ],
          "enabled": true
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01J49ZCDDPQK0TSQSB5QVS6AJ1",
      "parent_id": "01J49ZCDDNXRMF4WGE930CY69G",
      "user_id": null
    }
  },
  "logbookEntries": []
}

here is the Yaml for the automation

alias: Truenas app update
description: Send a notification if there is an app update for truenas apps
trigger: []
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.truenas_apps_photoprism
            attribute: Update available
            state: "On"
        sequence: []
    enabled: true
mode: single

ok, your new yaml, you have the attribute looking for the value “On” but the attrribute has the value is “1” so it fails… see this part of your trace:

        {
          "path": "action/0/choose/0/conditions/0/entity_id/0",
          "timestamp": "2024-08-02T16:39:48.406519+00:00",
          "result": {
            "result": false,
            "state": 1,
            "wanted_state": "On"
          }

and also your screenshot at the very top shows that the value of that attribute is ‘1’. so you shouldn’t be looking for “On” in your yaml.

here is the latest trace and YAML for the automation:
YAML:

alias: Truenas app update
description: Send a notification if there is an app update for truenas apps
trigger: []
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.truenas_apps_unifi_controller
            attribute: Update available
            state: "1"
        sequence: []
    enabled: true
mode: single

Trace:

{
  "trace": {
    "last_step": "action/0/choose/0/conditions/0/entity_id/0",
    "run_id": "59ed2b22a44146e9566c79d400d4eac0",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-08-02T18:27:41.576651+00:00",
      "finish": "2024-08-02T18:27:41.577273+00:00"
    },
    "domain": "automation",
    "item_id": "1722001115960",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2024-08-02T18:27:41.576712+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.truenas_app_update",
              "state": "on",
              "attributes": {
                "id": "1722001115960",
                "last_triggered": "2024-08-02T18:25:04.684844+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Truenas app update"
              },
              "last_changed": "2024-08-02T18:27:38.312443+00:00",
              "last_reported": "2024-08-02T18:27:38.312443+00:00",
              "last_updated": "2024-08-02T18:27:38.312443+00:00",
              "context": {
                "id": "01J4A5HVP849TQS4YNNX20AWDN",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-08-02T18:27:41.576919+00:00",
          "changed_variables": {
            "context": {
              "id": "01J4A5HYW8M6N4BG7SH14X36F6",
              "parent_id": "01J4A5HYW8B796CB70V5G409WN",
              "user_id": null
            }
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-08-02T18:27:41.577022+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-08-02T18:27:41.577040+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0/entity_id/0": [
        {
          "path": "action/0/choose/0/conditions/0/entity_id/0",
          "timestamp": "2024-08-02T18:27:41.577068+00:00",
          "result": {
            "result": false,
            "state": 1,
            "wanted_state": "1"
          }
        }
      ]
    },
    "config": {
      "id": "1722001115960",
      "alias": "Truenas app update",
      "description": "Send a notification if there is an app update for truenas apps",
      "trigger": [],
      "condition": [],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "state",
                  "entity_id": "binary_sensor.truenas_apps_unifi_controller",
                  "attribute": "Update available",
                  "state": "1"
                }
              ],
              "sequence": []
            }
          ],
          "enabled": true
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01J4A5HYW8M6N4BG7SH14X36F6",
      "parent_id": "01J4A5HYW8B796CB70V5G409WN",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Truenas app update",
      "message": "triggered",
      "source": null,
      "entity_id": "automation.truenas_app_update",
      "context_id": "01J4A5HYW8M6N4BG7SH14X36F6",
      "when": 1722623261.5767622,
      "domain": "automation"
    }
  ]
}

i tried changing it to an app that is running to see if that made a difference. As you can see in the trace it shows the state is 1 and the wanted state is aslo 1

note quite. the state is 1, the wanted state is “1”. those are different. the first is a number the second is a string

does this work?

alias: Truenas app update
description: Send a notification if there is an app update for truenas apps
trigger: []
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.truenas_apps_unifi_controller
            attribute: Update available
            state: 1
        sequence: []
    enabled: true
mode: single

Thank you this worked. How would i get the same value using the GUI instead of YAML?

1 Like

hmm. that’s a good question. I had not noticed before that the UI only supports string. I think you cannot do it via UI at this time.

Ah ok thank you