Need help for my first Sonoff Power Switch

openhab2
mqtt
items
Tags: #<Tag:0x00007f1e662ac5e8> #<Tag:0x00007f1e662ac1d8> #<Tag:0x00007f1e662bba48>
(Manfred Bartholomy) #1

Hello together,
since one week I installed openhabian on my raspberry 3B+. last year I used fhem for my homeautomation, but I thought this is too cryptic for me. Openhab seemed to me more modern and flexibel.

But since two day i try to integrate my Sonoff Power Switch.
Using the paperUI I was able to integrate the switching-action. I can see, when the switch will be switched on or off and I’m able to switch from openhab the Powerswitch.

I#m not able to display in a sitemap my energy-values.
In the forum I found a lot of information how to configure the items file and the sitemap. (both as default at this time)

In the openhab.log I get everytime the message:
019-04-05 16:56:16.899 [WARN ] [eneric.internal.generic.ChannelState] - Incoming payload ‘{“Time”:“2019.04.05 15:56:17”,“ENERGY”:{“Total”:251.986,“Yesterday”:0.552,“Today”:0.477,“Period”:0,“Power”:54,“Factor”:0.91,“Voltage”:225,“Current”:0.266}}’ not supported by type ‘NumberValue’

In the itemfile I configured the switch as follows_
Number Teichpumpe_V “Spannung [%.1f V]”
{ mqtt=" <[MQTTBroker-local:tele/Sonoff_Pow/SENSOR:state:JSONPATH($.Voltage)]" }
// Power in W
Number Teichpumpe_P “Leistung [%.1f W]”
{ mqtt="<[MQTTBroker-local:tele/Sonoff_Pow/SENSOR:state:JSONPATH($.Power)]" }
// Current in A
Number Teichpume_I “Strom [%.1f A]”
{ mqtt="<[MQTTBroker-local:tele/Sonoff_Pow/SENSOR:state:JSONPATH($.Current)]" }
// Energy for today in Wh
Number Teichpumpe_E “Energie heute [%.1f kWh]”
{ mqtt="<[MQTTBroker-local:tele/Sonoff_Pow/SENSOR:state:JSONPATH($.Today)]" }
// Energy since last reset to 0 in Wh
Number Teichpumpe_Et “Energie insgesamt [%.1f kWh]”
{ mqtt="<[MQTTBroker-local:tele/Sonoff_Pow/SENSOR:state:JSONPATH($.Today)]" }

In the console of the switch the messages looks like these:

15:59:47 MQT: tele/Sonoff_Pow/STATE = {“Time”:“2019.04.05 15:59:47”,“Uptime”:“3 03:14:42”,“Vcc”:3.516,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“Leopard”,“RSSI”:42,“APMac”:“34:31:C4:BC:FE:1B”}}
15:59:47 MQT: tele/Sonoff_Pow/SENSOR = {“Time”:“2019.04.05 15:59:47”,“ENERGY”:{“Total”:251.990,“Yesterday”:0.552,“Today”:0.480,“Period”:0,“Power”:54,“Factor”:0.78,“Voltage”:226,“Current”:0.305}}

I know, the fault is ervery time in front of the computer, but I really tried a lot and at this time I’m on the end off my ideas.

Perhaps someone is willing to give me a little bit start-up support.

Thanks in advance
manylomy

0 Likes

(Elias H.) #2

I will start with some quotes…


also

We need more Information!

  • Which Firmware do you use for your Sonoff?
  • Which openHAB Version?

Better read the “How to ask good questions” it really helps us helping you!

If you could provide a path what you did, which tutorial or topic you followed we could help even better

0 Likes

(Jürgen Baginski) #3

Looking at the received JSON I think the required JSONPATH transformation would be ...JSONPATH($.ENERGY.Voltage)

0 Likes

(Manfred Bartholomy) #4

@ opus
Thanks, i changed it, but nothing changed.

@BrutalBirdie

I have to read all your questions and will answer them, but it needs some time.
My path was not a straight one, and the last 2 nights I red a lot in the documentation and in the community. All these helped already a lot.

But the following point I’m able to answer:

System Rasperry 3B+
OH2
MQTT Broker from OH2 W(Which is correct working, I also use it on fhem)
I changed from paperUI as I could not find a description, how to configre the transforming and display the incoming data.
Every help in the community pointed to items and sitemap. And i found that OH2 can work in parallel with both of them.

But I understand your remarks. I will try to get more an information about the OH2, the bindings and the best way to install a good working system. But actual I’m a beginner and try to understand the concept (which is for the moment not so easy).
And with my Sonoff (Tasmota 5.12.0) I thought to get a sense of achievement.

Greetings
manylomy

0 Likes

(Elias H.) #5

@manylomy did you make any progress?

0 Likes

(Manfred Bartholomy) #6

Thanks for your asking. Yes, I had some Progress and received the energy results in my paper UI.
At least I switched over to the OH2 binding and config.
I got from someone the hint that the JSONPATH need no ( for the values, there has to be a dot instead.
With this correction I got my energy values correct. But actual I do not expand my actions in OH. I think that OH2 is a really innovative system for homeautomation. But it needs too much time for beginners. And until now I did online implement devices and created no rules etc. Seemed also a part with a lot on try in error.
My OH2 Raspi is still configured and a little bit later I think I will restart my tryings.
Thanks again for your help but I think it is the wrong time for me.
Best regards
Manfred

0 Likes

(Rick) #7

You can also have a look at the MQTTv2 docs from Tasmota here:

It’s true that openhab takes a while to get used to. However it’s really nice to build rules once everything is working.

0 Likes

(Jürgen Baginski) #8

That would depend on which mqtt binding you are using. Version 1 or 2, only the later works with things and does not use the (.

0 Likes