Sonoff Tasmota auto restart

Geflasht oder ungeflasht ...

Moderatoren: Cyrelian, udo1toni

Heavy-Dee
Beiträge: 139
Registriert: 18. Jan 2018 16:38
Answers: 0

Re: Sonoff Tasmota auto restart

Beitrag von Heavy-Dee »

Bei allen Tasmota-Geräten ist der GroupTopic auf "Tasmota" eingestellt.

Mit

Code: Alles auswählen

        val actionsBroker = getActions("mqtt","mqtt:broker:59dfa5c9cb")
          for (String device_id : Tasmota) {
          actionsBroker.publishMQTT("cmnd/" + device_id + "/restart", "1")
          }
hat es nicht funktioniert.
Aber

Code: Alles auswählen

        val actionsBroker = getActions("mqtt","mqtt:broker:59dfa5c9cb")
          actionsBroker.publishMQTT("cmnd/Tasmota/restart", "1")
läuft !!!

Danke Udo,
... bist seit Jahren eine riesige Hilfe !!!
openHab2 (v. 2.5.2) Docker auf Synology DS920+
openHab4 (v. 4.1.0) Docker auf Synology DS920+ :!:

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

Re: Sonoff Tasmota auto restart

Beitrag von peter-pan »

Es ist so wie Udo das schon vermutet hat. Du musst die Variable ("sonoff_device_ids" bzw. bei dir "tasmota_devices "), oder besser gesagt das Array vorher (vor der eigentlichen Rule) definieren. Dabei kannst du wie schon von Udo beschrieben einzelne Geräte oder ganze Gerätegruppen definieren.

Hier noch ein Beispiel meiner Regel, die entsprechend abgewandelt werden kann (muss):

Code: Alles auswählen

// Work with a list of selected Tasmota flashed devices
//
val sonoff_device_ids = newArrayList(
//        "schaltdose01",
//        "schaltdose02",
//        "schaltdose04",      
//        "schaltdose06",      
//        "schaltdose07",      
//        "schaltdose08",      
//        "gosundsp111_05",
//        "gosundsp111_02",
//        "gosundsp111_04",
//        "gosundsp111_06",
//        "gosundsp111_07",
//        "gosundsp111_08",
//        "basic_04",
//        "basic_03",
//        "lolin_01",                     // .83
//        "th16_01",                     // Steckdosenleiste .42
//        "pow_02",                      // Stehlicht .41
//        "gosundsp111_01",               // .35 
        "mini_01",                    //.34
//        "mini_03",                    // .59
//        "mini_04",                    // .57
//-----------------------------------------------------------
//        "mini_02",                  // !!! sensor release !!!  .37

//-----------------------------------------------------------
//       "espv3_02",                   // esp32_release .26  
//       "esp32_02",                   // esp32_release .67 
//       "esp32_01",                   // esp32_release .68 
       "dummy"   
)

// OR
// Work with the grouptopic, addressing ALL devices at once.
// val sonoff_device_ids = newArrayList("sonoffs", "tasmotas")
// val sonoff_device_ids = newArrayList("tasmosens")  // Group for Sensor-Firmware
// https://community.openhab.org/t/using-sonoff-power-switches-with-tasmota-firmware-and-openhab2-mqtt2-binding/59969/7  // thx to @opus
rule "Tasmota Maintenance"
  when
   Item Tasmota_Action received command
  then
   val actionsBroker = getActions("mqtt","mqtt:broker:claudi") // change "claudi" to your broker-name!
   for (String device_id : sonoff_device_ids) {
      switch (receivedCommand) {
         case "restart" : {
             actionsBroker.publishMQTT( "cmnd/" + device_id + "/restart", "1")
             logInfo("tasmota_maintenance", "Restart: " + device_id + " / " + receivedCommand + " / " + sonoff_device_ids)
            }
         case "queryFW" : {
             actionsBroker.publishMQTT( "cmnd/" + device_id + "/status", "2")
             logInfo("tasmota_maintenance", "Firmware Abfrage: " + device_id + " / " + receivedCommand + " / " + sonoff_device_ids)
            }
         case "upgrade" : {
//            actionsBroker.publishMQTT( "cmnd/" + device_id +"/otaurl", "http://ota.tasmota.com/tasmota/release/tasmota-DE.bin.gz")  // normal release  --> actual 
//             actionsBroker.publishMQTT( "cmnd/" + device_id +"/otaurl", "http://ota.tasmota.com/tasmota/release/tasmota-sensors.bin.gz")  // sensor release --> actual
             actionsBroker.publishMQTT( "cmnd/" + device_id +"/otaurl", "http://ota.tasmota.com/tasmota32/release/tasmota32-DE.bin")  // ESP32 release
             actionsBroker.publishMQTT( "cmnd/" + device_id + "/upgrade", "1")
             logInfo("tasmota_maintenance", "Update Firmware: " + device_id + " / " + receivedCommand + " / " + sonoff_device_ids)
            }
        }
    }
   createTimer(now.plusSeconds(20), [ |
    Tasmota_Action.postUpdate("OFF")
    logInfo("tasmota_maintenance", "Action-Switch nach 20 Sekunden wieder ausgeschaltet: " )
   ])
   
 end
Diese Regel verwende ich sowohl für "Restart", "Status" als auch für das "Upgrade" der Tasmota-Versionen.
Pi5/8GB(PiOS Lite 64-bit(bookworm)/SSD 120GB - OH4.1.2 openhabian

Antworten