Sofar mqtt to emoncms cloud

Hi
I have made one of the mqtt readers GitHub - cmcgerty/Sofar2mqtt: A smart home interface for Sofar solar and battery inverters.
and have the data coming in to the emonpi mqtt broker. I did this by making it publish to emon/emonpi/ so I can see it in the inputs and make feeds.
How do i send this data to my emoncms.org account?
The data from the sofar inverter is coming in as a json {} while the data from the emonpi is in the default format.

Thanks (apologies if this is in the wrong section, i am new here, I guess i don’t understand something basic)

The output from running: mosquitto_sub -v -h 192.168.1.246

emon/emonpi/power1 875
emon/emonpi/power2 219
emon/emonpi/power1pluspower2 1094
emon/emonpi/vrms 240.07
emon/emonpi/t1 17.8
emon/emonpi/t2 14.8
emon/emonpi/t3 0
emon/emonpi/t4 0
emon/emonpi/t5 0
emon/emonpi/t6 0
emon/emonpi/pulsecount 5
emonhub/rx/5/values 875,219,1094,240.07,17.8,14.8,0,0,0,0,5
emon/emonpi {"power1": 875, "power2": 219, "power1pluspower2": 1094, "vrms": 240.07, "t1": 17.8, "t2": 14.8, "t3": 0, "t4": 0, "t5": 0, "t6": 0, "pulsecount": 5, "time": 1668088096.6658092}

Hi,

I would love to do the same :slight_smile: However I set the sofar2mqtt publish topic to emon/sofar2mqtt that way it still appears on the inputs but is in its own group. However, I have not found a way to get it up to the cloud Emoncms :frowning: If you have managed to do any processing of the inputs → feeds I would be very interested
John

emoncms.org doen’t accept MQTT input.

You could use Node-RED to convert the data from a local MQTT to an HTTP input (using the emoncms node).

You can use the Sync module, but I don’t think that is automatic though I have a feeling someone here has managed to automate it.

You are sending the data twice to the same emonpi inputs.

emon/emonpi {"power1": 875, "power2": 219, "power1pluspower2": 1094, "vrms": 240.07, "t1": 17.8, "t2": 14.8, "t3": 0, "t4": 0, "t5": 0, "t6": 0, "pulsecount": 5, "time": 1668088096.6658092}

is the same as the individual topic publishes above.

Thanks John, if i ever get that far i will let you know.

Hi Brian, I will have to do a bit of learning of Node-RED.
I think that i might be sending the data twice because i turned on json in the the emonhub config. Me randomly pressing buttons to see what happens!

Just leave JSON on and turn off the non JSON mode (JSON is much more efficient and all inputs get the same value).

Ah OK, so you are reading the values via emonhub? If so, you can just create an HTTP interfacer there and it will send the data to emoncms.org as well as the local MQTT.

Post your emonhub config (down as far as the nodes section and use the ‘preformatted’ button above).

Hi Brian, sorry it took so long to reply (work getting in the way!)
I have not turned the json back on yet, but will do, as you can see from the config.

#######################################################################
#######################      emonhub.conf     #########################
#######################################################################
### emonHub configuration file, for info see documentation:
### https://github.com/openenergymonitor/emonhub/blob/emon-pi/configuration.md
#######################################################################
#######################    emonHub  settings    #######################
#######################################################################

[hub]
### loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL
loglevel = DEBUG
### Uncomment this to also send to syslog
# use_syslog = yes
#######################################################################
#######################       Interfacers       #######################
#######################################################################

[interfacers]
### This interfacer manages the RFM12Pi/RFM69Pi/emonPi module
[[RFM2Pi]]
    Type = EmonHubJeeInterfacer
    [[[init_settings]]]
        com_port = /dev/ttyAMA0
        com_baud = 38400                        # 9600 for old RFM12Pi
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,
        subchannels = ToRFM12,

        group = 210
        frequency = 433
        baseid = 5                              # emonPi / emonBase nodeID
        calibration = 230V                      # (UK/EU: 230V, US: 110V)
        quiet = true                            # Disable quite mode (default enabled) to enable RF packet debugging, show packets which fail crc
        # interval =  300                         # Interval to transmit time to emonGLCD (seconds)


[[MQTT]]

    Type = EmonHubMqttInterfacer
    [[[init_settings]]]
        mqtt_host = 127.0.0.1
        mqtt_port = 1883
        mqtt_user = emonpi
        mqtt_passwd = emonpimqtt2016

    [[[runtimesettings]]]
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,

        # emonhub/rx/10/values format
        # Use with emoncms Nodes module
        node_format_enable = 1
        node_format_basetopic = emonhub/

        # emon/emontx/power1 format - use with Emoncms MQTT input
        # http://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
        nodevar_format_enable = 1
        nodevar_format_basetopic = emon/

        # Single JSON payload published  - use with Emoncms MQTT
        node_JSON_enable = 0
        node_JSON_basetopic = emon/

[[emoncmsorg]]
    Type = EmonHubEmoncmsHTTPInterfacer
    [[[init_settings]]]
    [[[runtimesettings]]]
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,
        url = https://emoncms.org
        apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        senddata = 1                    # Enable sending data to Emoncms.org
        sendstatus = 1                  # Enable sending WAN IP to Emoncms.org MyIP > https://emoncms.org/myip/list
        sendinterval= 30                # Bulk send interval to Emoncms.org in seconds

#######################################################################
#######################          Nodes          #######################
#######################################################################

[nodes]

## See config user guide: https://github.com/openenergymonitor/emonhub/blob/emon-pi/conf/emonhub.conf

[[5]]
    nodename = emonpi
    [[[rx]]]
        names = power1,power2,power1pluspower2,vrms,t1,t2,t3,t4,t5,t6,pulsecount
        datacodes = h, h, h, h, h, h, h, h, h, h, L
        scales = 1,1,1,0.01,0.1,0.1,0.1,0.1,0.1,0.1,1
        units = W,W,W,V,C,C,C,C,C,C,p
 

A quick recap on how the interfacers work (teach a man to fish…)

This is actually the interfacer that is reading the data off the serial input

A bit like MQTT, it then publishes this data to an internal ‘buffer’.

Is an output interfacer (in this case) and ‘subscribes’ to the internal buffer

And sends the data to the MQTT broker configured - you can have more than one MQTT interfacer configured.

Personally I would just enable the node_JSON and disable the nodevar format. You only want one of them

You also have an HTTP interfacer defined to send the data to emoncms.org. So I am unclear why this is not happening.

Check the log again for a connection error.

BTW, be careful not to post your API Key.

1 Like

Thanks very very much Brian