SHARE
TWEET

Untitled

a guest Jan 24th, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Threading.Tasks;
  2. using JoySoftware.HomeAssistant.NetDaemon.Common;
  3. using System.Linq;
  4. public class BatteryManager : NetDaemonApp
  5. {
  6.     public override async Task InitializeAsync()
  7.     {
  8.         foreach (var device in State.Where(n => n.Attribute.battery_level < 20))
  9.         {
  10.             Log($"{device.EntityId} : {device.Attribute.battery_level}");
  11.         }
  12.  
  13.         foreach (var device in State.Where(n => n.EntityId.Contains("battery_level") && n.State < 20))
  14.         {
  15.             // Remove 14 characters from end (battery_level) to get entity id
  16.             Log($"{device.EntityId[0..^14]} : {device.State}");
  17.         }
  18.     }
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top