Hi all, I’m brand new to telegraf and MQTT and struggling to get the data from my new Solar Assistant setup into my InfluxDB V2.
Setup:
1 Raspi3b running Solar Assistant V2023-02-28
- Raspi4b running:
InfluxDB V2.6.1
Telegraf V1.26.0
MosquittoV2.0.11
Pi’s running Raspberry Pi OS Lite (64-bit)
I have MQTT set up on the Solar Assistant and can subscribe to it using the solar assistant IP from the console and get the following output This is a subset.
solar_assistant/total/battery_power/state 0
solar_assistant/total/battery_state_of_charge/state 100
solar_assistant/total/battery_temperature/state 16.0
solar_assistant/total/bus_voltage/state 855.3
solar_assistant/inverter_1/free_mode_charge_rate/state 100
solar_assistant/inverter_1/max_charge_current/state 60.0
solar_assistant/inverter_1/battery_absorption_charge_voltage/state 58.0
solar_assistant/inverter_1/grid_frequency/state 50.0
solar_assistant/inverter_1/pv_current_1/state 2.3
solar_assistant/inverter_1/load_first_stop_discharge/state 5
solar_assistant/inverter_1/pv_power/state 1823
solar_assistant/inverter_1/battery_voltage/state 53.2
solar_assistant/inverter_1/grid_first_stop_discharge/state 5
solar_assistant/inverter_1/pv_current_2/state 3.6
solar_assistant/inverter_1/temperature/state 33.9
solar_assistant/inverter_1/battery_float_charge_voltage/state 57.5
solar_assistant/inverter_1/load_first_stop_charge/state 100
solar_assistant/inverter_1/battery_current/state 0.0
solar_assistant/inverter_1/battery_first_grid_charge/state Disabled
solar_assistant/inverter_1/output_source_priority/state Load first
solar_assistant/inverter_1/grid_first_discharge_rate/state 100
solar_assistant/inverter_1/grid_power/state -1550
solar_assistant/inverter_1/pv_voltage_1/state 301.2
solar_assistant/inverter_1/pv_voltage_2/state 302.9
solar_assistant/inverter_1/pv_power_1/state 714
solar_assistant/inverter_1/battery_first_charge_rate/state 100
solar_assistant/inverter_1/device_mode/state Hybrid
solar_assistant/inverter_1/free_mode_discharge_rate/state 100
solar_assistant/inverter_1/battery_first_stop_charge/state 100
solar_assistant/inverter_1/grid_voltage/state 240.0
solar_assistant/inverter_1/load_power/state 200
solar_assistant/inverter_1/pv_power_2/state 1109
solar_assistant/total/battery_power/state 0
solar_assistant/total/battery_state_of_charge/state 100
solar_assistant/total/battery_temperature/state 16.0
solar_assistant/total/bus_voltage/state 855.3
solar_assistant/inverter_1/free_mode_charge_rate/state 100
solar_assistant/inverter_1/max_charge_current/state 60.0
solar_assistant/inverter_1/battery_absorption_charge_voltage/state 58.0
solar_assistant/inverter_1/grid_frequency/state 50.0
solar_assistant/inverter_1/pv_current_1/state 2.3
solar_assistant/inverter_1/load_first_stop_discharge/state 5
solar_assistant/inverter_1/pv_power/state 1823
solar_assistant/inverter_1/battery_voltage/state 53.2
solar_assistant/inverter_1/grid_first_stop_discharge/state 5
solar_assistant/inverter_1/pv_current_2/state 3.6
solar_assistant/inverter_1/temperature/state 33.9
solar_assistant/inverter_1/battery_float_charge_voltage/state 57.5
solar_assistant/inverter_1/load_first_stop_charge/state 100
solar_assistant/inverter_1/battery_current/state 0.0
solar_assistant/inverter_1/battery_first_grid_charge/state Disabled
solar_assistant/inverter_1/output_source_priority/state Load first
solar_assistant/inverter_1/grid_first_discharge_rate/state 100
solar_assistant/inverter_1/grid_power/state -1550
solar_assistant/inverter_1/pv_voltage_1/state 301.2
solar_assistant/inverter_1/pv_voltage_2/state 302.9
solar_assistant/inverter_1/pv_power_1/state 714
solar_assistant/inverter_1/battery_first_charge_rate/state 100
solar_assistant/inverter_1/device_mode/state Hybrid
solar_assistant/inverter_1/free_mode_discharge_rate/state 100
solar_assistant/inverter_1/battery_first_stop_charge/state 100
solar_assistant/inverter_1/grid_voltage/state 240.0
solar_assistant/inverter_1/load_power/state 200
solar_assistant/inverter_1/pv_power_2/state 1109
solar_assistant/total/battery_power/state 0
solar_assistant/total/battery_state_of_charge/state 100
solar_assistant/total/battery_temperature/state 16.0
solar_assistant/total/bus_voltage/state 855.3
I have the following in /etc/mosquitto/conf.d/solar-assistant.conf
connection SolarAssistant
#remote_username solar-assistant
#remote_password solar123
address xxx.xxx.xxx.xxx:1883
topic # in 0
topic solar_assistant/# out 0
I can subscribe to it using the localhost address and still get the same output.
So far, so good I think.
The difficulty I am having is getting telegraf to subscribe to the same feed and put the data into influxdb.
I have the following in my telegraf.conf file…
[agent]
omit_hostname = true
[[inputs.mqtt_consumer]]
servers = ["tcp://localhost:1883"]
topics = [ "solar_assistant" ]
data_format = "influx"
topic_tag = ""
[[outputs.influxdb_v2]]
urls = ["http://localhost:8086"]
token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
organization = "xxxxxx"
namepass = ["solar_assistant"]
bucket = "xxxxx"
This seems to start up OK from the following terminal OP
$ sudo systemctl start telegraf
$ sudo systemctl status telegraf
● telegraf.service - Telegraf
Loaded: loaded (/lib/systemd/system/telegraf.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-03-27 16:19:55 BST; 4s ago
Docs: https://github.com/influxdata/telegraf
Main PID: 23909 (telegraf)
Tasks: 9 (limit: 8755)
CPU: 266ms
CGroup: /system.slice/telegraf.service
└─23909 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! Available plugins: 235 inputs, 9 aggregators, 27 processors, 22 parsers, 57 outputs, 2 secret-stores
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! Loaded inputs: mqtt_consumer
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! Loaded aggregators:
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! Loaded processors:
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! Loaded secretstores:
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! Loaded outputs: influxdb_v2
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! Tags enabled:
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"", Flush Interval:10s
Mar 27 16:19:55 PiEnergyMon systemd[1]: Started Telegraf.
Mar 27 16:19:55 PiEnergyMon telegraf[23909]: 2023-03-27T15:19:55Z I! [inputs.mqtt_consumer] Connected [tcp://localhost:1883]
But I’m not getting the data into Influxdb.
I know my token etc is OK.
As I say, I’m brand new to this and at a loss as to where to go from here. I’m guessing once I get it running I’m going to have to parse the data to get it in in some sensible form but I want to see what it produces first of all. Plus I know I’ll need to think about security a bit more once it’s running.
Any help appreciated.