var count = context.get('count')||0;
count += 1;
/*
IF you do not want to update HA every second you can set the fuction to pass
the data less often - see below
*/
if (count < 1) { /* process data only every 30 seconds */
context.set('count',count);
return null;
}
count = 0;
context.set('count',count);
var msg1 = { payload:"actual consumption" };
var msg2 = { payload:"actual gridfeed" };
var msg3 = { payload:"consumption counter" };
var msg4 = { payload:"gridfeed counter" };
var msg5 = { payload:"voltage" };
/* to get the actual grid consumption in W we need the offset 0.1.4.0 */
offset = msg.payload.indexOf("00010400", 0, "hex")+ 4;
var consumption = parseInt((msg.payload[offset+0]*0x1000000 +
msg.payload[offset+1]*0x10000 +
msg.payload[offset+2]*0x100 +
msg.payload[offset+3]) / 10);
/* to get the actual grid consumption counter in Wh we need the offset 0.1.8.0 */
offset = msg.payload.indexOf("00010800", 0, "hex")+ 4;
var consumption_c = parseInt((msg.payload[offset+0]*0x100000000000000 +
msg.payload[offset+1]*0x1000000000000 +
msg.payload[offset+2]*0x10000000000 +
msg.payload[offset+3]*0x100000000 +
msg.payload[offset+4]*0x1000000 +
msg.payload[offset+5]*0x10000 +
msg.payload[offset+6]*0x100 +
msg.payload[offset+7]) / 3600);
/* to get the actual grid feed in W we need the offset 0.2.4.0 */
offset = msg.payload.indexOf("00020400", 0, "hex")+ 4;
var gridfeed = parseInt((msg.payload[offset+0]*0x1000000 +
msg.payload[offset+1]*0x10000 +
msg.payload[offset+2]*0x100 +
msg.payload[offset+3]) / 10);
/* to get the actual grid feed counter in Wh we need the offset 0.2.8.0 */
offset = msg.payload.indexOf("00020800", 0, "hex")+ 4;
var gridfeed_c = parseInt((msg.payload[offset+0]*0x100000000000000 +
msg.payload[offset+1]*0x1000000000000 +
msg.payload[offset+2]*0x10000000000 +
msg.payload[offset+3]*0x100000000 +
msg.payload[offset+4]*0x1000000 +
msg.payload[offset+5]*0x10000 +
msg.payload[offset+6]*0x100 +
msg.payload[offset+7]) / 3600);
/* to get the actual Voltage of Phase1 we need the offset 0.32.4.0 note 32 = 0x20 in hex*/
offset = msg.payload.indexOf("00200400", 0, "hex")+ 4;
var voltage = parseInt((msg.payload[offset+0]*0x1000000 +
msg.payload[offset+1]*0x10000 +
msg.payload[offset+2]*0x100 +
msg.payload[offset+3]) / 1000);
msg5.payload = voltage.toString();
if (consumption >= 0 && consumption < 100000 ) {
msg1.payload = consumption.toString();
} else msg1 = null;
if (consumption_c >= 0 && consumption_c < 50000000 ) {
msg2.payload = consumption_c.toString();
} else msg2 = null;
if (gridfeed >= 0 && gridfeed < 100000 ) {
msg3.payload = gridfeed.toString();
} else msg3 = null;
if (gridfeed_c >= 0 && gridfeed_c < 5000000 ) {
msg4.payload = gridfeed_c.toString();
} else msg4 = null;
if (voltage >= 0 && voltage < 1000 ) {
msg5.payload = voltage.toString();
} else msg5 = null;
return [msg1, msg2, msg3, msg4, msg5 ];
Iām doing this as per the description above. Using voltage as well as I log the grid fluctuations to show the utility company that there is a problem.
Iām also using Modbus with both inverter and battery charge. Descriptions can be found on this forumā¦
My config is already posted here. Modbus config is only to the inverter and battery charger, not Home Manager. HM2.0 is totally useless. I wish I had not spent money on thisā¦
when you say useless is that for usage with home-assistant? I thought I need a Home Manager for Battery usage and even without Battery to self consume the power. Or if no HM 2.0 then the SMA energy meter correct?
My understanding is that the home manager is only used, if you have compatible switches and to give you better predictions. It is not needed to use your system, ne it battery or self-consumption. It is useless for Home Assistant, as it disables WebConnect. Users are left with only ModBusa in order to access the devicesā dataā¦
Not sure what you mean by āenergy self consumption and batteryā. As previously stated, you can use your self produced electricity and use a battery whitout Home Manager 2. You may want to check with your installer why he recommended this?
SMA HomeManager is a real winner if you have electrical devices where solar power distribution can be controlled using the SMA communication protocol. These are batteries, wallboxes etc. where a substantial percentage of the current solar power can be used.
I use HomeManager 2.0 to control a 22kW Amtron wallbox. When the wallbox is controlled by HomeManager only solar energy is used to charge the car. This works extremely well. SMA and Mennekes (the manufacturer of the Amtron callboxes) developed the communicaton protocol together. To use this to integrate just your dish-washer is in my opinion not worth the effort.
Hi Chris, that is what I meant with self consumption. Iām looking for a SMA batterie, plus some devices with EEBus like my washing machine and later on a dryer, plus a wallbox. So then I will go with the Home Manager 2.0 and also use it to control my heatpump. That was helpful. And I like the Node-Red Thing!
Hello. Looking for a little help with the sma stuff. I currently have 2 SMA sunnyboy 6.0 inverters.
i was able to get one of them connected with the basic platform: sma
I can display pv power, voltage1 and voltage 2. i can not seem to get the daily yield to work
I did the inspect element on the webconnect and it doesnt seem to give me a custom code.
if i do the daily_yield. i get unknown and this in the logs
No values for sensors: daily_yield [6400_00262200]. Response from inverter: {ā6100_0046C200ā: {ā1ā: [{āvalā: 1766}]}, ā6100_00464800ā: {ā1ā: [{āvalā: 11856}]}, ā6100_00464900ā: {ā1ā: [{āvalā: 11908}]}}
3:19:33 PM ā /usr/local/lib/python3.8/site-packages/pysma/init.py (WARNING) - message first occurred at 2:59:33 PM and shows up 49 times
2nd question is there a way to have 2 inverters? i tried to do another platform:sma and the ip of the other inverter but HA complains about duplicate everything
I had the same issue with the sma module as I wanted to connect to multiple SMA inverter. The only way to currently read multiple SMA devices is via the modbus package. The whole list of values you can poll you can find in the modbus or sunspec documentation.
Below as an example my configuration.yaml with four SMA inverter and modbus tcp on port 502 enabled for all of them in the inverter webconfig:
and than add an extra file sensor.yaml for the sensor readings e.g.:
#### modbus 60 sec polling
- platform: modbus
scan_interval: 60
registers:
#### STP 10.0
- name: AC Leistung STP10
hub: inverter_pv_stp10
device_class: power
unit_of_measurement: W
data_type: int
slave: 3
register: 30775
register_type: holding
count: 2
- name: DC Leistung STP10 A
hub: inverter_pv_stp10
device_class: power
unit_of_measurement: W
data_type: int
slave: 3
register: 30773
register_type: holding
count: 2
- name: DC Leistung STP10 B
hub: inverter_pv_stp10
device_class: power
unit_of_measurement: W
data_type: int
slave: 3
register: 30961
register_type: holding
count: 2
- name: Netzbezug STP10
hub: inverter_pv_stp10
device_class: power
unit_of_measurement: W
data_type: int
slave: 3
register: 30865
register_type: holding
count: 2
- name: Netzeinspeisung STP10
hub: inverter_pv_stp10
device_class: power
unit_of_measurement: W
data_type: int
slave: 3
register: 30867
register_type: holding
count: 2
#### STP 8.0
- name: AC Leistung STP8
hub: inverter_pv_stp8
device_class: power
unit_of_measurement: W
data_type: int
slave: 3
register: 30775
register_type: holding
count: 2
- name: DC Leistung STP8 A
hub: inverter_pv_stp8
device_class: power
unit_of_measurement: W
data_type: int
slave: 3
register: 30773
register_type: holding
count: 2
- name: DC Leistung STP8 B
hub: inverter_pv_stp8
device_class: power
unit_of_measurement: W
data_type: int
slave: 3
register: 30961
register_type: holding
count: 2
And so on. I think this should get you the idea. SMA recommends to not poll too many registers simultaneously. Therefore some less critical values can be read less often, e.g.
I installed solar this summer and have three SMA Sunnyboy inverters, this is my solution to reading and combining the individual inverters and sending to data to HA using MQTT:
Simple setup by modifying the file configuration.py, then setting up a cron job to start it once a day before sunrise.
Hello all, I have a Sunny Boy 4.0 and by reading a little bit here and on other forums I managed to get a few readings from my inverter. These are: total_yield, grid_power, pv_power (gets me the same reading as grid_power) and voltage_l1. The rest of the values are āunknownā. I would like to be able to output the DC readings from the two strings of panels. I obtained the sensor keys but when I try to create the custom sensors in configuration.yaml, it doesnāt like the names I give them and the configuration check fails.
You should be able to retireve those values by adding āpv_power_aā and āpv_power_bā to your sensor configuration (they are predefined in pysma that Home Assistant uses under the hood).