We have successfully pulled the data available from a Selectronic SP-PRO inverter into HA using a rest sensor. There were 3 steps:
- get the local url for the Selectronic Inverter
- add a rest sensor to configuration.yaml
- add some sensor templates to configuration.yaml
1. local url: The Selectronic SP-PRO inverter controls an off-grid solar power installation. Selectronic (company) provides the free select.live website to monitor the power system. When you open the select.live dashboard in a browser you can typically right-click on the page and select view page source
. Search for the variable live_URLs
and make a copy of the first element in the array. The url will look something like:
//192.168.1.2/cgi-bin/solarmonweb/devices/732839EE3F53BDB735DFUYHD732793AB/point
If you paste this url into your browser address bar you will get to see the json reply from the Selectronic SP-PRO. Something like:
{
"device":{
"name":"Selectronic SP-PRO"
},
"item_count":22,
"items":{
"battery_in_wh_today":13.2890625,
"battery_in_wh_total":126.615234375,
"battery_out_wh_today":7.998046875,
"battery_out_wh_total":117.87890625,
"battery_soc":99.13671875,
"battery_w":435.791015625,
"fault_code":0,
"fault_ts":0,
"gen_status":0,
"grid_in_wh_today":0.0,
"grid_in_wh_total":0.56946533203125005,
"grid_out_wh_today":0.0,
"grid_out_wh_total":0.0,
"grid_w":0.0,
"load_w":389.1346435546875,
"load_wh_today":7.1752631835937501,
"load_wh_total":213.43560644531252,
"shunt_w":0.0,
"solar_wh_today":10.592055175781251,
"solar_wh_total":233.02521386718752,
"solarinverter_w":0.0,
"timestamp":1594021705
},
"now":1594021710
}
2. rest sensor: Add the following lines to your configuration.yaml under the sensor:
tag. Insert your local url as the resource:
sensor:
- platform: rest
name: "selectronic"
json_attributes_path: "$.items"
json_attributes:
- 'battery_in_wh_today'
- 'battery_in_wh_total'
- 'battery_out_wh_today'
- 'battery_out_wh_total'
- 'battery_soc'
- 'battery_w'
- 'fault_code'
- 'fault_ts'
- 'gen_status'
- 'grid_in_wh_today'
- 'grid_in_wh_total'
- 'grid_out_wh_today'
- 'grid_out_wh_total'
- 'grid_w'
- 'load_w'
- 'load_wh_today'
- 'load_wh_total'
- 'shunt_w'
- 'solar_wh_today'
- 'solar_wh_total'
- 'solarinverter_w'
- 'timestamp'
resource: "http://192.168.1.2/cgi-bin/solarmonweb/devices/732839EE3F53BDB735DFUYHD732793AB/point"
value_template: '{{ value_json.device.name }}'
force_update: true
3. sensor templates: add some sensor templates to reformat the raw data a little. Some examples:
sensor:
- platform: template
sensors: # for data obtained from selectronic inverter
power_battery_soc:
friendly_name: battery soc
device_class: battery
value_template: "{{(state_attr('sensor.selectronic', 'battery_soc')|float) | round(1)}}"
unit_of_measurement: "%"
entity_id: sensor.selectronic
power_battery_kw:
friendly_name: battery load
device_class: power
value_template: "{{(-state_attr('sensor.selectronic', 'battery_w')|float /1000) | round(2)}}"
unit_of_measurement: "kW"
entity_id: sensor.selectronic
power_load_kw:
friendly_name: load
device_class: power
value_template: "{{(state_attr('sensor.selectronic', 'load_w')|float /1000) | round(1)}}"
unit_of_measurement: "kW"
entity_id: sensor.selectronic
power_solar_kw:
friendly_name: solar
device_class: power
value_template: "{{(state_attr('sensor.selectronic', 'solarinverter_w')|float /1000) | round(1)}}"
unit_of_measurement: "kW"
entity_id: sensor.selectronic