Show energy balance of solar production in sitemap with different icons regarding in or out

Hi,

i want to show the actual energy balance of my house.
i have the energy produced from my inverter ( item “inverter1ActivePower”) and i have the energy which will be put in the battery or in the public net (item “SMA_power_out”). When getting energy from the public red i get that value on another item “SMA_power_in”

So i want to show the energy balance , so the positiv one if power is going into the public net with a green icon and in case of consumption from the public net an red icon with the value of “SMA_Power_in”.

This sideman code

Text item=inverter1ActivePower icon="poweroutlet" label="%d W"
Text item=SMA_power_out icon=[SMA_power_out>0 ? "arrow-up" : "arrow-down"] label=[SMA_power_out>0 ? "Energy to grid: %d W" : "Energy from grid: %d W"]
Text item=SMA_power_in icon=[SMA_power_in>0 ? "arrow-down" : "arrow-up"] label=[SMA_power_in>0 ? "Energy from grid: %d W" : "Energy to grid: %d W"] visibility=[SMA_power_in>0]

Text item=Energy_Balance label="Energy Balance: [%d W]" icon=[inverter1ActivePower-SMA_power_out+SMA_power_in > 0 ? "arrow-up" : "arrow-down"] {
    Text item=inverter1ActivePower label="Produced" icon="sun"
    Text item=SMA_power_out label="Energy to grid" icon="arrow-up"
    Text item=SMA_power_in label="Energy from grid" icon="arrow-down"
}

is not working due to syntax errors

Configuration model 'standard.sitemap' has errors, therefore ignoring it: [125,32]: no viable alternative at input '['
[125,84]: no viable alternative at input '['

Any idea how to realize?

Where did you get that syntax? Based on the docs for dynamic sitemaps only visibility and labelcolor and valuecolor support expressions like that. And even for those, the expressions use a completely different syntax.

See the icons section for how to do dynamic icons. If you can’t achieve what you are after using that, you’ll either have to put it on the sitemap twice (once for each icon) and use visibility to hide one based on the Item states. Or create a rule to move the icons around on disk based on the states of the Items.

You might not like my answer in the first place but your imho best bet is to drop sitemaps altogether and replace them with MainUI widgets. Any invest (of your time) in ‘doomed’ old technology options is a waste and better spent on familiarizing yourself with what has become available as alternatives in OH3.

More work short term yes, but savings in the long run.
Don’t worry it’s no one-or-the-other. I myself am also still using sitemaps but anything “new” I want I will only implement based on widgets. There’s so much more you can do with them, and there’s even many templates available you can copy ‘n’ paste.
It’ll be a huge leap in terms of UX, i.e. the look and usability of it.
There’s for example an animated widget to show energy flows of your inverter, battery, grid and consumers.

Or just install from the marketplace.

I’m not sure I would state this so strongly. Many of the developers and maintainers, including the developers of the Android app and OH core still use and prefer sitemaps. Even as I type this there are PRs to add new functionality to sitemaps FOR OH 4. I do not expect them to go away any time in the foreseeable future.

However, it is definitely true that MainUI is a much more dynamic and customizable interface. @ollys, in addition to the widget @mstormi posted there are four other energy widgets on the marketplace. And what’s key is that these are installed like an add-on and configured like a Thing. You don’t even have to look at the code if you don’t want to.

thanks guys, i will give this a try… i need first do create a basic structure in that widget things…4 floors… all lamps and power sockets knx, sonos, vallox air sysem, e-charger, pv inverter etc…and all accessable via the openhab app remotly… dont know how widget ui is working remotly… and i didnt found a nice icon set what i like… have to search more and than maybe copy a basic structure and develop that setup… thanks… first i will check teh syntax… i think i found my problems… but further hints also regarding widget ui are welcome!

The app supports it already. Essentially it’s a fallback to a web display on your smartphone but as MainUI is responsive design, it adapts its display to the end device’s characteristics.

Check out iconify: support, there’s a link in the widget options. More icons than you ever wanted having to choose from :slight_smile:

It’s fully supported. There are some properties you can set to help it adjust to small screens but other than that it works quite well.

MainUI supports all the OH icons, F7, Material, and Iconify natively. Anything outside of that can be copied and converted to OH icons following the instructions in the docs.

Though if you can’t find it in Iconify, it probably doesn’t exist.

Well then, since you’re using an SMA inverter I assume you’re German … so another option is to get my energy management system … it’s also featuring that widget I referred to, and alot more.
Free demo @ https://storm.house/installation#demo .

Hi mstormi,

thanks for that info, but i hope i will get ride of my sma stuff! i need a pv and battery solution with full power backup within ms and not via envitec-box within 20 seconds! the lg chem resu10h prime is still not certified for the “new” sma smartenergy inverters… since january 2022 they are anouncing to certify more bateries but still only byd is certified … sma is technically behind with the hybrid technologie…but i try to solve some small issues, also to learn… i managed it but now i have another problem:

Number SMA_power_in "Aktueller Netzbezug [JS(divide1000.js):%s kWh]"	<energy>	 	(gSMA) 	{ channel="smaenergymeter:energymeter:-1292110004:powerIn" }

gives me the value in kWh, so divided with 1000, but its not showing the unit kWh with this syntax.
When putting in the sidemap than this:

		Text item=SMA_power_in icon="offgrid.png" visibility=[SMA_power_in > 0 ] label="Netzbezug [%s kWh]" labelcolor=["red"] valuecolor=["red"]

i get again the value in W but with the unis specified in the sidemap… - very strange…

Oh dear. Support of SMA was actually my most recent inverter addition and right, I, too, have been cursing SMA for several of their weird software implementation details, too.
I myself actually own a Sungrow SH RT and a RESU10h, works pretty well and can switch backup in 20ms without any external Enwitec.
Unit display and conversions are pretty complex issues you should not be doing with strings (%s) or in sitemaps but using metadata and UoM (Units of Measurement).
Getting that right made up for a substantial amount of work during development of my EMS, too.