Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Off Topic
    4. Microcontroller
    5. ESPHome Syntax: Zwei Zustände vergleichen

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    ESPHome Syntax: Zwei Zustände vergleichen

    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      WolfgangFB last edited by

      Ich möchte bei einem binary_sensor eine Aktion ausführen wenn sich der Zustand echt geändert hat unr nicht nur aktualisiert worden ist: Wie lautet die richtige Syntax?

      So geht es jedenfalls nicht 😞

      
      globals:
        - id: WolfgangLast
          type: boolean
          initial_value: 'false' 
      
      binary_sensor:  
        - platform: ble_presence
          mac_address: 7C:2F:80:C4:5D:DA
          name: "Wolfgang Person.Wolfgang.Zustand"
          id: WolfgangNow
          on_press:
            then:
              - if:
                  condition: 
                    lambda: return (id(WolfgangLast).state != id(WolfgangNow).state);
                  then:
                    - text_sensor.template.publish:
                        id: WolfgangId
                        state: !lambda return "Wolfgang da " + id(MySntp).now().strftime("%d.%m %H:%M:%S");
                    - lambda: id(WolfgangLast) = true;
        
      

      Fehlermeldung:

      Compiling .pioenvs/esp32-ble/src/main.cpp.o
      /opt/iobroker/iobroker-data/esphome.0/esp32-ble.yaml: In lambda function:
      /opt/iobroker/iobroker-data/esphome.0/esp32-ble.yaml:123:37: error: request for member 'state' in 'WolfgangLast->esphome::globals::GlobalsComponent<bool>::value()', which is of non-class type 'bool'
                     lambda: return (id(WolfgangLast).state != id(WolfgangNow).state);
                                           ^~~~~
      
      liv-in-sky 1 Reply Last reply Reply Quote 0
      • liv-in-sky
        liv-in-sky @WolfgangFB last edited by

        @wolfgangfb sagte in ESPHome Syntax: Zwei Zustände vergleichen:

        which is of non-class type 'bool

        bin darin alles andere wie profi - aber sieh mal hier: https://community.home-assistant.io/t/esphome-global-as-boolean-in-lambda-not-compiling/182813

        der vergleich wird anders geschrieben wie bei dir - stichwort "quotes"

        W 1 Reply Last reply Reply Quote 0
        • W
          WolfgangFB @liv-in-sky last edited by

          @liv-in-sky

          Danke, es waren die Anführungszeichen.
          Korrekt lautet die Abrage:

              on_press:
                then:
                  - if:
                      condition: 
                        lambda: "return (id(WolfgangLast) != id(WolfgangNow).state);"
                      then:
          ...
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Support us

          ioBroker
          Community Adapters
          Donate

          977
          Online

          31.7k
          Users

          79.7k
          Topics

          1.3m
          Posts

          2
          3
          394
          Loading More Posts
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes
          Reply
          • Reply as topic
          Log in to reply
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
          The ioBroker Community 2014-2023
          logo