Blockly and Text analysis

I am running OH3.2 stable and am not able to find the root cause for this error message:

act_AlarmTime.indexOf is not a function in <eval> at line number 8

This is triggered by this Blockly rule:

From my understanding the act_AlarmTime is a string containing T from the DateTime Format.
Logging this works fine, but the text operation does not (see error above) - and I am wondering why.

What I am trying here is to read the current AlarmClock time and change it with the new setting (hour and minute).
Hour and Minute are separate Number items and this rule is triggered if one of them changed.
So I want to cut the time from the entire DateTime item and append the new hour:minute to the date.

There is possibly a better approach, but this kind of text operation would be helpful for other cases as well.

From the text blocks try using the append one to force your variable into a string (appending nothing), before using the find-first-occurance block.

Yes, this is the way to go:

What you can also do is use the following block which keeps out the T part by design:

image

2022-02-27 13:15:16

Thank you @hafniumzinc @stefan.hoehn
I will try both of your suggestions :blush:

Thanks guys - got it.
Cutting off the entire time string was not so helpful because I need most of it anyway (.000+01000)

So this works:

However, there is still a potential bug, because this only works if the alarmclock hour is below 10 am.
But after that I won’t need an alarm clock anyway :wink:

EDIT:
Actually this is cleaner:

Can you explain what you intend to do here? This looks pretty complex, so I am wondering if we cannot find an easier way of doing it. :slight_smile:

Of course. The simpler the better! :slight_smile:

This is all about the AlarmClock Time adjustment:
Sometimes I want to change it, so I created 2 Number items (Hours and Minutes).
When one of these change, I run this rule to get the actual AlarmClockTime and modify it with the new time.
In the background I use the AlarmClock from @rlkoshak :slight_smile:
Alarm Clock Rule - Add-on Marketplace / Rule Templates - openHAB Community
Obviouly this did not work with the Rule to move it to the next day (but I am still investigating)
To Today - Add-on Marketplace / Rule Templates - openHAB Community

Why not just keep it as a DateTime Item instead of splitting it into hour and minutes. Then you can use DateTime List Item and DateTime Standalone Widget to modify it in MainUI. Note that’s just a really simple widget that just sets the properties to enable the built in Date Time Picker. You could adjust the properties to just show the time part and use the To Today rule template to move it to the new day.

This is written up in more detail at Creating Capabilities with Rule Templates: Time of Day.

At this point keeping up with separate Items for minutes and hours is just going to make things more complicated than they need to be any more.

Thank you, Rich.
I will look into this option.
Sounds much leaner.
(my hour / min stuff comes from old OH2 times…:wink:

EDIT:
Both widgets do the same, right?
The first one does not look like it’s working on iOS:
There is nothing I can click on.

I cannot install the second one:
image

It displays differently in different browsers: see here.

(I don’t have an iOS device to test with unfortunately…)

Thank you, but on iOS there is no input field at all (or Calendar icon).

There really isn’t anything I can do about how it appears on iOS. But the widget looks like it’s smooshed together. The input part of the widget is above that line. The checkmark icon is what submits the entered value.

Yes but they need to be used in different contexts. The list widget you must only use as an entry in a list card. The standalone widget is a card in its own right and should not be used in a list.

For the installation failed I need the error logs.

Of course - I don’t blame you :wink:

I will check this out at a later stage.
First I need to prepare some other things before we move to the new house :slight_smile:
Thank you for your help, Rich!