0x2142 / frigate-notify

Event notifications for a standalone Frigate NVR instance
https://frigate-notify.0x2142.com/
MIT License
109 stars 9 forks source link

Timezone issue #172

Closed jbriscoenc closed 2 weeks ago

jbriscoenc commented 2 weeks ago

Having an issue getting eastern standard time showing... What am I doing wrong?

## Alerting methods
# Any combination of alert destinations can be configured
alerts:
  # General config applies to all alert methods below
  general:
    # Title for any alert messages (Default: Frigate Alert)
    # Supports template variables
    title: Camera Alert
    # Optionally modify default time format in notifications
    # Use Golang's reference time format, or see docs for more info
    timeformat: Mon, 02 Jan 2006 15:04:05 EST
    # Allow notification of events without a snapshot
    # Set to `drop` to disallow this
    nosnap: allow
    # Note: Following snap_ items only apply when event is in progress
    # Set to `true` to include bounding box on detected object in snapshot
    snap_bbox: true
    # Set to `true` to include timestamp on snapshot
    snap_timestamp: true
    # Set to `true` to crop snapshot
    snap_crop:
freefd commented 2 weeks ago

Hi @jbriscoenc, could you please provide more details about the issue you are facing? According to your configuration, excatly the Eastern Standard Time zone should be displayed: Mon, 02 Jan 2006 15:04:05 EST.

jbriscoenc commented 2 weeks ago

I would like it to display est time but when I try to use any format it's always UTC...

If I try to use: 2024-11-13 12:01:46 -0500 EST I get this: 2024-11-13 12:01:46 -4600 EST

freefd commented 2 weeks ago

@jbriscoenc, try to

  1. Check the indents in the YAML configuration for the alers.general section, especially for timeformat option.
  2. Pass the TZ environment variable to your frigate-notify appliance. Available timezones.

@0x2142, is it possible to show loaded enriched config being in the trace log level? Somewhere around https://github.com/0x2142/frigate-notify/blob/dev/config/config.go#L209.

0x2142 commented 2 weeks ago

Hi there, So - the timeformat config specifically only alters the timestamps which are displayed in notifications - it does not change the actual timezone of the host system. This uses Golang's built-in time formatting, which you can find docs for here. In order for timeformat to show you the time zone of the host system/container, you would use Mon, 02 Jan 2006 15:04:05 MST. Note that the reference/template timezone is MST, where Golang will look for that value to fill in the actual timezone. By setting this to EST, Golang is interpreting this as hard-coding a string of text to the end of the time format & not using this as a template.

In addition, to actually change the time zone used by the app, please use the TZ environment variable as mentioned by @freefd. If you're using the docker compose file, you might include the following:

    environment:
      - TZ=America/New_York

The combination of both of those changes should get the result you're looking for

jbriscoenc commented 2 weeks ago

Awesome. Thank you. Will try that tonight.

jbriscoenc commented 2 weeks ago

Still not getting EST from my pushover notification... The time on my Ubuntu server is set to est. I just can't see what i'm doing wrong...

 ## SAMPLE CONFIG FILE
# For more info, see docs at https://frigate-notify.0x2142.com/config/file/

## Event Collection Methods
# Note: Only enable one - webapi OR mqtt

frigate:
  environment:
   - TZ=America/New_York
  # Frigate host URL (ex. https://frigate.yourdomain.tld)
  # This is required for both collection methods
  server: http://192.168.1.25:5000 
  # Set to true to allow self-signed certificates
  ignoressl: true
  # Public / internet-facing Frigate URL, if different from above server address
  public_url: http://192.168.1.25:5000

  # List of HTTP headers to send to Frigate, in format Header: Value
  headers:
    # Example:
    # - Authorization: Basic abcd1234

  # On startup, frigate-notify will check reachability of Frigate server
  startup_check:
    # Max number of attempts (Default: 5)
    attempts: 3
    # Interval between attempts, in seconds (Default: 30)
    interval: 30

  webapi:
    # Set to true to enable event collection via the web API
    enabled: true 
    # Interval between checking for new events, in seconds (Default: 30)
    interval: 30 

  mqtt: 
    # Set to true to enable event collection via MQTT
    enabled: false 
    # MQTT host IP
    server: 192.168.1.25 
    # MQTT host port. (Default: 1883)
    port: 1883
    # MQTT Client ID (Default: frigate-notify)
    clientid:
    # MQTT Authentication. Leave both blank for anonymous
    username: 
    password: 
    # Optionally set custom topic prefix (Default: frigate)
    topic_prefix: 

  cameras:
    # List of cameras to exclude from being monitored
    # Camera names must match frigate configuration
    exclude:
      - test_cam_01

## Alerting methods
# Any combination of alert destinations can be configured
alerts: 
  # General config applies to all alert methods below
  general:
    # Title for any alert messages (Default: Frigate Alert)
    # Supports template variables
    title: Camera Alert
    # Optionally modify default time format in notifications
    # Use Golang's reference time format, or see docs for more info
    timeformat: Mon, 02 Jan 2006 15:04:05 MST
    # Allow notification of events without a snapshot
    # Set to `drop` to disallow this
    nosnap: allow
    # Note: Following snap_ items only apply when event is in progress
    # Set to `true` to include bounding box on detected object in snapshot
    snap_bbox: true
    # Set to `true` to include timestamp on snapshot
    snap_timestamp: true
    # Set to `true` to crop snapshot
    snap_crop:
    # By default, each Frigate event may generate several notifications as the object changes zones, etc
    # Set this to `true` to only notify once per event
    notify_once: true

  # If configured, ignore events between times below
  quiet:
    # Start / end times in 24 hour format (ex. 4:00 or 22:30)
    start:
    end:

  zones:
    # Allow notifications for events outside a zone
    # Set to `drop` to disallow this
    unzoned: allow
    # List of valid zones to generate alerts
    # If blank, all events with a zone will generate notifications
    allow:
     - backyard
     - frontyard
    # List of zones to never generate notifications
    block:
     - test_zone_02

  labels:
    # Filter events under minimum required label score (default: 0)
    min_score:
    # Filter notifications to only specific labels allowed here
    allow:
    # List of labels to never generate notifications
    block:

  sublabels:
    # Filter notifications to only specific sublabels allowed here
    allow:
    # List of sublabels to never generate notifications
    block:

  discord:
    # Set to true to enable alerting via Discord messages
    enabled: false
    # Insert full webhook URL below
    webhook: 
    # Custom notification template, if desired
    template:

  gotify:
    # Set to true to enable alerting via a Gotify push notification server
    enabled: false
    # Server URL (ex. https://push.yourdomain.tld)
    server:
    # Application token generated by Gotify
    token: 
    # Set to true to allow self-signed certificates
    ignoressl:
    # Custom notification template, if desired
    template:

  smtp:
    # Set to true to enable alerting via SMTP
    enabled: false
    # SMTP server host (ex. smtp.gmail.com)
    # SMTP port
    port: 465
    # Whether or not the SMTP server requires TLS (Default: true)
    tls: true
    # Username for authentication
    user: 
    # SMTP password for above user
    # Sending email address
    # Email alerts sent to any addresses listed below, separated by comma
    # Custom notification template, if desired
    template:
    # Set to true to allow self-signed certificates
    ignoressl: false

  # Telegram Config
  telegram:
    # Set to true to enable alerting via Telegram
    enabled: false
    # Chat ID of alert recipient
    chatid:
    # Bot API token
    token:
    # Custom notification template, if desired
    template:

  # Pushover Config
  pushover:
    # Set to true to enable alerting via Pushover
    enabled: true
    # Pushover API token for this application
    token: hidden
    # User or Group key for recipients
    userkey: hidden
    # Optional list of target devices by name, separated by comma
    devices:
    # Optional message priority, default is 0
    priority:
    # If priority is 2, retry & expiration must be set
    # Values in seconds. Retry must be 30 or higher
    retry:
    expire:
    # Optional message lifetime
    ttl:
    # Custom notification template, if desired
    template:

  # Ntfy Config
  ntfy:
    # Set to true to enable alerting via ntfy
    enabled: false
    # URL of Ntfy server
    server:
    # Ntfy topic for notifications
    topic:
    # Set to true to allow self-signed certificates
    ignoressl:
    # List of HTTP headers to send to Ntfy, in format Header: Value
    headers:
      # Example:
      # - Authorization: Basic abcd1234
    # Custom notification template, if desired
    template:

  # Webhook Config
  webhook:
    # Set to true to enable alerting via webhook
    enabled: false
    # URL of webhook receiver
    server:
    # Set to true to allow self-signed certificates
    ignoressl:
    # HTTP Method to send notifications, supports GET or POST (Default: POST)
    method:
    # Optional list of HTTP parameters to append to URL
    params:
      # Example:
      # - token: abcd1234
    # List of HTTP headers to send to webhook receiver, in format Header: Value
    headers:
      # Example:
      # - Authorization: Basic abcd1234
    # Custom notification template, if desired
    # Note that template must be valid JSON
    template:

## App Monitoring
# Sends HTTP GET to provided URL for aliveness checks
monitor:
  # Set to true to enable app monitoring
  enabled: false
  # URL for monitoring server
  url: 
  # Interval between monitoring check-in events, in seconds
  interval: 
  # Set to true to allow self-signed certificates
  ignoressl: 
0x2142 commented 2 weeks ago

How are you currently running frigate-notify? Container or binary? The environment variable TZ=America/New_York would go in the docker-compose.yaml, not the frigate-notify config

jbriscoenc commented 2 weeks ago

I'm an idiot... I added the timezone to my docker-compose file and it works... Don't know why I thought it needed to be in the config for the frigate-notify... Thank you so much