It seems that I need to additionally export the e_today value to Domoticz. Looking at the code of the LiveStats:
Code: Select all
import PluginLoader
class ConsoleOutput(PluginLoader.Plugin):
"""Outputs the data from the Omnik inverter to stdout"""
def process_message(self, msg):
"""Output the information from the inverter to stdout.
Args:
msg (InverterMsg.InverterMsg): Message to process
"""
print "ID: {0}".format(msg.id)
print "E Today: {0:>5} Total: {1:<5}".format(msg.e_today, msg.e_total)
print "H Total: {0:>5} Temp: {1:<5}"\
.format(msg.h_total, msg.temperature)
print "PV1 V: {0:>5} I: {1:>4}".format(msg.v_pv(1), msg.i_pv(1))
print "PV2 V: {0:>5} I: {1:>4}".format(msg.v_pv(2), msg.i_pv(2))
print "PV3 V: {0:>5} I: {1:>4}".format(msg.v_pv(3), msg.i_pv(3))
print "L1 P: {0:>5} V: {1:>5} I: {2:>4} F: {3:>5}"\
.format(msg.p_ac(1), msg.v_ac(1), msg.i_ac(1), msg.f_ac(1))
print "L2 P: {0:>5} V: {1:>5} I: {2:>4} F: {3:>5}"\
.format(msg.p_ac(2), msg.v_ac(2), msg.i_ac(2), msg.f_ac(2))
print "L3 P: {0:>5} V: {1:>5} I: {2:>4} F: {3:>5}"\
.format(msg.p_ac(3), msg.v_ac(3), msg.i_ac(3), msg.f_ac(3))
I've tried to add the e_today to the code, without any knowledge of Python and it seems that I missed something. I've added to the config.cfg file the line: 'idx_E_Today = 315 #nieuw'
config.cfg:
Code: Select all
################
### Settings ###
################
[general]
# General:enabled_plugins
# Choose which outputs to use
# Possible options: MysqlOutput,PVoutputOutput,ConsoleOutput,CSVOutput
enabled_plugins = DomoticzOutput
[domoticz]
domoticz_host = 192.168.1.100
domoticz_port = 8080
domoticz_url = json.htm
# Provide IDX here of the specific devices was 23
idx_Temp = 17
idx_PV1_U = 18
idx_PV2_U = 19
idx_PV1_A = 20
idx_PV2_A = 21
idx_AC_Output = 22
idx_E_Total = 23
idx_E_Today = 315 #nieuw
idx_E_Current = 24
[inverter]
# IP address of your Omnik inverter
ip = *********************
# Default for a Omnik with Wifi module
port = ***********************
# S/N of the wifi kit
wifi_sn = ************************
#use temperature of inverter for pvoutput
use_temperature = true
[mysql]
# Host where the mysql server is active
host = 127.0.0.1
user =
pass =
database =
[pvout]
# These two can be found at http://pvoutput.org/account.jsp
apikey = NOTAREALAPIKEY86e2258d4e29169fb79cf18b00
sysid = 12345
[csv]
disable_header = false
[log]
# Log:Output
# Possible options: none,console,file (combinations are possible)
# Use none to disable logging
type = console
# Log:level
# Possible options: critical, error, warning, info, debug
level = debug
# Log:filename
# Output file for file logger
filename = omnik-export.log
In the file DomoticzOutput.py I've added this section:
#NIEUW today kWh generated
get_data = {
'svalue': msg.e_today,
'type': 'command',
'param': 'udevice',
'idx' : idx_E_Today
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
DomoticzOutput.py:
Code: Select all
#!/usr/bin/python
import PluginLoader
import urllib
import urllib2
import ConfigParser
config = ConfigParser.RawConfigParser()
#change to correct folder.
config.read(['/home/pi/Omnik-Data-Logger/config-default.cfg', '/home/pi/Omnik-Data-Logger/config.cfg'])
domoticz_host = config.get('domoticz','domoticz_host')
domoticz_port = config.get('domoticz','domoticz_port')
domoticz_url = config.get('domoticz','domoticz_url')
idx_Temp = config.get('domoticz','idx_Temp')
idx_PV1_U = config.get('domoticz','idx_PV1_U')
idx_PV2_U = config.get('domoticz','idx_PV2_U')
idx_PV1_A = config.get('domoticz','idx_PV1_A')
idx_PV2_A = config.get('domoticz','idx_PV2_A')
idx_AC_Output = config.get('domoticz','idx_AC_Output')
idx_E_Total = config.get('domoticz','idx_E_Total')
idx_E_Today = config.get('domoticz','idx_E_Today') #nieuw
idx_E_Current = config.get('domoticz','idx_E_Current')
url = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url)
class DomoticzOutput(PluginLoader.Plugin):
"""Outputs the data from the Omnik inverter to Domoticz"""
def process_message(self, msg):
"""Output the information from the inverter to Domoticz.
Args:
msg (InverterMsg.InverterMsg): Message to process
"""
#NIEUW today kWh generated
get_data = {
'svalue': msg.e_today,
'type': 'command',
'param': 'udevice',
'idx' : idx_E_Today
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
#Total AC energy generated by inverter in kWatt
get_data = {
'svalue': msg.e_total,
'type': 'command',
'param': 'udevice',
'idx' : idx_E_Total
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
#Current AC power and today's total power
get_data = {
'svalue': str(msg.p_ac(1)) + ';' + str(msg.e_total * 1000),
'type': 'command',
'param': 'udevice',
'idx' : idx_E_Current,
'nvalue': '0'
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
#Current inverter temperature
if msg.temperature < 300: #inverter displays temperature of +/- 6352 degrees Celcius when not generating power
get_data = {
'svalue': msg.temperature,
'type': 'command',
'param': 'udevice',
'idx' : idx_Temp,
'nvalue': '0'
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
#String 1 voltage
get_data = {
'svalue': msg.v_pv(1),
'type': 'command',
'param': 'udevice',
'idx' : idx_PV1_U,
'nvalue': '0'
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
#String 2 voltage
get_data = {
'svalue': msg.v_pv(2),
'type': 'command',
'param': 'udevice',
'idx' : idx_PV2_U,
'nvalue': '0'
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
#String 1 ampere
get_data = {
'svalue': msg.i_pv(1),
'type': 'command',
'param': 'udevice',
'idx' : idx_PV1_A,
'nvalue': '0'
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
#String 2 ampere
get_data = {
'svalue': msg.i_pv(2),
'type': 'command',
'param': 'udevice',
'idx' : idx_PV2_A,
'nvalue': '0'
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
#Current AC current
get_data = {
'svalue': msg.i_ac(1),
'type': 'command',
'param': 'udevice',
'idx' : idx_AC_Output,
'nvalue': '0'
}
get_data_encoded = urllib.urlencode(get_data)
full_url = url + '?' + get_data_encoded
urllib.urlopen(full_url)
I have a General/custom sensor IDX 315 to which I try to export the data. This sensor is similar configured as the sensor that consumes the e_total (which part of the code I've tried to copy).
Any ideas what I missed?