[New Service] SMA SEMP Protocol - Addons/IO

Hi,
I wrote a SEMP service for OpenHab and it would be great if someone would test it. Depending on how many people are testing it I would try to get it to the default installation. I share the software under the Eclipse Public License . openhab2-addons/LICENSE at master · openhab/openhab2-addons · GitHub.

Download OH2.5: org.openhab.io.semp

Download OH3: org.openhab.io.semp

Readme:

openHAB SEMP Service

This service implements the SEMP protocol for openHAB

Features:

  • UPNP automatic discovery
  • Full SEMP Support
  • Support ON/OFF and Decimal item types

Installation:

After the activation of this plugin and the configuration it (e.g. in PaperUI) and of the consumer(s) the upnp service will start immediately. After some minutes you can start a device search in the SMA Sunny Portal. It will detect the device(s) and you will be able to add it to your device list.

Configuration:

An UUID (Universal Unique Identifier) is a 128-bit number used to uniquely identify some object or entity on the Internet. Usually it’s a mac and time based V1 UUID but it is possible to use a random generated UUID, too. There are some generators in the internet available.
Important: if you change it then you have to recreate the consumers in SMA Sunny Portal.

org.openhab.semp:discoveryUUID=8e75f1cc-848e-40ca-b7ec-87369019bd10

(Optional) For systems with multiple IP addresses the IP to use for UPNP may be specified, otherwise the first non loopback address will be used.

org.openhab.semp:discoveryIp=192.168.1.100

(Optional) Some SEMP applications require a different port (80) then what openHAB runs on by default (8080). This option will only advertise a different port then what we are listening on. Useful if you have an iptables rule redirect traffic from this port to the openHAB port.

org.openhab.semp:discoveryHttpPort=8080

Persistence (Optional)

Usually this plugin will send the devices status every minute. But there is the possibility to send values up to the last 10 minutes, too. If you want to use this feature then you have to configure persistence for this item. If your persistence is supporting a step smaller then one minute then this plugin will determine additional values like min, max or average from the last 60 seconds.

Device Tagging

The SEMP service supports multiple consumers. Every SEMP consumer needs up to four items mapped inside one group. These items are a switch item (on/off) for device controlling, a number item (power), an optional contact item for the “Connected” state and an optional contact item for the “Listening” state.
The identification of a SEMP consumer is a group-tag [“Consumer”]. The identification for the consumers items is a tag with the name of the consumers group.
These “contact” items has to be tagged for identification, too. Use the [“Connected”] tag for the indication whether the consumer is connected (like a car on an EVCharger) and the [“Listening”] Tag for the indication whether the consumer is listening to the SEMP commands. (e.g. you should set it to open if you are charging a car manually without SEMP).

Consumer Configuration

The consumer need some configuration parameters. This parameters are tags for the group item, too.

All tags are formatted like this:

semp:<tagtype>:<value>

For example:

semp:max_power:1400

If you’ve defined your Items in .items files, tags can be added using:

[ "mytag" ]

syntax (after the (Groups) and before the {channel}).
If you created your items another way, e.g. using the Paper UI, HABmin allows you to modify the tags.

Tag: device_id

The device ID is represented by a 92 bit integer which consists of the following components:
Device ID (92 bits):

Vendor ID type (4 bits)  + Vendor ID (32 bits)  + Serial-number (48 bits) + Sub-device ID (8 bits) 

Required: no

Default: auto-generated from consumers name

Example:

semp:device_id:F-11223344-112233445566-00

Tag: device_vendor

Name of the device’s vendor.

Required: no

Default: Unknown

Example:

semp:device_vendor:Unknown

Tag: device_type

Type of device. One of the values predefined in the SEMP XSD should be used:

AirConditioning
Charger
DishWasher
Dryer
ElectricVehicle
EVCharger
Fridge
Heater
HeatPump
Motor
Pump
WashingMachine
Other

Required: no

Default: Other

Example:

semp:device_type:WashingMachine

Tag: device_serial

A serial number that is known by the user so that he is able
to identify the device. If available use the vendor specific serial number which is printed on
the device.

Required: yes

Example:

semp:device_serial:abc123456789

Tag: max_power

Maximum power consumption of the device (in W).

Required: yes

Example:

semp:max_power:1400

Tag: min_off_time

When switched off (or paused), the device has to remain off for at least the given amount
of seconds.

Required: no

Default: 0

Example:

semp:min_off_time:15

Tag: min_on_time

When switched on (or un-paused), the device has to remain on for at least the given
amount of seconds.

Required: no

Default: 0

Example:

semp:min_on_time:15

Tag: inter_alowed

Specifies whether the device can be interrupted (paused) during runtime. This
allows a more flexible energy management for the device. For instance the EM
can interrupt a device in case of unpredictable bad weather conditions or when
the user switches on a device with conflicting energy needs and restart the inter-
rupted device afterwards.

Should be set to “true”. Set to “false” only if the device operation cannot be
paused, e.g. for some program based devices.

Required: no

Default: true

Example:

semp:inter_alowed:true

Tag: earliest_start

Specifies the earliest start time [in minutes from midnight] of the device.

Required: yes

Example:

semp:earliest_start:600
600->every day at 10am

If you want multiple time frames then you need to separate them with":"

semp:earliest_start:600:1020

Tag: latest_end

Specifies the end of the planning range. This is the latest possible time the device opera-
tion has to be finished. [in minutes from midnight]

Required: yes

Example:

semp:latest_end:660
660->every day at 11am

If you want multiple time frames then you need to separate them with":"

semp:latest_end:660:1080

Tag: min_running_time

The minimum amount of time the device needs to run in the time range specified by Earli-
estStart and LatestEnd. It will be assigned to device by the EM even if there is no PV-
production so that grid-energy has to be used to power the device. Note: If set to “0”
all of the energy is optional and should only be allocated to the device if certain
conditions are fulfilled (e.g. cheap PV-energy available). [in minutes]

Required: yes

Example:

semp:min_running_time:30

If you want multiple time frames then you need to separate them with":"

semp:min_running_time:30:20

Tag: max_running_time

The maximum amount of time the device needs to run in the time range specified by Earli-
estStart and LatestEnd. The difference between MaxRunningTime and MinRunningTime is
the optional runtime that can be assigned to the device by the EM if cheap energy (e.g.
excess PV-energy) is available. [in minutes]

Required: yes

Example:

semp:max_running_time:50

If you want multiple time frames then you need to separate them with":"

semp:max_running_time:50:40

Tag: days_of_week

Some consumers didn’t have to run every day. Meybe only on the weekdays or on the weekend. With this parameter it’s possible to set the relevant days of the week. These days have to be set in short format, Mon, Tue, Wed, Thu, Fri, Sat, Sun.

Required: no

Example:

semp:days_of_week:Mon

If you want multiple days then you need to separate them with":"

semp:days_of_week:Mon,Wed,Fri

Example

demo.items:

Group PwrSwitchMedia    "PowerSwitchMedia"    ["Consumer","semp:device_serial:abc123456789","semp:max_power:1400","semp:earliest_start:600","semp:latest_end:1000","semp:min_running_time:0","semp:max_running_time:300"] 

Switch Media_Switch   "Media center switch" (PwrSwitchMedia) { knx="<3/1/4" }
Number Media_Power    "Media center power" (PwrSwitchMedia)  { channel="edimax:sp2101w:29a0126d:power"} 

Contact isListening "Consumer is Listening" (PwrSwitchMedia)  ["Listening"] 

12.11.2019
New version with support for “Connected” and “Listening” contact items and a new group parameter “days_of_week”.

02.02.2021
Fixed links, some small bugfixes, OH3.0 Version

22.12.2021
New compiled version for OH 3

3 Likes

Hi,

i get installed my SMA-solar in the next days and very interessted in this service.
Did anyone tested it yet?

Thanks,
Stefan

Can you perhaps describe in a little more detail how I have to install the binding?

Just copy it into the addons folder.

Unfortunately the download link is not working anymore. Could you please share a new link?

I am highly interested in the addon. :slight_smile:

Hi Markus,

I’m also interested in the new version with support for “Connected” and “Listening” state.
The download link is not working, can you please upload the current version?

Thanks

I just fixed the links in the first post and added a version for OH 3.0.

Hi,

I copied the version for OH2.5.
The service is enabled. I set the UUID in PaperUI.
Create the items like your example, but I can’t see any log information from semp
and when I start to search for devices in the sunny portal, it find nothing.

Any ideas, what is going wrong??

Hi,
can you see this in the logfile?

2021-02-21 11:09:32.670 [INFO ] [openhab.io.semp.internal.SEMPServlet] - Started SSDP/SEMP Info service at /uuid:abcd1234-1234-ffff-aaaa-000000000000 and /semp.

Usually it should work, maybe a problem in the configuration.

There is no entry like this in the logfile.
Did i something wrong with the UUID? I generate a random uuid from a website.

In the karaf console the service is listed.
After stop and start the service, there are no entries in the log.
Reboot the rpi, doesn’t help.
OH Version is 2.5.10-1 (release build)

Hi,
I have a similar problem as cjoschui.
I used the OH3.0 addon at my openhabian installation. The service is enabled, too.
In my case I can see the entry in the logfile, but the result is the same.
It does not find any device at the sunnyportal.

I also used your examle (PwrSwitchMedia) for the first try.

@cjoschiu: Have you added tags with the name of the consumer group to the subitems?

Hmm that’s strange. Here it works without any problems, this is my config:

Group WallBeSMA    	"Wallbe-Wallbox ECO 11kW"    ["Consumer","semp:device_vendor:wallbe","semp:device_type:EVCharger","semp:device_serial:012-01234-12-12-123","semp:max_power:11000","semp:earliest_start:180","semp:latest_end:1430","semp:min_running_time:180","semp:max_running_time:720"] 

Switch WBLadevorgangFreigeben		"Ladevorgang freigeben [%d]"  						(gWallbe, WallBeSMA)  	{ channel="modbus:data:wallbe:wb_coil_400_11:wb_400:switch" }

Number WMWirkleistung	 			"Durch. Wirkleistung [%.2f W]"   					(gWallbe, WallBeSMA)  	{ channel="modbus:data:7KT1665:wm_input_34_32:wb_58_2:number" }

Contact WMCarConnected				"Auto ist angeschlossen [%d]" 						(gWallbe, WallBeSMA)	["Connected"]


Yes i tagged the switch and a number item with the consumer group.

I edited the posting above and added the other channels. It is simmilar to yours?

Group       gSteckdoseKuehlschrank    "PowerSwitchMedia"    ["Consumer","semp:device_serial:tuya4147","semp:device_type:Fridge","semp:max_power:1400","semp:earliest_start:600","semp:latest_end:1200","semp:min_running_time:300","semp:max_running_time:800"] 

Switch      SteckdoseKuehlschrank                             "Kühlschrank-Steckdose"                                                      <power> (gSteckdoseKuehlschrank){ channel="mqtt:topic:Mosquitto:tuyaplug4147:Power" }
Number      SteckdoseKuehlschrankPower                          "Verbrauch Insgesamt"                                                       (gSteckdoseKuehlschrank) { channel="mqtt:topic:Mosquitto:tuyaplug4147:TotalPwr" }```

Do i need the contact item or is it optional?

Connected and Listening are optional.

Do you use hue emulation?

I’ve created a second device in the config and it was detected without problems.

If it’s still not working then activate debug for this binding and send me the logfile including initialization.

I set the logging Level to debug for
org.openhab.io.semp

Is that correct?
Because I set it already to debug, but there are no debug entries in the Log.

OK, I got it.

I add the uuid to the runtime.cfg file.
After that the service starts and the sunny portal found the tagged device.

GREAT. IT WORKS. I’m so excited.

Thanks for the support.