Shelly plus i4

I have an Shelly plus i4 module I would like to introduce to Openhab3.
As the binding does not yet support the i4-module, I would like to get it read by MQTT.
Could somebody tell me how to configure the thing channel in order to read the input states.

The MQTT Explorer shows as topic :
shellyplusi4-083af200f114/events/rpc

and as event value:
{
“src”:“shellyplusi4-083af200f114”,
“dst”:“shellyplusi4-083af200f114/events”,
“method”:“NotifyStatus”,
“params”: {
“ts”:1644437498.95,
“input:3”: {
“id”:3,
“state”:false
}
}
}

Please note that I am not familiar with JSON at all.

Thanks a lot for information.

Ernest

Hast du einen Taster oder einen Schalter?
Für Taster wählst du bitte “Button” in der Shelly I4 Konfiguration.
Dann werden dir auch bei events die Arten der Bedienung angezeigt:
single_push
double_push
long_push
Das sieht dann z.B. so aus:

{“src”:“shellyplusi4-123456789”,“dst”:“shellyplusi4-123456789/events”,“method”:“NotifyEvent”,“params”:{“ts”:1645117510.31,“events”:[{“component”:“input:0”, “id”:0, “event”:“single_push”, “ts”:1645117510.31}]}}

shellyplusi4-123456789 ist bei dir shellyplusi4-083af200f114

Du brauchst einen MQTT Broker für Openhab, auf Openhabian kannst du z.B. Mosquitto im Konfig Menü installieren.
Danach

  • MQTT Binding installieren.
  • JSON Addon installieren.
  • Thing MQTT Broker hinzufügen
  • Thing ShellyPlusI4 hinzufügen (Generic MQTT Thing)
  • Channel hinzufügen mit MQTT State Topic: shellyplusi4-123456789/events/rpc
  • verlinken mit neuem Item Typ String
  • Beim ITEM JSONPATH anhaken und unter JSONPath Expression;
    $.params.events[:1].event

Jetzt hast du ein ITEM, welches du bei RULES verwenden kannst.
Viel Erfolg!

1 Like

English please, this is an international community!!!

Hi Pascal
Thank you for your instructions.
The last point was the one I missed.
Now it works fine .
Ernest

Thank you @Ernest and @BigPe for this post.
I have added several Shelly devices into OH3 with the Shelly-binding which was very easy. I experienced the same challenge as you, when I tried to implement a Shelly Plus i4. As the Shelly i4 is currently only supported with MQTT, I tried to follow your instructions (install MQTT Broker via Openhabian config, …). Up to now I didn’t use MQTT and have no knowledge on JSONpath.

When I push a button on the Shelly i4 I get the following result in the OH Log:

2022-03-18 18:41:39.971 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625300.54,“events”:[{“component”:“input:0”, “id”:0, “event”:“btn_down”, “ts”:1647625300.54}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625300.54,“events”:[{“component”:“input:0”, “id”:0, “event”:“btn_down”, “ts”:1647625300.54}]}}

2022-03-18 18:41:40.492 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625301.05,“events”:[{“component”:“input:0”, “id”:0, “event”:“btn_up”, “ts”:1647625301.05}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625301.05,“events”:[{“component”:“input:0”, “id”:0, “event”:“btn_up”, “ts”:1647625301.05}]}}

2022-03-18 18:41:40.497 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625301.05,“events”:[{“component”:“input:0”, “id”:0, “event”:“single_push”, “ts”:1647625301.05}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625301.05,“events”:[{“component”:“input:0”, “id”:0, “event”:“single_push”, “ts”:1647625301.05}]}}

2022-03-18 18:41:45.430 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625306.00,“events”:[{“component”:“input:0”, “id”:0, “event”:“btn_down”, “ts”:1647625306.00}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625306.00,“events”:[{“component”:“input:0”, “id”:0, “event”:“btn_down”, “ts”:1647625306.00}]}}

2022-03-18 18:41:45.657 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625306.23,“events”:[{“component”:“input:0”, “id”:0, “event”:“btn_up”, “ts”:1647625306.23}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625306.23,“events”:[{“component”:“input:0”, “id”:0, “event”:“btn_up”, “ts”:1647625306.23}]}}

2022-03-18 18:41:45.926 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625306.50,“events”:[{“component”:“input:0”, “id”:0, “event”:“single_push”, “ts”:1647625306.50}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625306.50,“events”:[{“component”:“input:0”, “id”:0, “event”:“single_push”, “ts”:1647625306.50}]}}

2022-03-18 18:42:04.364 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625324.94,“events”:[{“component”:“input:1”, “id”:1, “event”:“btn_down”, “ts”:1647625324.94}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625324.94,“events”:[{“component”:“input:1”, “id”:1, “event”:“btn_down”, “ts”:1647625324.94}]}}

2022-03-18 18:42:04.945 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625325.51,“events”:[{“component”:“input:1”, “id”:1, “event”:“btn_up”, “ts”:1647625325.51}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625325.51,“events”:[{“component”:“input:1”, “id”:1, “event”:“btn_up”, “ts”:1647625325.51}]}}

2022-03-18 18:42:04.949 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625325.51,“events”:[{“component”:“input:1”, “id”:1, “event”:“single_push”, “ts”:1647625325.51}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625325.51,“events”:[{“component”:“input:1”, “id”:1, “event”:“single_push”, “ts”:1647625325.51}]}}

2022-03-18 18:42:09.554 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625330.13,“events”:[{“component”:“input:1”, “id”:1, “event”:“btn_down”, “ts”:1647625330.13}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625330.13,“events”:[{“component”:“input:1”, “id”:1, “event”:“btn_down”, “ts”:1647625330.13}]}}

2022-03-18 18:42:09.765 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625330.34,“events”:[{“component”:“input:1”, “id”:1, “event”:“btn_up”, “ts”:1647625330.34}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625330.34,“events”:[{“component”:“input:1”, “id”:1, “event”:“btn_up”, “ts”:1647625330.34}]}}

2022-03-18 18:42:10.053 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625330.63,“events”:[{“component”:“input:1”, “id”:1, “event”:“single_push”, “ts”:1647625330.63}]}}’ not supported by type ‘OpenCloseValue’: No enum constant org.openhab.core.library.types.OpenClosedType.{“src”:“shellyplusi4-083af2014970”,“dst”:“shellyplusi4-083af2014970/events”,“method”:“NotifyEvent”,“params”:{“ts”:1647625330.63,“events”:[{“component”:“input:1”, “id”:1, “event”:“single_push”, “ts”:1647625330.63}]}}

My Channel definition for the buttons 0 and 1:

Item definition for button1:

I assume I did something wrong or didn’t fully understand your instructions. Could you give me a hint what I need to change? Do I need one channel and 4 items (one item for every button) or 4 channels and 4 items?

That looks not wrong… What is the result on the item?

When I push a button I get a result similar to

Do you get something like that?

I only use one button for one light, I want to control. But I guess you don’t need more even with four buttons. The button ID is transmitted via MQTT as well. You can separate this info as well (in an additional item).

When you see a correct result, then next try to add an item to get the ID of your button.

You will have one channel and 2 items. One item for the push type and one for the ID.

Thank you Pascal @BigPe for your quick reply. The result of my items was NULL. So I deleted the items and channel an created the channel again as type “String” and not as type “Contact” as I did before. According your recommendation I linked two items to the channel - one for the id (pushed contact 0 … 3) and one for the event (“single_push”, “double_push”, “long_push”).

Now I’m able to use these items in a rule
… but I still do not fully understand the JSON transformations
“$.params.events[:1].event” and “$.params.events[:1].id” … the part “[:1]” of the transformation stands for ???