Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. esphome Zähler über mqtt lesen und schreiben

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    esphome Zähler über mqtt lesen und schreiben

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

      Hallo zusammen,
      ich habe folgendes vor: ich möchte einen Zähler für Impulse.
      Dieser Zähler soll über mqtt die Gesamtzahl an iobroker liefern.
      Um einen aktuellen Stand überschreiben zu können, will ich von iobroker kommend einen Wert schreiben können.
      Aber ich bekomme es nicht hin. Im Code unten habe ich die Stellen kommentiert, die Probleme verursachen.
      Ich hoffe ihr steinigt mich nicht, ich bin darin echt schelcht...

      Der aktuelle Code sieht wie folgt aus:

      esphome:
        name: pellet-esp
        platform: esp8266
        board: nodemcuv2
        esp8266_restore_from_flash: True
      preferences:
        flash_write_interval: 5min
      
      # Enable logging
      logger:
      
      ota:
        password: "a9d021e0afcda4e05798857b49ef3b78"
      
      wifi:
        ssid: !secret wifi_ssid
        password: !secret wifi_password
      
        # Enable fallback hotspot (captive portal) in case wifi connection fails
        ap:
          ssid: "Pellet-Esp Fallback Hotspot"
          password: "sv8DdgYL3hZX"
      
      captive_portal:
      
      mqtt:
        broker: 192.168.178.28
        username: mqttuser
        password: !secret api_password
        id: mqtt_client
        birth_message:
          topic: mqtt/0/esphome_sensor/status
          payload: online
        will_message:
          topic: mqtt/0/esphome_sensor/status
          payload: offline
        on_message:
          topic: esphome_sensor/total_pulse_recovery
          qos: 0
          then:
            - lambda: id(total_pulses) = id(total_pulse_recovery); #hier ist ein Problem! total_pulses benötigt int, aber ich bekomme total_pulse_recovery als string
      
      
      status_led:
        pin: GPIO2
      
      globals:
        - id: total_pulses
          type: int
          restore_value: true
          #initial_value: '0'  # hier kann der Zaehlerstand initialisiert werden
      
          
      binary_sensor:
        - platform: gpio
          id: internal_pulse_counter
          pin: D5
          name: "Live-Impuls"
          filters:
            - delayed_on: 100ms
          on_press:
            then:
              - lambda: id(total_pulses) += 1;
      
      
      sensor:
        - platform: template
          name: "Umdrehungen gesamt"
          unit_of_measurement: "U"
          state_class: "total_increasing"
          accuracy_decimals: 0
          lambda: |-
            return id(total_pulses);
          on_value:
            - lambda: id(mqtt_client).publish("mqtt/0/esphome_sensor/mqtt_total_pulses", id(total_pulses));
        
        - platform: mqtt_subscribe
          id: total_pulse_recovery
          topic: esphome_sensor/total_pulse_recovery #/mqtt/0/ wird nicht benötigt: warum?
          accuracy_decimals: 0
      
      
      B 1 Reply Last reply Reply Quote 0
      • B
        bastl90 @bastl90 last edited by

        @bastl90
        kann geschlossen werden. Ich habe mich an espeasy probiert und hab es damit zum Laufen bekommen.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate
        FAQ Cloud / IOT
        HowTo: Node.js-Update
        HowTo: Backup/Restore
        Downloads
        BLOG

        451
        Online

        31.6k
        Users

        79.6k
        Topics

        1.3m
        Posts

        1
        2
        352
        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