Creation of self defined item (Switch/Dimmer)

Hello everyone,
I’ve started to set up a smart home a few weeks ago. I am using Openhabian 3.0.1 on a raspberry pi 3. To control my lights i use switches that are linked to the mqtt binding. They send a message to my Arduino and the Arduino then turn on the light via relay.

Now my question: Is it at all possible to define your own item for openhab?

I would like to program a switch with additional commands, as a switch typ item only sends the command “ON” or “OFF” to the MQTT Broker.

For example, I would like to install a switch that can send the commands “ON”, “OFF”, “X” and “Y”.

Hope this is comprehensible, as this is my first forum post.

Best regards,

Welcome to the openHAB forum :wave:

Read Here for the different item types. The table lists a dimmer with possible commands OnOff, IncreaseDecrease, Percent, that would fit your requirements.

Moin Jürgen,

Thanks for your quick response. Would it be at all possible to modify the Dimmer to send additional commands via MQTT?

Is it possible to add a button that sends a self defined command and is shown in the UI?

Thank you!

No. But you can apply a transformation to any standard command a Dimmer type Item can handle (ON, OFF, INCREASE, DECREASE,any number 0-100) before passing to MQTT payload.
But if this is not about something varying 0-100%, a Dimmer type is not really the best choice.

That’s probably a String type Item.
Ideal for choices like “Apple”, “Banana”, “Orange” or perhaps more likely “On”, “Off”, “Flash”, “Timed”

1 Like