mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
UTC upgrades for scheduler, nmap tracker, dsl_trigger
This commit is contained in:
parent
cd2b9ce975
commit
ae0cf49560
@ -6,8 +6,9 @@ Provides functionality to turn on lights based on
|
||||
the state of the sun and devices.
|
||||
"""
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timedelta
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.const import STATE_HOME, STATE_NOT_HOME
|
||||
from . import light, sun, device_tracker, group
|
||||
|
||||
@ -115,7 +116,7 @@ def setup(hass, config):
|
||||
new_state.state == STATE_HOME:
|
||||
|
||||
# These variables are needed for the elif check
|
||||
now = datetime.now()
|
||||
now = dt_util.now()
|
||||
start_point = calc_time_for_light_when_sunset()
|
||||
|
||||
# Do we need lights?
|
||||
|
@ -21,7 +21,7 @@ The IP addresses to scan in the network-prefix notation (192.168.1.1/24) or
|
||||
the range notation (192.168.1.1-255).
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta, datetime
|
||||
from datetime import timedelta
|
||||
from collections import namedtuple
|
||||
import subprocess
|
||||
import re
|
||||
@ -29,6 +29,7 @@ import re
|
||||
from libnmap.process import NmapProcess
|
||||
from libnmap.parser import NmapParser, NmapParserException
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.const import CONF_HOSTS
|
||||
from homeassistant.helpers import validate_config
|
||||
from homeassistant.util import Throttle, convert
|
||||
@ -106,7 +107,7 @@ class NmapDeviceScanner(object):
|
||||
Returns True if successful, False otherwise. """
|
||||
try:
|
||||
results = NmapParser.parse(stdout)
|
||||
now = datetime.now()
|
||||
now = dt_util.now()
|
||||
self.last_results = []
|
||||
for host in results.hosts:
|
||||
if host.is_up():
|
||||
@ -140,7 +141,7 @@ class NmapDeviceScanner(object):
|
||||
options = "-F --host-timeout 5"
|
||||
exclude_targets = set()
|
||||
if self.home_interval:
|
||||
now = datetime.now()
|
||||
now = dt_util.now()
|
||||
for host in self.last_results:
|
||||
if host.last_update + self.home_interval > now:
|
||||
exclude_targets.add(host)
|
||||
|
@ -13,9 +13,10 @@ which time.
|
||||
}
|
||||
|
||||
"""
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.components.scheduler import ServiceEventListener
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -46,14 +47,12 @@ class TimeEventListener(ServiceEventListener):
|
||||
def schedule(self, hass):
|
||||
""" Schedule this event so that it will be called. """
|
||||
|
||||
next_time = datetime.now().replace(hour=self.hour,
|
||||
minute=self.minute,
|
||||
second=self.second,
|
||||
microsecond=0)
|
||||
next_time = dt_util.now().replace(
|
||||
hour=self.hour, minute=self.minute, second=self.second)
|
||||
|
||||
# Calculate the next time the event should be executed.
|
||||
# That is the next day that the schedule is configured to run
|
||||
while next_time < datetime.now() or \
|
||||
while next_time < dt_util.now() or \
|
||||
next_time.weekday() not in self.my_schedule.days:
|
||||
|
||||
next_time = next_time + timedelta(days=1)
|
||||
|
@ -22,7 +22,7 @@ which event (sunset or sunrise) and the offset.
|
||||
|
||||
"""
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import timedelta
|
||||
|
||||
try:
|
||||
import ephem
|
||||
@ -233,7 +233,7 @@ class SunEventListener(ServiceEventListener):
|
||||
else:
|
||||
next_time = next_event + self.offset
|
||||
|
||||
while next_time < datetime.now() or \
|
||||
while next_time < dt_util.now() or \
|
||||
next_time.weekday() not in self.my_schedule.days:
|
||||
next_time = next_time + timedelta(days=1)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user