Widget "Post ist da"

Für welche Projekte verwendet Ihr OpenHAB? Was habt Ihr automatisiert? Stellt eure Projekte hier vor.

Moderatoren: Cyrelian, seppy

Antworten
atk69
Beiträge: 100
Registriert: 15. Jan 2019 19:07
Answers: 1
Wohnort: Weil am Rhein

Widget "Post ist da"

Beitrag von atk69 »

Hallo zusammen,
irgendwie stelle ich mich mal wieder etwas dumm an ;) :
Ich brauche ein Widget, dass mir den Briefkastenstatus anzeigt.
Dazu habe ich einen IR-Sensor (MQTT) im Briefkasten, der das auch wunderbar macht.
Allerdings soll er sich nicht selbst zurückstellen, sonder per Button resettet werden.
Den Code für die Anzeige des Sensors habe ich schon, es fehlt "einfach" nur , dass der Status bis zum reset bleibt.
Bringt ja nix, wenn die Anzeige nur ein paar Sekunden da ist.

Code: Alles auswählen

uid: Post_da
tags: []
props:
  parameters:
    - context: item
      label: IR_Sensor1_IR Item
      name: IR_Sensor1_IR Item
      required: true
      type: TEXT
    - label: Titel
      name: title
      required: false
  parameterGroups: []
timestamp: Mar 21, 2026, 7:20:00 PM
component: f7-card
config:
  stylesheet: |
    @keyframes blinker {
      50% { opacity: 0; }
    } .blink-active {
      animation: blinker 1s linear infinite;
    }
  title: =props.title
slots:
  default:
    - component: oh-icon
      config:
        class: '=(items.IR_Sensor1_IR.state === "true") ? "blink-active" : ""'
        icon: '=(items.IR_Sensor1_IR.state === "false") ?
          "f7:exclamationmark_triangle_fill" : "f7:house"'
        size: 80
        style:
          color: '=(items.IR_Sensor1_IR.state === "true") ? "green" : "red"'
          margin-left: 20px
    - component: Label
      config:
        style:
          font-weight: bold
          margin-left: 20px
        text: '=(items.IR_Sensor1_IR.state === "true") ? "Post da" : "Keine Post"'
Gruss
Andreas
and IT works ;)

Harka
Beiträge: 596
Registriert: 30. Apr 2021 13:13
Answers: 19

Re: Widget "Post ist da"

Beitrag von Harka »

Moin,
Du musst dafür noch eine Aktion mit 'actionCommand: "false" 'einbauen. Hier auf den Icon (Achtung - Item ist variabel gemacht)

Code: Alles auswählen

uid: Post_da
tags: []
props:
  parameters:
    - context: item
      label: item
      name: Sensor_Item
      required: true
      type: TEXT
    - label: Titel
      name: title
      required: false
  parameterGroups: []
timestamp: Mar 21, 2026, 9:03:14 PM
component: f7-card
config:
  stylesheet: |
    @keyframes blinker {
      50% { opacity: 0; }
    } .blink-active {
      animation: blinker 1s linear infinite;
    }
  title: =props.title
slots:
  default:
    - component: oh-icon
      config:
        class: '=(items[props.Sensor_Item].state === "true") ? "blink-active" : ""'
        icon: '=(items[props.Sensor_Item].state === "false") ?
          "f7:exclamationmark_triangle_fill" : "f7:house"'
        size: 80
        style:
          color: '=(items[props.Sensor_Item].state === "true") ? "green" : "red"'
          margin-left: 20px
        actionItem: =(props.Sensor_Item)
        actionCommand: "false"
        action: command
    - component: Label
      config:
        style:
          font-weight: bold
          margin-left: 20px
        text: '=(items[props.Sensor_Item].state === "true") ? "Post da" : "Keine Post"'

atk69
Beiträge: 100
Registriert: 15. Jan 2019 19:07
Answers: 1
Wohnort: Weil am Rhein

Re: Widget "Post ist da"

Beitrag von atk69 »

Vielen Dank Harka.
allerdings funktioniert es nicht.
Code sieht nun so aus:

Code: Alles auswählen

uid: Post_da
tags: []
props:
  parameters:
    - context: item
      label: IR_Sensor1_IR Item
      name: IR_Sensor1_IR Item
      required: true
      type: TEXT
    - label: Titel
      name: title
      required: false
  parameterGroups: []
timestamp: Mar 21, 2026, 9:03:14 PM
component: f7-card
config:
  stylesheet: |
    @keyframes blinker {
      50% { opacity: 0; }
    } .blink-active {
      animation: blinker 1s linear infinite;
    }
  title: =props.title
slots:
  default:
    - component: oh-icon
      config:
        class: '=(items[props.IR_Sensor1_IR_Item].state === "true") ? "blink-active" : ""'
        icon: '=(items[props.IR_Sensor1_IR_Item].state === "false") ?
          "f7:exclamationmark_triangle_fill" : "f7:house"'
        size: 80
        style:
          color: '=(items[props.IR_Sensor1_IR_Item].state === "true") ? "green" : "red"'
          margin-left: 20px
        actionItem: =(props.IR_Sensor1_IR_Item)
        actionCommand: "false"
        action: command
    - component: Label
      config:
        style:
          font-weight: bold
          margin-left: 20px
        text: '=(items[props.IR_Sensor1_IR_Item].state === "true") ? "Post da" : "Keine Post"'
sollte doch so korrekt sein ? :roll:
Hat sich nichts verändert. Er zeigt immer noch nur kurz an.
and IT works ;)

Harka
Beiträge: 596
Registriert: 30. Apr 2021 13:13
Answers: 19

Re: Widget "Post ist da"

Beitrag von Harka »

Hast Du auf der Seite im Edit-Modus für das Feld unter Configure_Cell das Item ausgewählt? Kommt im Log der Befehl false an?

Benutzeravatar
peter-pan
Beiträge: 2849
Registriert: 28. Nov 2018 12:03
Answers: 30
Wohnort: Schwäbisch Gmünd

Re: Widget "Post ist da"

Beitrag von peter-pan »

Mal abgesehen, davon, dass das Icon nicht blinkt, hätte ich eine Variante anzubieten.

Du brauchst ja eine Schalter (Dummy) mit dem du den Postkasten "entleerst".
eine kleine Regel würde dieses Problem beheben.

.rules

Code: Alles auswählen

rule "Test Reed"
  when
    Item snzb03_01_occupancy changed from OFF to ON   // Das ist dein Reed-Kontakt

  then
    Dummy_11.sendCommand(ON)   //Das ist der Dummy-Schalter
 end
Dazu brauchst du noch das Dummy-Item:
.items

Code: Alles auswählen

Switch                      Dummy_11                  "Testschalter Dummy_11 [%s]"                                   (gPower1)              { stateDescription="pattern" [pattern="MAP(de.map):%s"], synonyms="Schalter" }
Den Schalter musst du natürlich auch in ein Widget packen oder du baust ihn in dein Custom-Widget ein.

Dein Widget würde dann etwa so aussehen (ohne Schalter)

Code: Alles auswählen

uid: Post_da
tags: []
props:
  parameters:
    - context: item
      label: item
      name: Sensor_Item
      required: true
      type: TEXT
    - label: Titel
      name: title
      required: false
  parameterGroups: []
timestamp: Mar 22, 2026, 4:05:14 PM
component: f7-card
config:
  stylesheet: |
    @keyframes blinker {
      50% { opacity: 0; }
    } .blink-active {
      animation: blinker 1s linear infinite;
    }
  title: =props.title
slots:
  default:
    - component: oh-icon
      config:
        class: '=(items[props.Sensor_Item].state === "ON") ? "blink-active" : ""'
        icon: '=(items[props.Sensor_Item].state === "OFF") ?
          "f7:exclamationmark_triangle_fill" : "f7:house"'
        size: 80
        style:
          color: '=(items[props.Sensor_Item].state === "ON") ? "green" : "red"'
          margin-left: 20px
        actionItem: =(props.Sensor_Item)
        actionCommand: "false"
        action: command
    - component: Label
      config:
        style:
          font-weight: bold
          margin-left: 20px
        text: '=(items[props.Sensor_Item].state === "ON") ? "Post da" : "Keine Post"'
Als Item müsstest du dann den Dummy eingeben.
Pi5/8GB(PiOS Lite 64-bit(trixie)/SSD 120GB - OH5.1.3 openhabian
(Test openHAB 5.2.0 Build #5140 - snapshot)

Benutzeravatar
peter-pan
Beiträge: 2849
Registriert: 28. Nov 2018 12:03
Answers: 30
Wohnort: Schwäbisch Gmünd

Re: Widget "Post ist da"

Beitrag von peter-pan »

Hier noch "ein Schnellschuss" mit eingebautem Schalter

Code: Alles auswählen

uid: Post_da
tags: []
props:
  parameters:
    - context: item
      label: item
      name: Sensor_Item
      required: true
      type: TEXT
    - label: Titel
      name: title
      required: false
  parameterGroups: []
timestamp: Mar 22, 2026, 4:45:20 PM
component: f7-card
config:
  stylesheet: |
    @keyframes blinker {
      50% { opacity: 0; }
    } .blink-active {
      animation: blinker 1s linear infinite;
    }
  title: =props.title
slots:
  default:
    - component: oh-icon
      config:
        action: command
        actionCommand: "false"
        actionItem: =(props.Sensor_Item)
        class: '=(items[props.Sensor_Item].state === "ON") ? "blink-active" : ""'
        icon: '=(items[props.Sensor_Item].state === "OFF") ?
          "f7:exclamationmark_triangle_fill" : "f7:house"'
        size: 80
        style:
          color: '=(items[props.Sensor_Item].state === "ON") ? "green" : "red"'
          margin-left: 20px
    - component: Label
      config:
        style:
          font-weight: bold
          margin-left: 20px
        text: '=(items[props.Sensor_Item].state === "ON") ? "Post da" : "Keine Post"'
    - component: f7-col
      config: {}
      slots:
        default:
          - component: oh-toggle
            config:
              item: =(props.Sensor_Item)
Pi5/8GB(PiOS Lite 64-bit(trixie)/SSD 120GB - OH5.1.3 openhabian
(Test openHAB 5.2.0 Build #5140 - snapshot)

Antworten