I thought this would be a great little weekend project do work on and it is. I took a bit a time to realize I had ordered the SPI version so I had to solder on a couple of more leads and try again.
I had to install MQTT version 1.5.7 I believe – whatever them most current is and I tested it by sending some messages back and forth.
My issue is that I can’t get the detector to connect to the local host broker. I no next to nothing about MQTT other than what I played with today.
In the script I am using the following for MQTT config
# The hostname or IP address of the MQTT broker to connect to (Default: localhost)
# Also read from the MQTT_HOSTNAME environment variable
hostname = localhost
# The TCP port the MQTT broker is listening on (Default: 1883)**
# Also read from the MQTT_PORT environment variable**
port = 1883
After messing with this a bit, I am lost. See below:
pi@raspberrypi:~ $ sudo systemctl status mosquitto.service
● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset
Active: active (running) since Tue 2021-02-02 09:17:39 CST; 6min ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Main PID: 2399 (mosquitto)
Tasks: 1 (limit: 2063)
CGroup: /system.slice/mosquitto.service
└─2399 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Feb 02 09:17:39 raspberrypi systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 Brok
Feb 02 09:17:39 raspberrypi systemd[1]: Started Mosquitto MQTT v3.1/v3.1.1 Broke
pi@raspberrypi:~ $ cd /opt/ISP-lightning-mqtt-daemon
pi@raspberrypi:/opt/ISP-lightning-mqtt-daemon $ sudo nano config.ini
pi@raspberrypi:/opt/ISP-lightning-mqtt-daemon $ sudo systemctl start pigpiod.service
pi@raspberrypi:/opt/ISP-lightning-mqtt-daemon $ cd
pi@raspberrypi:~ $ python3 /opt/ISP-lightning-mqtt-daemon/ISP-lightning-mqtt-daemon.py
[2021-02-02 09:27:22] - * **init mqtt_client_connected=[False]**
[2021-02-02 09:27:22] * Sensor on SPI bus
ini file
# The hostname or IP address of the MQTT broker to connect to (Default: localho$
# Also read from the MQTT_HOSTNAME environment variable
hostname = localhost
# The TCP port the MQTT broker is listening on (Default: 1883)
# Also read from the MQTT_PORT environment variable
port = 1883
# Enable TLS/SSL on the connection
tls = false
# Path to CA Certificate file to verify host
#tls_ca_cert =
# Path to TLS client auth key file
#tls_keyfile = privkey.pem
# Path to TLS client auth certificate file
#tls_certfile = fullchain.pem
I have set this up, but so far all of the MQTT sensors only display Unknown. I am assuming the sensor that I use with the lightning detector card is the “sensor.current_ringset” and “sensor.past_ringset”?
@emergent the “Unknown” usually indicate that MQTT broker under MQTT has not yet received any information from your RPi/Lightning detector.
You can watch MQTT traffic by monitoring what the broker is receiving using tools such as MQTT Explorer or MQTTBox. After you confirm the sensor is reporting then you should see these values start updating correctly.
Yes, the current_ringset is the latest Lightning Detection traffic.
I’m looking and topic home/nodes/sensor/lightningdetector is only showing the status topic which is status=Online. I’m not seeing a topic home/nodes/sensor/settings being created like the docs refer to.
This is what my config.ini looks like:
# Configuration file for lightning-detector-MQTT2HA-Daemon
# Source: https://github.com/ironsheep/lightning-detector-MQTT2HA-Daemon
#
# Uncomment and adapt all settings as needed.
# Some settings can be configured by environment variables.
# If an env variable is set, it takes precedence over settings in this file
[General]
[Daemon]
# Enable or Disable an endless execution loop (Default: true)
#enabled = true
[MQTT]
# The hostname or IP address of the MQTT broker to connect to (Default: localho$
# Also read from the MQTT_HOSTNAME environment variable
hostname = 192.168.1.248
# The TCP port the MQTT broker is listening on (Default: 1883)
# Also read from the MQTT_PORT environment variable
#port = 1883
# Maximum period in seconds between ping messages to the broker. (Default: 60)
#keepalive = 60
# NOTE: The MQTT topic used for this device is constructed as:
# {base_topic}/{sensor_name}
#
# The MQTT base topic to publish the Lightning detector sensor data topics unde$
base_topic = home/nodes
# The MQTT name for this Lightning detector sensor
sensor_name = lightningdetector
# The MQTT broker authentification credentials (Default: no authentication)
# Will also read from MQTT_USERNAME and MQTT_PASSWORD environment variables
#username = user
#password = pwd123
# Enable TLS/SSL on the connection
#tls = false
# Path to CA Certificate file to verify host
#tls_ca_cert =
# Path to TLS client auth key file
#tls_keyfile =
# Path to TLS client auth certificate file
#tls_certfile =
# Broker connection-failure recovery
# Rety connection attempts [default 5]
#retry_count = 5
# Retry after waiting N seconds [default 30]
#retry_wait_in_seconds = 30
[Behavior]
# This script accumulates detections into buckets (rings if you will) for this period of time [2-10] in minutes [Default: 5]
#period_in_minutes = 5
# This script accumulates values into [3-7] rings [Default: 5]
#number_of_rings = 5
# This script can report distances in miles or kilometers (mi, km) [Default: km]
distance_as = mi
# This script determines that a storm has ended after this period of time [10-60] in minutes [Default: 30]
#end_storm_after_minutes = 30
[Sensor]
# decribe how your sensor is hooked up to your RPi
# use values 'I2C' or 'SPI' - default is 'I2C'
#sensor_attached = I2C
# GPIO pin used for interrupts
#intr_pin = 17
# The SPI bus and device numbers come from the device file being used.
# e.g., /dev/spidev0.0 would be bus=0, device=0
# The defaults are 0 and 0 (SPI0 which appears at the GPIO 40pin header)
#spi_bus = 0
#spi_device = 0
# Rev. 1 Raspberry Pis should leave bus set at 0, while rev. 2 Pis should set
# bus equal to 1. The address should be changed to match the address of the
# sensor.
#i2c_bus = 1
#i2c_address = 0x03
# Value to use for your board
# Internal Tuning Capacitors (from 0 to 120pF in steps of 8pf) - A value of [0-15]
# run the script with a --tune paramater to determine value for your board
# NOTE: this runs for 3 minutes so be patient! Then record your best value here.
tuning_capacitor = 0xf
# Indoors (True) = more sensitive (can miss very strong lightnings)
# Outdoors (False) = less sensitive (can miss far away lightnings)
detector_afr_gain_indoor = True
detector_noise_floor = 1
# Prevent single isolated strikes from being logged => interrupts begin after
# this number of strikes (def: 5, value 1,5,9,16), then are fired normally.
detector_min_strikes = 1
# The hostname or IP address of the MQTT broker to connect to (Default: localho$
# Also read from the MQTT_HOSTNAME environment variable
hostname = 192.168.1.173
#hostname = localhost
#hostname = 192.168.1.170
# The TCP port the MQTT broker is listening on (Default: 1883)
# Also read from the MQTT_PORT environment variable
#port = 1883
@Edhall1044 OK, I’ll need a little bit more understanding of your setup.
The normal environment is one RPi with Lightning detector attached and running the properly configured python script which announces messages to an external MQTT broker. Then a second RPi (or another machine) is running both Home Assistant and the MQTT Broker.
OK, that’s a good start. But behind that, you should see detection reports. Until the detection reports are sent to MQTT the card won’t show anything…
You should be able to run the detector script by hand (stop the daemon form while doing so) and enable debug output (I think this may be the -d option. You can check by running the script with -h and it will tell you all available options.)
This will help you see if your detector is reporting anything useful.
OK, that helps. Check the config.ini on the Detector RPi. Hostname in that file should refer to your Home Assistant RPi 4 hostname where the MQTT broker is running. This should be the hostname of the MQTT broker machine.
You currently have:
# The hostname or IP address of the MQTT broker to connect to (Default: localho$
# Also read from the MQTT_HOSTNAME environment variable
hostname = 192.168.1.173