<commit_before>﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ZWave.CommandClasses;

namespace ZWave.Devices
{
    public class BatteryDevice : Device
    {
        private byte? _controllerID;
        public event EventHandler<EventArgs> WakeUp;

        public BatteryDevice(Node node)
            : base(node)
        {
            node.GetCommandClass<WakeUp>().Changed += WakeUp_Changed;

        }

        private async Task<byte> GetControllerID()
        {
            return (_controllerID ?? (_controllerID = await Node.Controller.GetNodeID())).Value;
        }

        private void WakeUp_Changed(object sender, ReportEventArgs<WakeUpReport> e)
        {
            if (e.Report.Awake)
            {
                OnWakeUp(EventArgs.Empty);
                return;
            }
        }

        protected virtual void OnWakeUp(EventArgs e)
        {
            WakeUp?.Invoke(this, e);
        }

        public async Task<TimeSpan> GetWakeUpInterval()
        {
            return (await Node.GetCommandClass<WakeUp>().GetInterval()).Interval;
        }

        public async Task SetWakeUpInterval(TimeSpan value)
        {
            await Node.GetCommandClass<WakeUp>().SetInterval(value, 0xFF);
        }

        public async Task<Measure> GetBatteryLevel()
        {
            var value = (await Node.GetCommandClass<Battery>().Get()).Value;
            return new Measure(value, Unit.Percentage);
        }

        public async Task Sleep()
        {
            await Node.GetCommandClass<WakeUp>().NoMoreInformation();
        }
    }
}<commit_msg>SetWakeUpInterval will set the targetnode to the controller<commit_after>﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ZWave.CommandClasses;

namespace ZWave.Devices
{
    public class BatteryDevice : Device
    {
        private byte? _controllerID;
        public event EventHandler<EventArgs> WakeUp;

        public BatteryDevice(Node node)
            : base(node)
        {
            node.GetCommandClass<WakeUp>().Changed += WakeUp_Changed;

        }

        private async Task<byte> GetControllerID()
        {
            return (_controllerID ?? (_controllerID = await Node.Controller.GetNodeID())).Value;
        }

        private void WakeUp_Changed(object sender, ReportEventArgs<WakeUpReport> e)
        {
            if (e.Report.Awake)
            {
                OnWakeUp(EventArgs.Empty);
                return;
            }
        }

        protected virtual void OnWakeUp(EventArgs e)
        {
            WakeUp?.Invoke(this, e);
        }

        public async Task<TimeSpan> GetWakeUpInterval()
        {
            return (await Node.GetCommandClass<WakeUp>().GetInterval()).Interval;
        }

        public async Task SetWakeUpInterval(TimeSpan value)
        {
            var controllerNodeID = await Node.Controller.GetNodeID();
            await Node.GetCommandClass<WakeUp>().SetInterval(value, controllerNodeID);
        }

        public async Task<Measure> GetBatteryLevel()
        {
            var value = (await Node.GetCommandClass<Battery>().Get()).Value;
            return new Measure(value, Unit.Percentage);
        }

        public async Task Sleep()
        {
            await Node.GetCommandClass<WakeUp>().NoMoreInformation();
        }
    }
}
{'fraction_non_alphanumeric': 0.09453904873752202, 'fraction_numerical': 0.0002935995302407516, 'mean_word_length': 2.0338379341050756, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4202650', 'n_tokens_mistral': 933, 'n_tokens_neox': 902, 'n_words': 187}