MQTT Homeassistant: How to setup homeassistant device for ebusd

I want to create a rule which informs me about the next maintainance.
How can I find out why the script failed?
Isn’t the argument to split() a regex? Doesn’t that mean that ‘.’ means “any character”?

Then changing the way it’s shown on the UIs through the state description is going to do nothing for you.

  1. Use a date time type Channel
  2. As I said above, chain your JSONPATH transformation to the JS transformation. The description in the UI tells you how to do that.
  3. Trigger the rule using the DateTime Item.

Note, the rule will trigger at midnight on that date. If you want it at a different time, you’ll need to add that time in the JS transformation. Create a LocalDateTime instead of just a LocalDate and you’ll need to supply the hour and minute and second. LocalDateTime | js-joda

You’ve added the transformation only to the way the Item is shown on the UI.

The Item has not been updated. It’s state is NULL. It will not receive a state until an MQTT message is received by OH.

When you tried to look at the Item in the UI, it invoked the transformation and that function doesn’t handle NULL. It doesn’t need to handle NULL because if you use it on the Channel it will never see NULL.

I replaced the channel with one of type DateTime and used the incoming value transformation

JSONPATH:$.value.value∩JS(date_dmy.js):%s

Now I get the following error:

2026-01-22 18:54:48.737 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{
“value”: {“value”: “01.05.2018”}}’ from channel ‘mqtt:topic:mosquitto-localhost:Th_Gastherme:Ch_MaintenanceDate’ not supported by type ‘DateTimeValue’: {
“value”: {“value”: “01.05.2018”}} is not in a valid format.

What’s my fault?

No :%s. That’s only used in Item labels and state description patterns. That’s not actually a part of the transformation at all.

I tried

JS(date_dmy.js) ∩ JSONPATH($.value.value)

and it seems that nothing happens. The value of the item is not set and there’s no log entry.
If I change it to

JSONPATH($.value.value) ∩ JS(date_dmy.js)

I get a script error.

Any ideas what’s wrong?

You have to put the JSONPATH first. Everything flows from left to right. The JSONPATH extracts the date and the JS changes the format into something that will work for OH.

And the error is?

Sorry, my post was wrong. Nothing happens when I use

JSONPATH($.value.value) ∩ JS(date_dmy.js)

No log entry in events.log or openhab.log, no item value change.

Is there something wrong with my item or the channel link?

Is it possible to log a channel change?

There should be no spaces around the ∩.

Also, there must be a new message published to the MQTT topic before the Item will be updated and the transformation runs after every change to the Channel. No message, nothing to do and the Item remains NULL.

I force the ebusd to publish the current value using

ebusctl read MaintenanceDate

And I check, if a new topic was posted using MQTT.fx
So a new topic is always posted and should be received by the MQTT binding.
Removing the spaces in the transformation did not change anything.

Logs?

If there is a message posted and the transformation doesn’t work there will be errors in the logs.

You are confirming a new message is being published using MQTT Explorer or some other tool?

Yes. I use the MQTT explorer MQTT.fx. There I subscribe the topic “ebusd/430/MaintenanceDate”. And there I receive every topic ebusd published and I can see its content there.
During the creation of the thing channel I copied the topic from MQTT.fx to avoid misspelling.
Is there a way to ensure that the channel is triggered?

Publish a message to the topic it subscribes to. That’s the only think that will cause the binding to do anything.

Note that MQTT Explorer shows past messages. Double check the timestamp on the message to see when it was sent. That will tell you if ti was sent after saving the changes to the OH Thing.

If the message was not retained and the message was sent before you saved, nothing will happen.

This is what I do in a sequence:

  • change the thing channel or item, save it
  • afterwards trigger the publishing of the topic
  • afterwards wait in the MQTT explorer for the new topic
  • afterwards wait some seconds and check the log entries

This works for every channel except the one which uses “ebusd/430/MaintenanceDate”.
It must either be

  • a transformation problem or
  • a problem with the link between item and channel or
  • a problem in the item definition

This is the channel definition:

and this is the item:

and here is the link:

There will be errors in openhab.log if this is the case. Transformations do not fail with an error silently.

There is pretty much nothing that can go wrong here unless you’ve applied a profile. All the link consists of is the name and the Channel ID. there isn’t something more that can break. But you can search for orphaned links in the karaf console. If there is a problem there, it will show up as orphaned.

The Item wouldn’t show up at all if there is a problem there.

Are you using this term “topic” deliberately or my mistake? The MQTT Thing subscribes to a topic for messages. It’s the messages that the get received and processed, not the topic.

If new topics are indeed being used, this isn’t going to work as configured and it’s going to get much more complicated depending on how these new topics are appearing.

Don’t post screen shots. Click on the code tab and post the text you find there. Use code fences.

```
code goes here
```

Put the MQTT binding into debug or trace level logging. You’ll see everything that the MQTT binding is doing when/if these messages arrive.

How do I do that? I use the MQTT binding very frequently. How do I avoid thousands of log messages?

Maybe disable all the other Things and Channels except this one, put the binding into debug or trace logging, and then run the test. Restore everything when done.

Or just let it log everything and search through the logs related to this one Channel.

Thanks to the good documentation I could set the debug level on the binding.
Now I get the following log:

2026-01-22 23:00:13.011 [DEBUG] [ab.binding.mqtt.generic.ChannelState] - Transformation ‘{
“value”: {“value”: “01.05.2018”}}’ returned null on ‘org.openhab.core.thing.binding.generic.ChannelTransformation@1179d1db’, discarding message

ok, it’s the transformation. but why?

I changed the log level to TRACE but I didn’t get any additional info.

There is something wrong with the transformation to a DateTime.
I changed the Javascript to

(function(i){
console.info(“date_dmy input”, i)
const words = i.split(‘\.’); // Datum im Format dd.mm.yyyy
const result = time.LocalDate.of(parseInt(words[2]), parseInt(words[1]), parseInt(words[0])).toString();
console.info(“date_dmy result”, result)
return result
})(input)

and I get the following logs:

2026-01-22 23:33:45.339 [INFO ] [scripting.transformation.date_dmy.js] - date_dmy input 01.05.2018
2026-01-22 23:33:45.348 [DEBUG] [ab.binding.mqtt.generic.ChannelState] - Transformation ‘{
“value”: {“value”: “01.05.2018”}}’ returned null on ‘org.openhab.core.thing.binding.generic.ChannelTransformation@1179d1db’, discarding message

The first log line is executed but not the second.

With this settings it works:

  1. date_dmy.js:

(function(i){
//console.info(“date_dmy input”, i)
const words = i.split(‘.’); // Datum im Format dd.mm.yyyy
//console.info(“date_dmy words[0]”, words[0])
//console.info(“date_dmy words[1]”, words[1])
//console.info(“date_dmy words[2]”, words[2])
const result = time.LocalDateTime.of(parseInt(words[2]), parseInt(words[1]), parseInt(words[0]), 0, 0).toString();
//console.info(“date_dmy result”, result)
return result
})(input)

  1. pattern in the state description of the item:

%1$td.%1$tm.%1$tY

Result is an Item of Type DateTime, which e. g. is displayed as “01.05.2018”.

@rlkoshak: Thanks a lot for your great support