jokob-sk / NetAlertX

🖧🔍 WIFI / LAN intruder detector. Scans for devices connected to your network and alerts you if new and unknown devices are found.
GNU General Public License v3.0
3.15k stars 186 forks source link

mqtt wont work #748

Closed kuduacz closed 4 months ago

kuduacz commented 4 months ago

MQTT in ha configured correctly cuz z2m work well. mqttexplorer do not show netalertx

Is there an existing issue for this?

Current Behavior

do not send any info to mqtt broker

Expected Behavior

sendieng infos to mqtt broker

Steps To Reproduce

No response

app.conf

# MQTT
#---------------------------
MQTT_RUN='always_after_scan'
MQTT_RUN__metadata="                      {\"function\": \"RUN\", \"events\": [\"test\"], \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"select\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": \"disabled\", \"options\": [\"disabled\", \"on_notification\", \"once\", \"schedule\", \"always_after_scan\", \"on_new_device\"], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"When to run\"}, {\"language_code\": \"es_es\", \"string\": \"Cuando ejecuta\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Enable sending notifications via <a target=\\\"_blank\\\" href=\\\"https://www.home-assistant.io/integrations/mqtt/\\\">MQTT</a> to your Home Assistance instance. Usually, <code>on_notification</code> is recommended. See the <a target=\\\"_blank\\\" href=\\\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/HOME_ASSISTANT.md\\\">NetAlertX Home Assistant guide</a> for details.\"}, {\"language_code\": \"es_es\", \"string\": \"Habilitar el env\\u00edo de notificaciones a trav\\u00e9s de <a target=\\\"_blank\\\" href=\\\"https://www.home-assistant.io/integrations/mqtt/\\\">MQTT</a> a su Home Assistance.\"}]}\n                    "
MQTT_CMD='python3 /app/front/plugins/_publisher_mqtt/mqtt.py devices={devices}'
MQTT_CMD__metadata="                      {\"function\": \"CMD\", \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [{\"readonly\": \"true\"}], \"transformers\": []}]}, \"default_value\": \"python3 /app/front/plugins/_publisher_mqtt/mqtt.py devices={devices}\", \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Command\"}, {\"language_code\": \"es_es\", \"string\": \"Comando\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Command to run\"}, {\"language_code\": \"es_es\", \"string\": \"Comando a ejecutar\"}]}\n                    "
MQTT_RUN_SCHD='* * * * *'
MQTT_RUN_SCHD__metadata="                      {\"function\": \"RUN_SCHD\", \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": \"0 2 * * 3\", \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Schedule\"}, {\"language_code\": \"es_es\", \"string\": \"Schedule\"}, {\"language_code\": \"de_de\", \"string\": \"Schedule\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Only enabled if you select <code>schedule</code> in the <a href=\\\"#MQTT_RUN\\\"><code>MQTT_RUN</code> setting</a>. Make sure you enter the schedule in the correct cron-like format (e.g. validate at <a href=\\\"https://crontab.guru/\\\" target=\\\"_blank\\\">crontab.guru</a>). For example entering <code>0 4 * * *</code> will run the scan after 4 am in the <a onclick=\\\"toggleAllSettings()\\\" href=\\\"#TIMEZONE\\\"><code>TIMEZONE</code> you set above</a>. Will be run NEXT time the time passes.\"}, {\"language_code\": \"es_es\", \"string\": \"Solo est\\u00e1 habilitado si selecciona <code>schedule</code> en la configuraci\\u00f3n <a href=\\\"#MQTT_RUN\\\"><code>MQTT_RUN</code></a>. Aseg\\u00farese de ingresar la programaci\\u00f3n en el formato similar a cron correcto (por ejemplo, valide en <a href=\\\"https://crontab.guru/\\\" target=\\\"_blank\\\">crontab.guru</a>). Por ejemplo, ingresar <code>0 4 * * *</code> ejecutar\\u00e1 el escaneo despu\\u00e9s de las 4 a.m. en el <a onclick=\\\"toggleAllSettings()\\\" href=\\\"#TIMEZONE\\\"><code>TIMEZONE</ c\\u00f3digo> que configur\\u00f3 arriba</a>. Se ejecutar\\u00e1 la PR\\u00d3XIMA vez que pase el tiempo.\"}, {\"language_code\": \"de_de\", \"string\": \"Nur aktiviert, wenn Sie <code>schedule</code> in der <a href=\\\"#MQTT_RUN\\\"><code>MQTT_RUN</code>-Einstellung</a> ausw\\u00e4hlen. Stellen Sie sicher, dass Sie den Zeitplan im richtigen Cron-\\u00e4hnlichen Format eingeben (z. B. validieren unter <a href=\\\"https://crontab.guru/\\\" target=\\\"_blank\\\">crontab.guru</a>). Wenn Sie beispielsweise <code>0 4 * * *</code> eingeben, wird der Scan nach 4 Uhr morgens in der <a onclick=\\\"toggleAllSettings()\\\" href=\\\"#TIMEZONE\\\"><code>TIMEZONE</ ausgef\\u00fchrt. Code> den Sie oben festgelegt haben</a>. Wird das N\\u00c4CHSTE Mal ausgef\\u00fchrt, wenn die Zeit vergeht.\"}]}\n                    "
MQTT_RUN_TIMEOUT=20
MQTT_RUN_TIMEOUT__metadata="                      {\"function\": \"RUN_TIMEOUT\", \"type\": {\"dataType\": \"integer\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [{\"type\": \"number\"}], \"transformers\": []}]}, \"default_value\": 20, \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Run timeout\"}, {\"language_code\": \"es_es\", \"string\": \"Tiempo de espera de ejecuci\\u00f3n\"}, {\"language_code\": \"de_de\", \"string\": \"Wartezeit\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Maximum time in seconds to wait for the script to finish. If this time is exceeded the script is aborted.\"}, {\"language_code\": \"es_es\", \"string\": \"Tiempo m\\u00e1ximo en segundos para esperar a que finalice el script. Si se supera este tiempo, el script se cancela.\"}]}\n                    "
MQTT_BROKER='mqtt://192.168.5.61'
MQTT_BROKER__metadata="                      {\"function\": \"BROKER\", \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": \"\", \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"MQTT broker URL\"}, {\"language_code\": \"es_es\", \"string\": \"URL del broker MQTT\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"MQTT host URL (do not include <code>http://</code> or <code>https://</code>).\"}, {\"language_code\": \"es_es\", \"string\": \"URL del host MQTT (no incluya <code>http://</code> o <code>https://</code>).\"}]}\n                    "
MQTT_PORT=1883
MQTT_PORT__metadata="                      {\"function\": \"PORT\", \"type\": {\"dataType\": \"integer\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [{\"type\": \"number\"}], \"transformers\": []}]}, \"default_value\": 1883, \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"MQTT broker port\"}, {\"language_code\": \"es_es\", \"string\": \"Puerto del broker MQTT\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Port number where the broker is listening. Usually <code>1883</code>.\"}, {\"language_code\": \"es_es\", \"string\": \"Puerto donde escucha el broker MQTT. Normalmente <code>1883</code>.\"}]}\n                    "
MQTT_USER='Milu'
MQTT_USER__metadata="                      {\"function\": \"USER\", \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": \"\", \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"MQTT user\"}, {\"language_code\": \"es_es\", \"string\": \"Usuario de MQTT\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"User name used to login into your MQTT broker instance.\"}, {\"language_code\": \"es_es\", \"string\": \"Nombre de usuario utilizado para iniciar sesi\\u00f3n en su instancia de agente de MQTT.\"}]}\n                    "
MQTT_PASSWORD='Milu1985t'
MQTT_PASSWORD__metadata="                      {\"function\": \"PASSWORD\", \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [{\"type\": \"password\"}], \"transformers\": []}]}, \"default_value\": \"\", \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"MQTT password\"}, {\"language_code\": \"es_es\", \"string\": \"Contrase\\u00f1a de MQTT\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Password used to login into your MQTT broker instance.\"}, {\"language_code\": \"es_es\", \"string\": \"Contrase\\u00f1a utilizada para iniciar sesi\\u00f3n en su instancia de agente de MQTT.\"}]}\n                    "
MQTT_SEND_STATS=True
MQTT_SEND_STATS__metadata="                      {\"function\": \"SEND_STATS\", \"type\": {\"dataType\": \"boolean\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [{\"type\": \"checkbox\"}], \"transformers\": []}]}, \"default_value\": true, \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Send stats\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Check to send overal device stats, such as number of Online and Offline devices.\"}]}\n                    "
MQTT_DEVICE_ID='netalertx'
MQTT_DEVICE_ID__metadata="                      {\"function\": \"DEVICE_ID\", \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": \"netalertx\", \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Device ID\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"The root path of the stats overview sensor. Inserted into the <code>system-sensors/sensor/{DEVICE_ID}/state</code> topic.\"}]}\n                    "
MQTT_DEVICE_NAME='NetAlertX'
MQTT_DEVICE_NAME__metadata="                      {\"function\": \"DEVICE_NAME\", \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": \"NetAlertX\", \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Device name\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"The name used for the stats overview device.\"}]}\n                    "
MQTT_SEND_DEVICES=True
MQTT_SEND_DEVICES__metadata="                      {\"function\": \"SEND_DEVICES\", \"type\": {\"dataType\": \"boolean\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [{\"type\": \"checkbox\"}], \"transformers\": []}]}, \"default_value\": true, \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Send devices\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Check to send individual devices to the broker with details, such as <code>is_new</code>, <code>is_present</code>, or <code>mac_address</code> of the devices.\"}]}\n                    "
MQTT_DEVICES_SQL='select rowid, * from Devices where dev_Name not in ({s-quote}null{s-quote}, {s-quote}(name not found){s-quote}, {s-quote}(unknown){s-quote})'
MQTT_DEVICES_SQL__metadata="                      {\"function\": \"DEVICES_SQL\", \"type\": {\"dataType\": \"string\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": \"select rowid, * from Devices where dev_Name not in ({s-quote}null{s-quote}, {s-quote}(name not found){s-quote}, {s-quote}(unknown){s-quote})\", \"options\": [], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Devices SQL\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"The SQL condition used to select which Devices are sent via MQTT. Please note that you need to use <code>{s-quote}</code> for single quotes replacement and double-quotes are not supported.\"}]}\n                    "
MQTT_QOS=0
MQTT_QOS__metadata="                      {\"function\": \"QOS\", \"type\": {\"dataType\": \"integer\", \"elements\": [{\"elementType\": \"select\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": 0, \"options\": [0, 1, 2], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"MQTT Quality of Service\"}, {\"language_code\": \"es_es\", \"string\": \"Calidad de servicio MQTT\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Quality of service setting for MQTT message sending. The higher the quality the longer the delay. <br/> <code>0</code> - Low quality to <code>2</code> - High quality.\"}, {\"language_code\": \"es_es\", \"string\": \"Configuraci\\u00f3n de calidad de servicio para el env\\u00edo de mensajes MQTT. <code>0</code>: baja calidad a <code>2</code>: alta calidad. Cuanto mayor sea la calidad, mayor ser\\u00e1 el retraso.\"}]}\n                    "
MQTT_VERSION=2
MQTT_VERSION__metadata="                      {\"function\": \"VERSION\", \"type\": {\"dataType\": \"integer\", \"elements\": [{\"elementType\": \"select\", \"elementOptions\": [], \"transformers\": []}]}, \"default_value\": 1, \"options\": [1, 2], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"Version\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"Paho MQTT API version. Depends on the MQTT <a href=\\\"https://eclipse.dev/paho/files/paho.mqtt.python/html/index.html#callbacks\\\" target=\\\"_blank\\\">version supported by the MQTT broker</a>. Usually set to <code>1</code>.\"}]}\n                    "
MQTT_DELAY_SEC=2
MQTT_DELAY_SEC__metadata="                      {\"function\": \"DELAY_SEC\", \"type\": {\"dataType\": \"integer\", \"elements\": [{\"elementType\": \"input\", \"elementOptions\": [{\"type\": \"number\"}], \"transformers\": []}]}, \"default_value\": 2, \"options\": [2, 3, 4, 5], \"localized\": [\"name\", \"description\"], \"name\": [{\"language_code\": \"en_us\", \"string\": \"MQTT delay per device\"}, {\"language_code\": \"es_es\", \"string\": \"Retraso de MQTT por dispositivo\"}], \"description\": [{\"language_code\": \"en_us\", \"string\": \"A little hack - delay adding to the queue in case the process is restarted and previous publish processes aborted (it takes ~<code>2</code>s to update a sensor config on the broker). Tested with <code>2</code>-<code>3</code> seconds of delay. This delay is only applied when devices are created (during the first notification loop). It doesn not affect subsequent scans or notifications.\"}, {\"language_code\": \"es_es\", \"string\": \"Un peque\\u00f1o truco: retrase la adici\\u00f3n a la cola en caso de que el proceso se reinicie y los procesos de publicaci\\u00f3n anteriores se anulen (se necesitan ~<code>2</code>s para actualizar la configuraci\\u00f3n de un sensor en el intermediario). Probado con <code>2</code>-<code>3</code> segundos de retraso. Este retraso solo se aplica cuando se crean dispositivos (durante el primer bucle de notificaci\\u00f3n). No afecta los escaneos o notificaciones posteriores.\"}]}\n                    "

docker-compose.yml

name: big-bear-netalertx
services:
    big-bear-netalertx:
        cpu_shares: 90
        command: []
        container_name: big-bear-netalertx
        deploy:
            resources:
                limits:
                    memory: "16538140672"
        environment:
            ALWAYS_FRESH_INSTALL: "false"
            PORT: "8099"
            TZ: Europe/Warsaw
        hostname: big-bear-netalertx
        image: jokobsk/netalertx:latest
        labels:
            icon: https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/pi-alert.png
        network_mode: host
        privileged: true
        restart: unless-stopped
        volumes:
            - type: bind
              source: /DATA/AppData/big-bear-netalertx/config
              target: /app/config
              bind:
                create_host_path: true
            - type: bind
              source: /DATA/AppData/big-bear-netalertx/db
              target: /app/db
              bind:
                create_host_path: true
        x-casaos:
            ports:
                - container: "8080"
                  description:
                    en_us: 'Container Port: 8080'
            volumes:
                - container: /app/config
                  description:
                    en_us: 'Container Path: /app/config'
                - container: /app/db
                  description:
                    en_us: 'Container Path: /app/db'
networks:
    default:
        name: big-bear-netalertx_default
x-casaos:
    architectures:
        - amd64
        - arm64
    author: BigBearTechWorld
    category: BigBearCasaOS
    description:
        en_us: WIFI / LAN intruder detector. Scans for devices connected to your network and alerts you if new and unknown devices are found.
    developer: jokobsk
    hostname: ""
    icon: https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png/pi-alert.png
    index: /
    is_uncontrolled: false
    main: big-bear-netalertx
    port_map: "8099"
    scheme: http
    store_app_id: big-bear-netalertx
    tagline:
        en_us: NetAlertX
    thumbnail: ""
    title:
        custom: ""
        en_us: NetAlertX

What branch are you running?

Production

app.log

No response

Debug enabled

jokob-sk commented 4 months ago

Hi there, Could you please provide a relevant app.log output to investigate further? Also, the URL of your broker doesn't seem correct. Try to use an ip without the protocol.

Thanks, J