Simple Mailbox notifier ( 2 sensors + optional camera )

Here the blueprint, generated with Gpt5.0… because i know noooothing about code.

Quite simple for european mailbox:
1 sensor for the mailbox fence
1 sensor for the latch
notifier via the companion app, working well.

Using Gpt to generate a script : nightmare !
I have to say it’s very limited and hallucinating on code a lot…
this is the 10th generation, with trial and error.

The other thing it didn’t succeed doing it was multiple selection for mobile to notify.

  • what do you think about the code quality ?
  • anybody could correct/add the multiple mobile choice so i can post it for the others ?
blueprint:
  name: Mail Notifier with cam snapshot 
  description: >
    Counts the mail delivered by the postman and sends a notification with the time.
    Resets the counter and notifies when the flap is open (mail collected).
    Can send a photo if a camera is connected.
  domain: automation
  input:
    fente_sensor:
      name: Fense sensor
      description: Sensor detecting the opening of the slot (post deposited)
      selector:
        entity:
          domain: binary_sensor
    trappe_sensor:
      name: mailbox door
      description: Sensor detecting the opening of the hatch (post collected)
      selector:
        entity:
          domain: binary_sensor
    compteur:
      name: Mail counter
      description: Counter entity
      selector:
        entity:
          domain: counter
    notif_device:
      name: Notification device
      description: Device (select the Mobile App device)
      selector:
        device:
            integration: mobile_app
          
    camera_entity:
      name: IP Camera (optional)
      description: Postbox camera to send a photo
      default: ""
      selector:
        entity:
          domain: camera

mode: restart
max_exceeded: silent

variables:
  compteur: !input compteur
  camera: !input camera_entity
  notify_device: !input notif_device

trigger:
  - platform: state
    entity_id: !input fente_sensor
    to: "on"
    id: courrier
  - platform: state
    entity_id: !input trappe_sensor
    to: "on"
    id: releve

action:
  - choose:
      - conditions:
          - condition: trigger
            id: courrier
        sequence:
          - service: counter.increment
            target:
              entity_id: !input compteur

          - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ camera != '' }}"
                sequence:
                  - domain: mobile_app
                    type: notify
                    device_id: !input notif_device
                    title: "📬 Mail !"
                    message: >
                      The postman came by at {{ now().strftime('%H:%M') }}.
                      Number of letters in the post box : {{ states(compteur) }}
                    data:
                      image: "/api/camera_proxy/{{ camera }}"
            default:
              - domain: mobile_app
                type: notify
                device_id: !input notif_device
                title: "📬 Mail !"
                message: >
                  The postman came by at {{ now().strftime('%H:%M') }}.
                  Number of letters in the post box : {{ states(compteur) }}

      - conditions:
          - condition: trigger
            id: releve
        sequence:
          - service: counter.reset
            target:
              entity_id: !input compteur
          - domain: mobile_app
            type: notify
            device_id: !input notif_device
            title: "📭 relevé..."
            message: "The post has been collected. {{ now().strftime('%H:%M') }}."

All the best

Hello Adefx,

Thanks for contributing to the community with a new Blueprint.
I have a suggestion for you. Many people who are not familiar with directory structures will have problems installing this without the Home Assistant MY tools.
Adding a MY link for this Blueprint to your top post would help them a lot.
Here is the link to make that.
Create a link – My Home Assistant

If it doesn’t work the way it’s supposed to, then the quality is 0/10… your time would have been better spent reading the docs.

None of your Entity selectors are correct. You can read about how they should be configured to filter by domain in HA Docs - Selectors - Entity

You can find the details for Device selectors on the same page… just a little further down. Once you’ve found the Device section, look for the word “multiple”.

If you want to be able to select multiple devices for the notification, you will need to place the action in a Repeat for Each action.

Ok thanks,
The script is doing what i want, but as i told, i know nothing about coding and was aware to know if a chat gpt has done it right.
Regarding your gentle answer the coding capability of GPT aren’t the best…
Going to improve my coding skills reading TFM.

Thanks

Is this ChatGPT hallucinating again/still? Sadly the time spent futzing could have been used to read and understand the vendor documentation, which is accurate and up to date, and produced a far better outcome, as well a stepping board to continue your automation goals.