Open roller shutter with time delay

Hello all,

I have set it up with Astro Binding so that my shutter opens at sunrise.

However, some days I don’t want my blinds to open at sunrise. I would like it to open at a custom time on those days. I would like to set the time from my phone (Base UI). For this I’m currently thinking of a slider or just a text field.

I know that I can set the time by means of “Cronjob”. But this is not useful, because a manual adjustment of the time is not possible via the mobile.

The question is how to get it implemented? I don’t really have an idea as I am new to the rules of openHAB.

Is it possible to set the cronjob with a variable like this?

rule "Test"
when
    Time cron "minute hour * * *"
then
    // do something
end

BasicUI and sitemaps have no support for a text field.

New in OH 3.3 is the Time is <item> trigger (see Rules | openHAB). This will trigger the rule based on the state of a DateTime Item.

However you are somewhat stuck if you are using BasicUI because there is no way to enter a DateTime. The best you can do is to define a separate Hours, Minutes, and Seconds Item with a slider. Changes to these Items trigger a rule where you’ll have to use the new values to build that DateTime Item’s state.

Search the forum for one of the many “alarm clock” examples to show how to do this.

If you use MainUI, all you need is to install DateTime Standalone Widget and DateTime List Item (or configure these yourself, there isn’t anything special or really all that custom about either of these) for DateTime entry on your MainUI widgets.

No.

I created a widget that allows me to edit 2 opening / close times for 2 items (in my case two opening / close times for rollershutters) that can be configured.

Here is the code of the widget:

uid: rollladen_zeit
tags: []
props:
  parameters:
    - description: Titelzeile
      label: Titelzeile
      name: headline
      required: false
      type: TEXT
    - description: Name Rollladen 1
      label: Name Rollladen 1
      name: rs1_name
      required: false
      type: TEXT
    - context: item
      description: An item to control
      label: Schließzeit Rollladen 1
      name: rs1_closetime
      required: false
      type: TEXT
    - context: item
      description: An item to control
      label: Öffnungszeit Rollladen 1
      name: rs1_opentime
      required: false
      type: TEXT
    - description: Name Rollladen 2
      label: Name Rollladen 2
      name: rs2_name
      required: false
      type: TEXT
    - context: item
      description: An item to control
      label: Schließzeit Rollladen 2
      name: rs2_closetime
      required: false
      type: TEXT
    - context: item
      description: An item to control
      label: Öffnungszeit Rollladen 2
      name: rs2_opentime
      required: false
      type: TEXT
  parameterGroups: []
timestamp: Mar 28, 2021, 7:32:32 PM
component: f7-card
config:
  title: =props.headline
slots:
  default:
    - component: f7-card-content
      config:
        width: 100%
      slots:
        default:
          - component: f7-row
            config:
              visible: =(props.rs1_closetime!=null)
            slots:
              default:
                - component: Label
                  config:
                    text: =props.rs1_name
                    style: center
          - component: f7-row
            config:
              visible: =(props.rs1_closetime!=null || props.rs1_opentime!=null)
            slots:
              default:
                - component: f7-col
                  slots:
                    default:
                      - component: oh-input-card
                        config:
                          visible: =(props.rs1_closetime!=null)
                          sendButton: true
                          outline: true
                          inputmode: text
                          placeholder: hh:mm:ss
                          title: Close Time
                          type: time
                          validate: true
                          item: =props.rs1_closetime
                - component: f7-col
                  slots:
                    default:
                      - component: oh-input-card
                        config:
                          visible: =(props.rs1_opentime!=null)
                          sendButton: true
                          outline: true
                          inputmode: text
                          placeholder: hh:mm:ss
                          title: Open Time
                          type: time
                          validate: true
                          item: =props.rs1_opentime
    - component: f7-card-content
      config:
        width: 100%
      slots:
        default:
          - component: f7-row
            config:
              visible: =(props.rs2_closetime!=null || props.rs2_opentime!=null)
            slots:
              default:
                - component: Label
                  config:
                    text: =props.rs2_name
                    style: center
          - component: f7-row
            config:
              visible: =(props.rs2_closetime!=null || props.rs2_opentime!=null)
            slots:
              default:
                - component: f7-col
                  slots:
                    default:
                      - component: oh-input-card
                        config:
                          visible: =(props.rs1_closetime!=null)
                          sendButton: true
                          outline: true
                          inputmode: text
                          placeholder: hh:mm:ss
                          title: Close Time
                          type: time
                          validate: true
                          item: =props.rs2_closetime
                - component: f7-col
                  slots:
                    default:
                      - component: oh-input-card
                        config:
                          visible: =(props.rs2_opentime!=null)
                          sendButton: true
                          outline: true
                          inputmode: text
                          placeholder: hh:mm:ss
                          title: Open Time
                          type: time
                          validate: true
                          item: =props.rs2_opentime

which then is used in a page like so:

config:
  label: Rollladen Planung
  sidebar: true
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-row
          config: {}
          slots:
            default:
              - component: oh-grid-col
                config: {}
                slots:
                  default:
                    - component: widget:rollladen_zeit
                      config:
                        rs1_closetime: Zeit_Rollladen_GZ_Schliessen
                        headline: Rollläden GZ
                        rs1_name: Seite
                        rs2_name: Arbeitszimmer
                        rs2_closetime: Zeit_Rollladen_AZ_Schliessen
                        rs2_opentime: Zeit_Rollladen_AZ_Oeffnen
masonry:
  - component: oh-masonry
    slots: {}
grid: null
canvas: null

which results into

You should then be able to use these times with these mentioned new trigger types (thanks Rich, I didn’t know about them myself).

Does that help?

Hello, thanks for the quick reply and help.

I have tried something the last few days. I am currently at the following state:

I have an item in which the date & time of the next sunrise should be written. This allows me to control the shutters with “Time is xxx”. The only problem I have is that the Astro Binding doesn’t really seem to work.

First I wanted to look when the night is over.

DateTime  Night_End  "Night [%1$tH:%1$tM]"  { channel="astro:sun:home:night#end" }

Thus I do not get a value. Therefore, I just wanted to look when the sun rises today and add 24 hours.

astro:sun:homePlus1440 [ geolocation="XXX, XXX,100", interval=60 ] {
    Channels:
        Type rangeEvent : set#event [
      offset=1440
    ]
    Type start : set#start [
      offset=1440
    ]
    Type end : set#end [
      offset=1440
    ]
}

DateTime         Sunrise_Tomorrow     "Night [%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS]"                     { channel="astro:sun:homePlus1440:rise#start"}

But this shows me strangely only the time for sunrise today. I copied the code from the delay by 1 hour, which also works.

Do you have any ideas and can you help me?

Hello,
i have now found a solution to open the shutters at sunrise or at a certain time after. The only problem is that the varriable, which should show the time of the next opening, shows the date +2h. But this will be a problem with daylight saving time in Germany and surely easy to fix. But is not a priority for me right now.

Thanks again for the initial help)

Items:

Number V_Kind_Rollade_Minuten
Number V_Kind_Rollade_Stunden
DateTime V_Kind_Rollade_Oeffnen

Sitemap:

Setpoint item=V_Kind_Rollade_Stunden label="Setpoint Stunde [%d]" icon="time" minValue=0 maxValue=23 step=1
Slider item=V_Kind_Rollade_Stunden label="Slider Stunde [%d]" icon="time" minValue=0 maxValue=23 step=1

Setpoint item=V_Kind_Rollade_Minuten label="Setpoint Minute [%d]" icon="time" minValue=0 maxValue=59 step=1
Slider item=V_Kind_Rollade_Minuten label="Slider Minute [%d]" icon="time" minValue=0 maxValue=59 step=1

Text item=V_Kind_Rollade_Oeffnen label="Rollade_Öffnen (+2h)[%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS]"

Rules:

rule "Rollade_Kinderzimmer_hoch"
when
    Time is V_Kind_Rollade_Oeffnen
then
    if (V_Roll_kind_automatik.state == ON) {
        sendCommand(A_Roll_kind, UP)
    }
end

rule "Rollade_Kinderzimmer_runter"
when
    Channel 'astro:sun:homePlus60:set#event' triggered START
then
    if (V_Roll_kind_automatik.state == ON) {
        sendCommand(A_Roll_kind, DOWN)
    }
end

rule "Setze_Zeit_Zum_Rollade_oeffnen"
when
    Time cron "0 0 12 * * *"
then
    var Integer sekundenBisMorgen = 86400

    var DateTimeType sonnenaufgangHeute = (Sunrise_Time.state as DateTimeType)
    var DateTimeType sonnenaufgangMorgen = new DateTimeType(sonnenaufgangHeute.getZonedDateTime().plusSeconds(sekundenBisMorgen))

    var Number sonnenaufgangStunde = Integer::parseInt(sonnenaufgangMorgen.toString.substring(11,13))
    var Number sonnenaufgangMinute = Integer::parseInt(sonnenaufgangMorgen.toString.substring(14,16))

    V_Kind_Rollade_Stunden.sendCommand(sonnenaufgangStunde)
    V_Kind_Rollade_Minuten.sendCommand(sonnenaufgangMinute)

    V_Kind_Rollade_Oeffnen.sendCommand(sonnenaufgangMorgen)
end

rule "Aendere_Datum_zum_oeffnen_der_Rollade"
when
    Item V_Kind_Rollade_Minuten changed or
    Item V_Kind_Rollade_Stunden changed
then
    var String stundeAlsString
    var String minuteAlsString

    var Number sonnenaufgangStunde = (V_Kind_Rollade_Stunden.state as DecimalType).intValue
    var Number sonnenaufgangMinute = (V_Kind_Rollade_Minuten.state as DecimalType).intValue

    if (sonnenaufgangStunde < 10) {
        stundeAlsString = "0" + sonnenaufgangStunde
    } else {
        stundeAlsString = "" + sonnenaufgangStunde
    }

    if (sonnenaufgangMinute < 10) {
        minuteAlsString = "0" + sonnenaufgangMinute
    } else {
        minuteAlsString = "" + sonnenaufgangMinute
    }

    val String dateString = V_Kind_Rollade_Oeffnen.state.toString.substring(0,11)

    val String fertigesDatumString = dateString + stundeAlsString + ":" + minuteAlsString + ":00.000Z"

    val DateTimeType neuesDatum = DateTimeType.valueOf(fertigesDatumString)

    V_Kind_Rollade_Oeffnen.sendCommand(neuesDatum)
end