• Categories
  • Recent
  • Tags
  • Popular
  • Register
  • Login
  • Categories
  • Recent
  • Tags
  • Popular
  • Register
  • Login

Battery level in rules or chart? [Script Rule to check battery level]

Scheduled Pinned Locked Moved Scripts
battery levelbatterynodescriptrule
4 Posts 3 Posters 3.7k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    DaTTcz
    last edited by jkandasa 17 Nov 2016, 18:23

    Hello, how can I work with an item Battery level? How do I keep track of battery usage nodes? It's going to add to the rules? It could based on the condition of batteries to generate rules for individual nodes? I Can add another item to the sensor, but why send another same item. thank you for the advice

    I am sorry for my bad English. I speak Czech.

    J 1 Reply Last reply 18 Nov 2016, 03:48 Reply Quote 0
    • J Offline
      jkandasa @DaTTcz
      last edited by jkandasa 18 Nov 2016, 03:48

      @DaTTcz For now direct battery support not available on Rules. However you can do it from script. I will update how to handle with script.

      Kindly create a request on github page to support battery level on rules.

      ALL these features are available on SNAPSHOT build

      Enter your condition via script,

      Steps:

      • Create UID Tag for your node,
      • Create script to check node battery level (script type: Condition)
      • Create rule with this condition script
      • Enjoy 🙂
      Create UID Tag:

      0_1479454456642_upload-6bd6f2c1-24c2-431c-b97e-6ae08892003c

      Add script:

      0_1479454321011_upload-df8f276c-45cd-4c6c-9ef2-1de1c50f4445
      Java Script to check battery level,

      var myImports = new JavaImporter(java.io, java.lang, java.util, java.text);
      
      with(myImports) {
        var mcResult = false; //By default this is false. When your condition meets change this to true
        var batteryLevel = mcApi.uidTag().getByUid("node1").resource.batteryLevel;
        if(batteryLevel >= 50){ // Your condition
           mcResult = true;
        }
      }
      
      Add rule:

      0_1479454517098_upload-ec78f98b-ead9-442b-80aa-28eda4e10dd4

      1 Reply Last reply Reply Quote 1
      • D Offline
        DaTTcz
        last edited by DaTTcz 1 Feb 2017, 01:51 31 Dec 2016, 09:30

        Thank you for your response!

        I am sorry for my bad English. I speak Czech.

        1 Reply Last reply Reply Quote 0
        • V Offline
          Velo17
          last edited by Velo17 15 Jan 2017, 12:21

          @jkandasa I'm using the 0.0.3.Final-SNAPSHOT - does this mean I dont need to create a script like above but find a rule/condition about battery levels of nodes? If so, I cannot find that, but I am currently using your script example, which works, but is of course a little cumbersome compared to another option of using a node's battery level directly somewhere in the rules panel...

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

          0

          Online

          632

          Users

          532

          Topics

          3.4k

          Posts
          Copyright © 2015-2025 MyController.org | Contributors | Localization