Shtime-API

There are two ways to access the API

  1. Directly

    Use it the following way to access the api, if you have no access to the sh object in your method or function:

    # to get access to the object instance:
    from lib.shtime import Shtime
    shtime = Shtime.get_instance()
    
    # to access a method (eg. to get timezone info):
    shtime.tzinfo()
    
  2. Through the main SmartHome object

    If you have access to the sh object in your method or function, you can use the following way:

    # to access a method (eg. to get timezone info):
    sh.shtime.tzinfo()
    

The API is implemented through the following library:

lib.shtime

class lib.shtime.Shtime(smarthome)[source]

Bases: object

static get_instance()[source]
Returns the instance of the Shtime class, to be used to access the shtime-API
   from lib.shtime import Shtime
   shtime = Shtime.get_instance()

   # to access a method (eg. to get timezone info):
   shtime.tzinfo()


:return: shinfo instance
:rtype: object or None
set_tz(tz)[source]

set timezone info from name of timezone

set_tzinfo(tzinfo)[source]

Set the timezone info

now()[source]

Returns the actual time in a timezone aware format

Returns:Actual time for the local timezone
Return type:datetime
tz()[source]

Returns the the actual local timezone

Returns:Timezone
Return type:str
tzinfo()[source]

Returns the info about the actual local timezone

Returns:Timezone info
Return type:object
utcnow()[source]

Returns the actual time in GMT

Returns:Actual time in GMT
Return type:datetime
utcinfo()[source]

Returns the info about the GMT timezone

Returns:Timezone info
Return type:str
runtime()[source]

Returns the uptime of SmartHomeNG

Returns:Uptime in days, hours, minutes and seconds
Return type:str