Outback Power Mate3s Rest PV Solar System Sensors and Occasionally Unavailable

Hello all,
This is my first post, I’ve scoured the blogs for the answers, not finding them. But I’m having a few problems.

First, I have a OutbackPower Inverter/Charge Controller, Mate3s Hub PV Setup and can connect to the Mate3s to get JSON output.

My system is small so far, but it will grow. Currently 2kw with 6 panels. And I have a 75kw battery - all running at 48Volts.

Here are the details: Mate3s is living at 10.0.0.150

The Json delivered is in example below.
It runs fine, and I get “Unavailable” occasionally.

The data shows up ok for a while. then shows unavailable, then connects again and shows ok…
The problem may be timeouts to the http resource.

I’d like the data to stay static on the screen, even if it hiccups when getting the data.

Here is what my Lovelace page looks when working (note, this is when the sun was just coming up, so the values are small)

Here is the json example:

{"devstatus": {
"Gateway_Type": "Mate3s","Sys_Time": 1601009672,
"Sys_Batt_V": 54.1,
"ports": [
{ "Port": 1, "Dev": "FXR","Type": "60Hz","Inv_I_L2": 0,"Chg_I_L2": 0,"Buy_I_L2": 0,"Sell_I_L2": 0,"VAC1_in_L2": 0,"VAC2_in_L2": 0,"VAC_out_L2": 122,"AC_Input": "Grid","Batt_V": 54.0,"AC_mode": "NO AC","INV_mode": "Inverting","Warn": ["none"],"Error": ["none"],"AUX": "disabled"},
{ "Port": 2, "Dev": "CC","Type": "FM80","Out_I": 12.9,"In_I": 9,"Batt_V": 54.6,"In_V": 79.6,"Out_kWh": 0.2,"Out_AH": 4,"CC_mode": " ","Error": ["none"],"Aux_mode": "Manual","AUX": "disabled"},
{ "Port": 3, "Dev": "FNDC","Enabled": ["A","B"],"Shunt_A_I":  -1.0,"Shunt_A_AH": -17,"Shunt_A_kWh": -0.880,"Shunt_B_I":  12.8,"Shunt_B_AH": 7,"Shunt_B_kWh":  0.420,"SOC": 93,"Min_SOC": 90,"Days_since_full": 2.8,"CHG_parms_met": false,"In_AH_today": 5,"Out_AH_today": 5,"In_kWh_today":  0.250,"Out_kWh_today":  0.260,"Net_CFC_AH": -10,"Net_CFC_kWh": -0.480,"Batt_V": 54.1,"Batt_temp": "###","Aux_mode": "manual","AUX": "disabled"}
]}}

And finally, here is my yaml sensor file:

#######################
# Some sensors for the Outback Mate3s 
# Coming from the OutbackPower OpticeRE System. 
#
# The mate3s controller lives at 10.0.0.150
# The api is: http://10.0.0.150/Dev_status.cgi?&Port=0
# It is a json output... so, lets get some data. 
#
# Json looks like this (as of 2020-09-25)
# {"devstatus": {
# "Gateway_Type": "Mate3s","Sys_Time": 1601009672,
# "Sys_Batt_V": 54.1,
# "ports": [
# { "Port": 1, "Dev": "FXR","Type": "60Hz","Inv_I_L2": 0,"Chg_I_L2": 0,"Buy_I_L2": 0,"Sell_I_L2": 0,"VAC1_in_L2": 0,"VAC2_in_L2": 0,"VAC_out_L2": 122,"AC_Input": "Grid","Batt_V": 54.0,"AC_mode": "NO AC","INV_mode": "Inverting","Warn": ["none"],"Error": ["none"],"AUX": "disabled"},
# { "Port": 2, "Dev": "CC","Type": "FM80","Out_I": 12.9,"In_I": 9,"Batt_V": 54.6,"In_V": 79.6,"Out_kWh": 0.2,"Out_AH": 4,"CC_mode": " ","Error": ["none"],"Aux_mode": "Manual","AUX": "disabled"},
# { "Port": 3, "Dev": "FNDC","Enabled": ["A","B"],"Shunt_A_I":  -1.0,"Shunt_A_AH": -17,"Shunt_A_kWh": -0.880,"Shunt_B_I":  12.8,"Shunt_B_AH": 7,"Shunt_B_kWh":  0.420,"SOC": 93,"Min_SOC": 90,"Days_since_full": 2.8,"CHG_parms_met": false,"In_AH_today": 5,"Out_AH_today": 5,"In_kWh_today":  0.250,"Out_kWh_today":  0.260,"Net_CFC_AH": -10,"Net_CFC_kWh": -0.480,"Batt_V": 54.1,"Batt_temp": "###","Aux_mode": "manual","AUX": "disabled"}
# ]}}
#
# Port 0 = Inverter (FXR - 60hz)
# Port 1 = Charge Controller (CC - FM80)
# Port 2 = FNDC
#######################
# When ready, include this file into configuration.yaml
# sensors: !include sensors_outback_opticsre.yaml
#
# Notes: 
# For rest connections, we could do multiple "resource" connections, each to get a specific value, 
# Example below works for charge controller batter voltage, but if we do this for each sensor, 
# we will flood the rest service and also cause multiple issues on the mate3s. 
# In fact, too many calls too quickly will crash port 80 on the mate3s.   So don't do it this way:
#  
#  - platform: rest
#    name: "PV CC Battery Voltage"
#    resource: "http://10.0.0.150/Dev_status.cgi?&Port=0"
#    value_template: "{{ value_json.devstatus.ports.1['Batt_V'] | float (2) }}"
#    method: GET
#    unit_of_measurement: "Vdc"
#    scan_interval: 30
#    
#  - platform: rest
#    name: "PV Gateway Type"
#    resource: "http://10.0.0.150/Dev_status.cgi?&Port=0"
#    value_template: "{{ value_json.devstatus.Gateway_Type }}"
#    method: GET
#    scan_interval: 30
#
# More notes: 
#    I can get the JSON data multiple ways... ecamples for charge controller battery voltage are:  
#        # value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["Batt_V"] }}'
#        # value_template: '{{ state_attr("sensor.mate3s_report", "devstatus") ["ports"][1]["Batt_V"] }}'
#
####
# Instead of using multiple resource connections, 
# Lets get all the data into attributes of a RESTful sensor and create a set of 
# template sensors that monitor the attributes and present the values in a 
# usable form. 
#
# Note, some sensors commented out, because I want to keep the size as small as possible, 
# and we are not currently needing those values for our reporting. 
#

  - platform: rest
    name: MATE3S_REPORT
    json_attributes:
      - devstatus
      - ports
      - Out_kWh
      - Batt_V
      
    resource: "http://10.0.0.150/Dev_status.cgi?&Port=0"
    value_template: 'OK'
    scan_interval: 30
    
  - platform: template
    sensors:

#    pv_gateway_type:
#      friendly_name: 'PV Gateway Type'
#      entity_id: sensor.mate3s_report
#      value_template: '{{ state_attr("sensor.mate3s_report", "devstatus") ["Gateway_Type"] }}'
        
      pv_sys_batt_v:
        friendly_name: 'PV Sys Battery Voltage'
        entity_id: sensor.mate3s_report
        value_template: '{{ state_attr("sensor.mate3s_report", "devstatus") ["Sys_Batt_V"] }}'
        unit_of_measurement: "Vdc"
        
################################# 
# Inverter Values on "ports[0]"
################################# 
        
      pv_inv_batt_v:
        friendly_name: 'Inv Battery Voltage'
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][0]["Batt_V"] }}'
        unit_of_measurement: "Vdc"
        
#     pv_inv_chg_i_l2:
#       friendly_name: 'Inv Chg I L2'
#       value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][0]["Chg_I_L2"] }}'
        
#     pv_inv_inv_i_l2:
#       friendly_name: 'Inv Inv I L2'
#       value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][0]["Inv_I_L2"] }}'
        
      pv_inv_mode:
        friendly_name: 'Inv Mode'
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][0]["INV_mode"] }}'
        
      pv_inv_vac_out_l2:
        friendly_name: 'Inv VAC Out L2'
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][0]["VAC_out_L2"] }}'
        unit_of_measurement: "Vac"

######################################## 
# Charge Controller values on "ports[1]"
######################################## 
      
      pv_cc_batt_v:
        friendly_name: 'CC Battery Voltage'
        
######## The following was my first attempt of dealing with "unavailable"... this didn't work. 
#      value_template: > 
#         {% if value_json.devstatus is defined and 'ports' in value_json.devstatus %}
#           {{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["Batt_V"] }}
#         {% else %}
#           {{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["Batt_V"].status }}
#         {% endif %}
######## End of attempt. 

        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["Batt_V"] }}'
        unit_of_measurement: "Vdc"

#     pv_cc_in_i:
#       friendly_name: 'CC In I'
#       entity_id: sensor.mate3s_report
#       value_template: '{{ sensor.mate3s_report.attributes["devstatus"]["ports"][1]["In_I"] }}'

      pv_cc_in_v:
        friendly_name: 'CC In Volts'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["In_V"] }}'
        unit_of_measurement: "Vdc"

      pv_cc_out_ah:
        friendly_name: 'CC Out AH'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["Out_AH"] }}'
        unit_of_measurement: "AH"

#     pv_cc_out_I:
#       friendly_name: 'CC Out I'
#       entity_id: sensor.mate3s_report
#       value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["Out_I"] }}'
        
      pv_cc_out_kwh:
        friendly_name: 'CC kWh OUT'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["Out_kWh"] }}'
        unit_of_measurement: "kWh"

#     pv_cc_type:
#       friendly_name: 'CC Type'
#       entity_id: sensor.mate3s_report
#       value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][1]["Type"] }}'


######################################## 
# FlexNet DC  values on "ports[2]"
######################################## 
     
      pv_fndc_batt_v:
        friendly_name: 'FNDC Battery Voltage'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Batt_V"] }}'
        unit_of_measurement: "Vdc"
        
#     pv_fndc_chg_params_met:
#       friendly_name: 'FNDC Charge Parameters Met'
#       entity_id: sensor.mate3s_report
#       value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Chg_params_met"] }}'
        
      pv_fndc_days_since_full:
        friendly_name: 'FNDC Days Since Full'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Days_since_full"] }}'
        unit_of_measurement: "Days"
        
#     pv_fndc_dev:
#       friendly_name: 'FNDC Dev'
#       entity_id: sensor.mate3s_report
#       value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["dev"] }}'
        
      pv_fndc_in_ah_today:
        friendly_name: 'FNDC In AH Today'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["In_AH_today"] }}'
        unit_of_measurement: "AH"
        
      pv_fndc_in_kwh_today:
        friendly_name: 'FNDC In kWh Today'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["In_kWh_today"] }}'
        unit_of_measurement: "kWh"
        
      pv_fndc_min_soc:
        friendly_name: 'FNDC Min SOC'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Min_SOC"] }}'
        unit_of_measurement: "Percent"
        
#     pv_fndc_net_cfc_ah:
#       friendly_name: 'FNDC Net CFC AH'
#       entity_id: sensor.mate3s_report
#       value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Net_CFC_AH"] }}'
#       unit_of_measurement: "AH"

#     pv_fndc_net_cfc_kwk:
#       friendly_name: 'FNDC Net CFC KWH'
#       entity_id: sensor.mate3s_report
#       value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Net_CFC_kWh"] }}'
#       unit_of_measurement: "kWh"
        
      pv_fndc_out_ah_today:
        friendly_name: 'FNDC Out AH Today'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Out_AH_today"] }}'
        unit_of_measurement: "AH"
        
      pv_fndc_out_kwh_today:
        friendly_name: 'FNDC Out kWh Today'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Out_kWh_today"] }}'
        unit_of_measurement: "kWh"
        
      pv_fndc_soc:
        friendly_name: 'FNDC SOC'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["SOC"] }}'
        unit_of_measurement: "Percent"
        
      pv_fndc_shunt_b_i:
        friendly_name: 'FNDC Shunt B Input'
        entity_id: sensor.mate3s_report
        value_template: '{{ states.sensor.mate3s_report.attributes["devstatus"]["ports"][2]["Shunt_B_I"] }}'
        unit_of_measurement: "AH"
  
#####################################################################      
# Calculate total PV Watts In (pv_fndc_shunt_b_i * pv_cc_batt_v)
#####################################################################      
  
  - platform: template
    sensors:
      pv_energy_from_panels:
        unit_of_measurement: 'Watts'
        friendly_name: "PV Energy From Panels"
        value_template: > 
          {% set amps_now = states('sensor.pv_fndc_shunt_b_i') %}
          {% set volts_now = states('sensor.pv_cc_batt_v') %}
          {{ (float(amps_now) | float(2) * float(volts_now) | float(2)) | round(2) }}

Any help would be appreciated on
a) why am I getting “unavailable”
b) how to I check for it and provide previous sensor value instead of the word “unavailable”. (see what I tried in code above).

Thanks!!!

Oh yes, this is what it looks like when it goes "unavailable:

Read the warning on the templating page about using states.entity_id.state vs states('entity_id').

You could try creating a ping sensor to your outback ip and monitor that to reveal any network issues.

Thanks Tom.
I changed all the sensors to use "state_attr()…

As for catching the “Unavailable” issue, I tried this:

        value_template: > 
          {% if states("sensor.pv_cc_batt_v") != "Unavailable" %}
            {{ state_attr("sensor.mate3s_report", "devstatus") ["ports"][1]["Batt_V"] }}
          {% else %}
              ??
          {% endif %}

And although it does not blow up, it still shows “Unavailable” when the sensors disappear.
Why are we going unavailable? Nothing in the logs.

I wonder if my system is just bogged down.
Any ideas?

Did you resolve your issue? I want to add my Outback systems to my HA. If there is an update to your code perhaps you would be willing to share it?

1 Up. I’m also interested in a solution.

Don’t know if someone can help but my JSON is malformed :


{"devstatus": {
"Gateway_Type": "Mate3s","Sys_Time": 1628924683,
"Sys_Batt_V": 55.4,
"ports": [
		{ "Port": 1, "Dev": "GS","Type": "60Hz","Inv_I_L1": 0,"Chg_I_L1": 0,"Buy_I_L1": 6,"Sell_I_L1": 0,"VAC1_in_L1": 126,"VAC2_in_L1": 0,"VAC_out_L1": 124,"Inv_I_L2": 0,"Chg_I_L2": 0,"Buy_I_L2": 5,"Sell_I_L2": 0,"VAC1_in_L2": 127,"VAC2_in_L2": 0,"VAC_out_L2": 124,"AC_Input": "Grid","Batt_V": 55.2,"AC_mode": "AC USE","INV_mode": "PassThru","Warn": ["none"],"Error": ["none"],"AUX": "disabled","RELAY": "disabled"},
{ "Port": 8, "Dev": "CC","Type": "FM100","Out_I": 7.9,"In_I": 2,"Batt_V": 55.3,"In_V": 170.9,"Out_kWh": 0.1,"Out_AH": 2,"CC_mode"[u][u]**: " ","Error": ["Shorted RTS",],"**[/u][/u]Aux_mode": "Manual","AUX": "disabled"},
{ "Port": 10, "Dev": "FNDC","Enabled": ["A","B"],"Shunt_A_I":  0.0,"Shunt_A_AH": 0,"Shunt_A_kWh":  0.000,"Shunt_B_I":  8.0,"Shunt_B_AH": 0,"Shunt_B_kWh":  0.040,"SOC": 100,"Min_SOC": 99,"Days_since_full": 109.3,"CHG_parms_met": false,"In_AH_today": 3,"Out_AH_today": 2,"In_kWh_today":  0.150,"Out_kWh_today":  0.130,"Net_CFC_AH": 0,"Net_CFC_kWh":  0.030,"Batt_V": 55.4,"Batt_temp": "30 C","Aux_mode": "manual","AUX": "disabled"}
]}}

,“Error”: [“Shorted RTS”,],"

I have to search/replace ,] with ].

Do someone know how to do that ?

Yeah
2 notable repairs:
a) upgraded my system off the pi onto an Intel NUC (much faster now , especially since I’m storing a lot of data).
b) Updated the yaml (similar to above).
I’m uploading things to github now, so I’ll post the link shortly.

As for the replace code above, the new python libraries will actually create the json properly.
Make sure the libraries are up to date.
Why do you have a “shorted rts” error (not that it matters, but it is curious).

Here is my github link

I’ll be happy to coach and help if anyone needs any help.
I did find one issue about my python code - it is “hardcoded” to use only the ports which are defined in the Mate3S… if your hardware lives on different ports, you need to modify it accordingly.

I’ll be creating a new version whch just searches for things, and then builds appropriate json for export at some point totally generically, but for now, you need to know which port your cc is on, and so on.

Also note, I updated my cc from an fm80 to an fm100, the code is basically the same, but there are new constants which show that instead.

Enjoy

Thank you very much! This certainly gives me a head start over having to do it from scratch. My equipment is different (Mate3, 2xGS8048A, 4xFM-80,FN-DC) but I would think that the changes would be minor. One of my goals is to automatically control the charging of the electric car. It does fine on sunny days but when there is less than full sun I would like it to reduce the current going to the car. Currently we have keep an eye on it and reduce it manually. Now I just need to find the time to dig into all of this.

Wao ! Congrats that seems nice.
I didn’t implement it for the moment cause I’m wondering how python would manage my JSON error :

My Mate3s gives a malformed JSON and I was wondering how to manage it. I did a first test getting the malformed JSON in Node Red and performing a string find/replace to get rid of it but that didn’t satisfy me cause I’m using inputs as variables in HA. Your way of doing things using MQTT is much more elegant.

Can you suggest me a code line which could do my find/replace so that I add it in your code for my malformed JSON (I’m not a python dev).

The find/replace is just find ‘,]’ and replace with ‘]’.

Actually my JSON is :


{"devstatus": {
"Gateway_Type": "Mate3s","Sys_Time": 1630683059,
"Sys_Batt_V": 50.5,
"ports": [
{ "Port": 1, "Dev": "GS","Type": "60Hz","Inv_I_L1": 10,"Chg_I_L1": 0,"Buy_I_L1": 0,"Sell_I_L1": 0,"VAC1_in_L1": 118,"VAC2_in_L1": 0,"VAC_out_L1": 125,"Inv_I_L2": 19,"Chg_I_L2": 0,"Buy_I_L2": 0,"Sell_I_L2": 0,"VAC1_in_L2": 119,"VAC2_in_L2": 0,"VAC_out_L2": 123,"AC_Input": "Grid","Batt_V": 50.0,"AC_mode": "AC DROP","INV_mode": "Inverting","Warn": ["none"],"Error": ["none"],"AUX": "disabled","RELAY": "disabled"},
{ "Port": 8, "Dev": "CC","Type": "FM100","Out_I": 58.9,"In_I": 19,"Batt_V": 50.6,"In_V": 159.3,"Out_kWh": 28.0,"Out_AH": 514,"CC_mode": "","Error": ["Shorted RTS",],"Aux_mode": "Manual","AUX": "disabled"},
{ "Port": 10, "Dev": "FNDC","Enabled": ["A","B"],"Shunt_A_I":  -80.9,"Shunt_A_AH": -230,"Shunt_A_kWh":  -12.050,"Shunt_B_I":  58.6,"Shunt_B_AH": 220,"Shunt_B_kWh":  11.600,"SOC": 95,"Min_SOC": 94,"Days_since_full": 129.7,"CHG_parms_met": false,"In_AH_today": 515,"Out_AH_today": 465,"In_kWh_today":  27.920,"Out_kWh_today":  24.990,"Net_CFC_AH": -43,"Net_CFC_kWh":  -2.190,"Batt_V": 50.5,"Batt_temp": "30 C","Aux_mode": "manual","AUX": "disabled"}
]}}

As you can read on Port 8 line :
,"Error": ["Shorted RTS",],
is not a valid JSON

Thanks

Hello, I have a pair of outback flexmax80, I would like to get the data and use it in Home Assistant just like you, my problem is that I have no idea of programming and even seeing your codes I am not able to know how to start, wiring, etc. Is it possible that any of you can help me or if he knows of a step-by-step tutorial from how to connect the outputs to how and where to put the code? Thank you very much

Hello there.
I will be happy to help you, but it does require the use of home assistant, and how to work with a raspberry pi. I don’t have a “turn key” solution, where you just plug it in and get data… it will require work and customization to get there.

Where are you located in the world?

I can answer questions and steer you to the right place as best I can.

Thanks

I´m from Barcelona, i have home assistant with many things, node red, studio code, file editor, esphome etc. My english is very poor, sorry.
what cable do I have to make, where to connect it and how to send the data, or it has to be through a raspberry and send it to my home assistant server
I have any arduinos and esp8266, an elfin-ew11, thanks

This is really great looking, I have a really basic question though, how do you get the cron script working on a single board computer (Odroid in my case, but very similar to RPI) when it’s running HAOS? I can’t see down to the underlying system (if it’s there at all).

Do you boot outside of HAOS and set up Cron then boot back into HAOS?