Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Threading.Tasks;
- using JoySoftware.HomeAssistant.NetDaemon.Common;
- using System.Linq;
- public class BatteryManager : NetDaemonApp
- {
- public override async Task InitializeAsync()
- {
- foreach (var device in State.Where(n => n.Attribute.battery_level < 20))
- {
- Log($"{device.EntityId} : {device.Attribute.battery_level}");
- }
- foreach (var device in State.Where(n => n.EntityId.Contains("battery_level") && n.State < 20))
- {
- // Remove 14 characters from end (battery_level) to get entity id
- Log($"{device.EntityId[0..^14]} : {device.State}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement