datenschuft / SMA-EM

SMA Energymeter measurement
GNU General Public License v2.0
93 stars 38 forks source link

Struggle, smaemd.service now loaded but no input in influxdb #61

Closed broke23 closed 3 years ago

broke23 commented 3 years ago

Hi all,

I had to start all over new, but now on a pi 4.

sudo apt install python3-pip= installed no problem sudo apt install git = installed no problem sudo apt install python3 cl-py-configparser = installed no problem config file is utf8 and filled in to work with influxdb

now for influxdb, what version am I supposed to get ? there's influxdb and python3-inbluxdb

requirements state:

paho-mqtt~=1.5.0 = needed for influxdb ? influxdb~=5.3.0 (python3-influxdb version 5.2.0-1) influxdb-client~=1.14.0 (installed 1.6.4-1+deb10u1 ) pymodbus~=2.4.0 = needed for influxdb ? requests~=2.24.0 = needed for influxdb ?

I'm in the loop here, sorry about that, I think i got tripped along the way and I think i already tried every single pack of influx and got db created, but somehow messed things up trying to install more stuff I fear, so I'm gonna start over once again I'm affraid.

Anyone care to point me in the correct direction here ?

broke23 commented 3 years ago

pi@ElectricPI:~ $ sudo systemctl status smaemd.service smaemd.service - SMA Energymeter measurement daemon

Loaded: loaded (/etc/systemd/system/smaemd.service; enabled; vendor p Active: failed (Result: exit-code) since Sat 2021-09-04 09:28:51 CEST Process: 5097 ExecStart=/opt/smaemd/SMA-EM/sma-daemon.py start_systemd Main PID: 5097 (code=exited, status=1/FAILURE)

Sep 04 09:28:51 ElectricPI systemd[1]: smaemd.service: Service RestartSeSep 04 09:28:51 ElectricPI systemd[1]: smaemd.service: Scheduled restartSep 04 09:28:51 ElectricPI systemd[1]: Stopped SMA Energymeter measuremeSep 04 09:28:51 ElectricPI systemd[1]: smaemd.service: Start request repSep 04 09:28:51 ElectricPI systemd[1]: smaemd.service: Failed with resulSep 04 09:28:51 ElectricPI systemd[1]: Failed to start SMA Energymeter

Note that the directory was changed of daemon as cloning resulted in adding SMA-EM so hence I changed that. Still resulting in error

broke23 commented 3 years ago

Got smaemd.service working! But no data found in influxdb. Db is there but that's it... It's not writing to SMA somehow 🤔

Tested with grafana as well, template used:

https://www.unifox.at/2020/08/05/sma-em-influxdb-grafana/ (one from Flo Wenger) updated with my serial.

My config file:

[SMA-EM]
# serials of sma-ems the daemon should take notice                      # separated by space
serials=1900254537
# features could filter serials to, but wouldn't see serials if these s$# list of features to load/run
#features=simplefswriter sample pvdata ediplugs mqtt remotedebug symcon$features=influxdb

[DAEMON]
pidfile=/run/smaemd.pid
# listen on an interface with the given ip
# use 0.0.0.0 for any interface
ipbind=192.168.1.13
# multicast ip and port of sma-datagrams                                # defaults
mcastgrp=239.12.255.254
mcastport=9522
statusdir=

[FEATURE-influxdb]
# influx
host=influxdb
port=8086
ssl=
db=SMA

timeout=5
user=
password=                                                              
# How frequently to send updates over (defaults to 20 sec)
min_update=20

debug=0
#emdata
measurement=SMAEM

#A list of possible field names can be found above under FEATURE-mqtt
fields=pconsume,psupply,p1consume,p2consume,p3consume,p1supply,p2supply

sma-em-easurement.py not working either

@ElectricPI:/opt/smaemd/SMA-EM $ python3 sma-em-measurement.py
could not connect to mulicast group or bind to given interface
datenschuft commented 3 years ago

Hi, sorry for the delay - It's hobby project ... [SMA-EM] serials=1900254537 ... is this the serial of your sma-em/hm ? otherwise the daemon ignores the datapackages. check it with sma-em-capture-package (works also, if have no configuration file)

you have not enabled features in your configuration like features=simplefswriter influxdb

i have written a german description page https://www.unifox.at/software/sma-em-daemon/ maybe it will help you to configure the daemon for your environment. If german is not your preferred language - try the google translator. I hope it will help you

broke23 commented 3 years ago

I can see the udp packets though:

sudo tcpdump -i eth0 -s0 -vv -e host 239.12.255.254
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
11:06:51.842071 00:d0:93:2c:f8:e6 (oui Unknown) > 01:00:5e:0c:ff:fe (oui Unknown), ethertype IPv4 (0x0800), length 642: (tos 0x0, ttl 1, id 0, offset 0, flags [DF], proto UDP (17), length 628)
    192.168.1.13.44467 > 239.12.255.254.9522: [udp sum ok] UDP, length 600

yet issue stays the same:

pi@ElectricPI:/opt/smaemd $ python3 sma-em-measurement.py could not connect to mulicast group or bind to given interface

edit: hi datenschuft, I know it's hobby, and was trying to solve it anyhow, so hoped to see some help, but I'm happy to see some new input now

about your website unifox: I know, i used it and tried to resolve the issues :)

as for sma-em-catpture: same error

pi@ElectricPI:/opt/smaemd $ python3 sma-em-capture-package.py
could not connect to mulicast group or bind to given interface

config file, ah heck, i have the options there though, must have messed up with pasting:

[SMA-EM]
# serials of sma-ems the daemon should take notice
# separated by space
serials=1900254537
# features could filter serials to, but wouldn't see serials if these serials was not defines in SMA-EM serials
# list of features to load/run
#features=simplefswriter sample pvdata ediplugs mqtt remotedebug symcon influxdb
features=influxdb

[DAEMON]
pidfile=/run/smaemd.pid
# listen on an interface with the given ip
# use 0.0.0.0 for any interface
ipbind=192.168.1.13
# multicast ip and port of sma-datagrams
# defaults
mcastgrp=239.12.255.254
mcastport=9522
statusdir=

[FEATURE-influxdb]
# influx
host=influxdb
port=8086
ssl=
db=SMA

timeout=5
user=
password=
# How frequently to send updates over (defaults to 20 sec)
min_update=20

debug=0
#emdata
measurement=SMAEM

#A list of possible field names can be found above under FEATURE-mqtt
fields=pconsume,psupply,p1consume,p2consume,p3consume,p1supply,p2supply,p3supply
datenschuft commented 3 years ago

remove ipbind=192.168.1.13 and retry the daemon should find an interface with this ip - address. if none with that ip was found (changed by dhcp) - this could be the error.

broke23 commented 3 years ago

aargh, I was playing with ip's, and set up 0.0.0.0 in the sma-em-measurement, but it was looking in config with 192.168.1.13 (from config) and thus not working

now I can at least see measurement and capture!
so great, one step closer to getting a view in my usage again :) I think I messed up with databases or something

yet, /run/shm/ is still empty, no serial visible there i did reload daemon, started smaemd.service and status is active (running)

do we need simplefswriter as well to be able to write into influxdb and hence fill out /run/shm/?

datenschuft commented 3 years ago

The daemon reads the values, but if no Feature is selected, nothing happends.

simplefswriter populates /run/shm/ but only with the values configured in the section [FEATURE-simplefswriter] example: https://github.com/datenschuft/SMA-EM/tree/master/features serials=1900204522 values=pconsume psupply qsupply ssupply

influxdb send SMA-measurement-values to an influxdb. but only configured measurments example: [FEATURE-influxdb] host=influxdb port=8086 ssl= db=SMA

timeout=5 user= password= min_update=30

debug=0 measurement=SMAEM

A list of possible field names can be found above under FEATURE-mqtt fields=pconsume,psupply,p1consume,p2consume,p3consume,p1supply,p2supply,p3supply see https://github.com/datenschuft/SMA-EM/blob/master/config.sample

broke23 commented 3 years ago
[SMA-EM]
# serials of sma-ems the daemon should take notice
# separated by space
serials=1900254537
# features could filter serials to, but wouldn't see serials if these serials was not defines in SMA-EM serials
# list of features to load/run
#features=simplefswriter sample pvdata ediplugs mqtt remotedebug symcon influxdb
features=influxdb

[DAEMON]
pidfile=/run/smaemd.pid
# listen on an interface with the given ip
# use 0.0.0.0 for any interface
ipbind=0.0.0.0
# multicast ip and port of sma-datagrams
# defaults
mcastgrp=239.12.255.254
mcastport=9522
statusdir=

[FEATURE-influxdb]
# influx
host=influxdb
port=8086
ssl=
db=SMA

timeout=5
user=
password=
# How frequently to send updates over (defaults to 20 sec)
min_update=20

debug=0
#emdata
measurement=SMAEM

#A list of possible field names can be found above under FEATURE-mqtt
fields=pconsume,psupply,p1consume,p2consume,p3consume,p1supply,p2supply,p3supply

According to me I have this setup right, no ? I have the fields, i have the feature influxdb set up, no ?

I copied the same u are using here: https://www.unifox.at/2020/08/05/sma-em-influxdb-grafana/

all this to see if I can get it working before I try to setup my own ...

datenschuft commented 3 years ago

try: stop the daemon change debug=1 in section [FEATURE-influxdb] run the daemon in foreground like sudo /opt/smaemd/sma-daemon.py run and have a look at the debug output

broke23 commented 3 years ago
pi@ElectricPI:/opt/smaemd $ sudo /opt/smaemd/sma-daemon.py run
config
import influxdb.py
influxdb: feature enabled
InfluxDB: Error while connecting to '' @ 'influxdb'(SMA)
HTTPConnectionPool(host='influxdb', port=8086): Max retries exceeded with url: /query?q=SHOW+DATABASES (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xb5c7ddd0>: Failed to establish a new connection: [Errno -2] Name or service not known'))
datenschuft commented 3 years ago

is your host named influxdb (where influxdb is running) ? or is it running on localhost ?

broke23 commented 3 years ago

running on the raspberry pi itsself, localhost

but as stated in the beginning, I think I messed up somewhere with the installs, got influxdb, python3-influx, influxdb-client

influxdb~=5.3.0 (python3-influxdb version 5.2.0-1) (updated to 5.3.1) influxdb-client~=1.14.0 (installed 1.6.4-1+deb10u1 )

influxdb 1.8.9 is installed as well ...

datenschuft commented 3 years ago

in your configurtion the sma-daemon trys to send data to an infoxdb running on host influxdb, but this hostname is unknown. if your influxdb is unning on the same host, you have to change the host value at the [FEATURE-influxdb]-section to localhost

[FEATURE-influxdb] host=localhost

broke23 commented 3 years ago
Sep 06 16:57:12 ElectricPI sma-daemon.py[548]: HTTPConnectionPool(host='localhost', port=8086): Max retries exceeded with url: /query?q=SHOW+DATABASES (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xb5be36d0
Sep 06 16:57:12 ElectricPI sma-daemon.py[548]: InfluxDB: Error while connecting to '' @ 'localhost'(SMA)

one step further again, thanks again, but I tend to keep struggling with my setup

might not be better if I restart from scratch all over, install seems fine, but I'm not sure about the requirements file, do all these need to be installed for my feature influxdb ? hence all my troubleshooting before I got help from you I'm not so sure the installs are fine

broke23 commented 3 years ago

I started from scratch and got it up and running now, thanks @datenschuft !

datenschuft commented 3 years ago

you're welcome. it's true; maybe the requirements file is a bit confusing, because not all requirements are necessary for all features