Help with a simple label on Habpanel to show once a week

Hi.
In my city there is a car rotation and you cannot go out with the car one day a week and at a specific time.
I installed a tablet on the wall next to where we kept the keys with a HABpanel panel.
I would like to have an alert message or image displayed on this panel only on the day and at the specified time.
What is the simplest way to do this?
I don’t have much knowledge of programming.
Tks

Create string item
Create two cron rules, the first is temporarily allowed, the second is not allowed. In the rules, set the item value to the desired text. Show this item in the habpanel.

I’m trying to use Visual Studio to do that but I don’t know how.
I’ve made this:
rule “”
when
<0 50 8 ? * TUE *> [or <TRIGGER_CONDITION2> [or …]]
then

end

Can you show an example, please?

file_name.items
String MyStrItem "Message string [%s]" (gRestore)
file_name.rules

rule "cron1"
when 
    Time cron "0 0 5 * * ? *"
then
    MyStrItem.postUpdate("String1")
end
rule "cron2"
when 
    Time cron "0 0 15 * * ? *"
then
    MyStrItem.postUpdate("String2")
end

Every rule must have a unique name
Rule “myCronRule”

Rule cron triggers look nothing like that.
There are many hundred examples in this forum or you might even try the docs

It’s working nice

Thank you very much

Do you think it’s possible to use images instead of words using the same process?

Everything was fine. Then I tried to use an image instead of a text to warn abou the car restrictions.
After I use this command
import java.io.ByteArrayOutputStream
import java.net.URL
in a .rules file the text item is sending only NULL.
These are the files that was working before:

rod.itmes

String MyStrItem “Message string [%s]” (gRestore)

rod.rules

rule “cron1”
when
Time cron “0 0 7 ? * WED *”
then
MyStrItem.postUpdate(“RODÍZIO”)
end
rule “cron2”
when
Time cron “0 0 10 ? * WED *”
then
MyStrItem.postUpdate(“LIBERADO”)
end
rule “cron3”
when
Time cron “0 0 17 ? * WED *”
then
MyStrItem.postUpdate(“RODÍZIO”)
end
rule “cron4”
when
Time cron “0 0 20 ? * WED *”
then
MyStrItem.postUpdate(“LIBERADO”)
end

Is there a way to retrieve the previous condition?
tks

Sorry, my English is very bad, I don’t think I understand your problem.
First, use code fences, “</>” button, to make your code example readable

image

You have several rules with one content, but different trigger, combine them:

rule "cron1"
when
	Time cron "0 0 7 ? * WED *" or
	Time cron "0 0 17 ? * WED *"
then
	MyStrItem.postUpdate("RODÍZIO")
end

And if I understood you correctly, you want to have an icon instead of text, but you use HabPanel to display, in that case, do it in the HabPanel.
I’m not a hub panel specialist, you will have to search the forum yourself for how to do this.
Here’s an example for a starting point, add a standard widget template and paste the following code into it:

<span ng-style="{ 'font-size': '32pt' }" class="value ng-binding">{{ itemValue('MyStrItem') }}</span>
<div ng-if="itemValue('MyStrItem')=='Rodizio'">
  <widget-icon size="'128'" iconset="'eclipse-smarthome-classic'" icon="'light'" state="'on'" class="ng-scope ng-isolate-scope"></widget-icon>
</div>
<div ng-if="itemValue('MyStrItem')=='LIBERADO'">
  <widget-icon size="'128'" iconset="'eclipse-smarthome-classic'" icon="'light'" state="'off'" class="ng-scope ng-isolate-scope"></widget-icon>
</div>

Here’s another option:

I’m sorry about that. <>
Thanks for your response.
My english is a working process. Maybe you speak Portuguese :grin:
I was being a stupid. The word was not showing because of the cron time I configured. As soon as the time comes the word shows up. That’s working fine.
I’m in the process to use image instead of just words
Thank you for your help

This works fine too.
Can you show how to use an image instead of the word RODIZIO?
I have the guarda.png image inside the html folder.
I’ve created an item on Paper UI called RodizioIMG with Image type and this .rules
<
rule “RodizioIMG”
when
Time cron “0 0/1 * 1/1 * ? *”
then
RodizioIMG.postUpdate.Image url=“http://192.168.2.112:8080/guarda.png
end

but my log says this
Error during the execution of rule ‘RodizioIMG’: An error occurred during the script execution: index=1, size=1

The cron time is this way just to test every minute if it is working, I’ll change for “0 0 7 ? * WED *” and “0 0 17 ? * WED *” later

tks

In the example that I wrote to you above, the image changes when the word (your two words) changes, look carefully at the code, you will understand, but the image is taken from standard icons, for example I made a light bulb. And according to the link I gave you, it is written how to substitute your image instead of an icon.

you don’t need to do this, just put 2 images in the “html” folder

see here for an example
you get something like this:

<span ng-style="{ 'font-size': '32pt' }" class="value ng-binding">{{ itemValue('MyStrItem') }}</span>
<div ng-if="itemValue('MyStrItem')=='Rodizio'">
  <img src="/static/rodizio.jpg"/>
</div>
<div ng-if="itemValue('MyStrItem')=='LIBERADO'">
  <img src="/static/liberado.jpg"/>
</div>
1 Like

Thank you very much.
That’s perfect.
I’m making the same thing to show the days the garbage truck comes. How can I show an image on those days but don’t show anything during the other days? Everything I try returns NULL.

I did this to show nothing after the garbage truck hours:

on rules:

    rule "cron1"
    when 
        Time cron "0 0 18 ? * TUE,THU,SAT *"  
    then
        LixoItem.postUpdate("LIXO")
    end
    rule "cron2"
    when 
        Time cron "0 0 21 ? * TUE,THU,SAT *"
    then
        LixoItem.postUpdate("")
    end

on the widget I erased the second part:

<span ng-style="{ 'font-size': '25pt' }" class="value ng-binding">{{ itemValue('LixoItem') }}</span>
<div ng-if="itemValue('LixoItem')=='LIXO'">
<img src="/static/lixo.png"/>
</div>

but I think this is not the right way, although it’s working.
Is that right?

I’m not an expert in the habpanel, I just did it for you by searching and examples. I think if now everything is working as you wanted, then don’t touch it anymore :slight_smile:

You’re right.
tanks for your help.