Nov-30-2017, 02:08 PM
Hello,
i'm having issues with a script which I found on https://github.com/datenschuft/SMA-EM
It's a script to read out and write away to some file the values of the energy meter which it has been created for.
I tried contacting the creator, but seems he has no clue either, or his instructions were not very complete.
Anyhow, I hope anyone can point me in the right direction regarding the following error:
Error:/home/SMA-EM $ sudo python3 sma-daemon.py
Traceback (most recent call last):
File "/usr/local/lib/python3.5/configparser.py", line 1136, in _unify_values
sectiondict = self._sections[section]
KeyError: 'SMA-EM'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "sma-daemon.py", line 30, in <module>
smaemserials=parser.get('SMA-EM', 'serials')
File "/usr/local/lib/python3.5/configparser.py", line 779, in get
d = self._unify_values(section, vars)
File "/usr/local/lib/python3.5/configparser.py", line 1139, in _unify_values
raise NoSectionError(section)
configparser.NoSectionError: No section: 'SMA-EM'
I get this error after running this script:#!/usr/bin/env python3 # coding=utf-8 """ .... """ import sys, time from daemon3x import daemon3x from configparser import SafeConfigParser import smaem #read configuration parser = SafeConfigParser() parser.read('/etc/smaemd/config') smaemserials=parser.get('SMA-EM', 'serials') serials=smaemserials.split(' ') smavalues=parser.get('SMA-EM', 'values') values=smavalues.split(' ') pidfile=parser.get('DAEMON', 'pidfile') class MyDaemon(daemon3x): def run(self): emparts = {} while True: emparts=smaem.readem() for serial in serials: #print(serial) #print(emparts['serial']) if serial==format(emparts['serial']): #print("match") for value in values: file = open("/run/shm/em-"+format(serial)+"-"+format(value), "w") file.write('%.4f' % emparts[value]) file.close() if __name__ == "__main__": daemon = MyDaemon(pidfile) if len(sys.argv) == 2: if 'start' == sys.argv[1]: daemon.start() elif 'stop' == sys.argv[1]: daemon.stop() elif 'restart' == sys.argv[1]: daemon.restart() else: print ("Unknown command") sys.exit(2) sys.exit(0) else: print ("usage: %s start|stop|restart" % sys.argv[0]) print (pidfile) sys.exit(2)and it refers to this config file as well (which I needed to create myself given the instructions)
configfile Wrote:[SMA-EM]
*serials of sma-ems the daemon should take notice
*seperated by space
serials=1900254500
*measurement values
values=pregard psurplus qsurplus ssurplus
[DAEMON]
pidfile=/run/smaemd.pid
I tried running python v3 and the base version (2.7...) with sudo ofcourse.
The issue i posted on this github, which gave me no info :
https://github.com/datenschuft/SMA-EM/issues/9
Thanks for anyone who wants to help out here.