Exemplo n.º 1
0
 def initialize(self, botengine):
     """
     Initialize this object
     
     The correct behavior is to create the object, then initialize() it every time you want to use it in a new bot execution environment
     """
     ThermostatDevice.initialize(self, botengine)
 def initialize(self, botengine):
     """
     Initialize this object
     
     The correct behavior is to create the object, then initialize() it every time you want to use it in a new bot execution environment
     """
     ThermostatDevice.initialize(self, botengine)
 def set_heating_setpoint(self, botengine, setpoint_celsius, reliably=False):
     """
     Set the heating set-point
     :param botengine: BotEngine environmnet
     :param setpoint_celsius: Temperature in Celsius
     :param reliably: True to keep retrying to get the command through
     """
     ThermostatDevice.set_heating_setpoint(self, botengine, setpoint_celsius, reliably=False)
 def set_cooling_setpoint(self, botengine, setpoint_celsius, reliably=False):
     """
     Set the cooling setpoint
     :param botengine: BotEngine environment
     :param setpoint_celsius: Absolute setpoint in Celsius
     :param reliably: True to keep retrying to get the command through
     """
     ThermostatDevice.set_cooling_setpoint(self, botengine, setpoint_celsius, reliably=False)
Exemplo n.º 5
0
 def set_cooling_setpoint(self, botengine, setpoint_celsius, reliably=False):
     """
     Set the cooling setpoint
     :param botengine: BotEngine environment
     :param setpoint_celsius: Absolute setpoint in Celsius
     :param reliably: True to keep retrying to get the command through
     """
     ThermostatDevice.set_cooling_setpoint(self, botengine, setpoint_celsius, reliably=False)
Exemplo n.º 6
0
 def set_heating_setpoint(self, botengine, setpoint_celsius, reliably=False):
     """
     Set the heating set-point
     :param botengine: BotEngine environmnet
     :param setpoint_celsius: Temperature in Celsius
     :param reliably: True to keep retrying to get the command through
     """
     ThermostatDevice.set_heating_setpoint(self, botengine, setpoint_celsius, reliably=False)
 def set_system_mode(self, botengine, system_mode, reliably=False):
     """
     Set the system mode
     :param botengine:
     :param system_mode:
     :param reliably: True to keep retrying to get the command through
     :return:
     """
     ThermostatDevice.set_system_mode(self, botengine, system_mode, reliably=False)
Exemplo n.º 8
0
 def set_system_mode(self, botengine, system_mode, reliably=False):
     """
     Set the system mode
     :param botengine:
     :param system_mode:
     :param reliably: True to keep retrying to get the command through
     :return:
     """
     ThermostatDevice.set_system_mode(self, botengine, system_mode, reliably=False)
    def initialize(self, botengine):
        """
        Initialization
        :param botengine:
        :return:
        """
        ThermostatDevice.initialize(self, botengine)

        if not hasattr(self, 'saved_state'):
            self.saved_state = None
Exemplo n.º 10
0
    def initialize(self, botengine):
        """
        Initialization
        :param botengine:
        :return:
        """
        ThermostatDevice.initialize(self, botengine)

        if not hasattr(self, 'saved_state'):
            self.saved_state = None
Exemplo n.º 11
0
    def initialize(self, botengine):
        """
        Initialize
        :param botengine:
        :return:
        """
        if not hasattr(self, 'ee_only'):
            self.ee_only = False

        if not hasattr(self, 'ee_timestamp_ms'):
            self.ee_timestamp_ms = None

        ThermostatDevice.initialize(self, botengine)
    def initialize(self, botengine):
        """
        Initialize
        :param botengine:
        :return:
        """
        if not hasattr(self, 'ee_only'):
            self.ee_only = False

        if not hasattr(self, 'ee_timestamp_ms'):
            self.ee_timestamp_ms = None

        ThermostatDevice.initialize(self, botengine)
Exemplo n.º 13
0
    def __init__(self,
                 botengine,
                 device_id,
                 device_type,
                 device_description,
                 precache_measurements=True):
        ThermostatDevice.__init__(self,
                                  botengine,
                                  device_id,
                                  device_type,
                                  device_description,
                                  precache_measurements=precache_measurements)

        # The boolean on/off state of this device that was saved
        self.saved_state = None
    def __init__(self, botengine, device_id, device_type, device_description, precache_measurements=True):
        """
        Constructor
        :param botengine:
        :param device_id:
        :param device_type:
        :param device_description:
        :param precache_measurements:
        """
        ThermostatDevice.__init__(self, botengine, device_id, device_type, device_description, precache_measurements)

        # Set to True to activate the 'climate' mode switching functionality which is incompatible with demand response events.
        self.ee_only = False

        # Start timestamp of EE events for tracking
        self.ee_timestamp_ms = None
    def set_energy_efficiency_sleep(self, botengine):
        """
        Add an energy efficiency policy for sleep mode
        :param botengine: BotEngine environment
        :param identifier: Identifier so we can cancel or modify this energy efficiency policy later.
        :return: The current system mode if the change went into effect, Nothing if nothing happened
        """
        if not self.ee_only:
            return ThermostatDevice.set_energy_efficiency_sleep(self, botengine)

        if self.ee_timestamp_ms is None:
            self.ee_timestamp_ms = botengine.get_timestamp()

        botengine.send_command(self.device_id, self.COMMAND_CLIMATE_MODE, "sleep")
        self.location_object.narrate(botengine,
                                        title = _("'{}': Sleep mode").format(self.description),
                                        description = _("Setting your ecobee thermostat into Sleep mode."),
                                        priority = botengine.NARRATIVE_PRIORITY_DEBUG,
                                        icon = 'thermostat'
                                        )

        policies = {
            'device_id': self.device_id,
            'device_description': self.description,
            'is_connected': self.is_connected,
            'thermostat_mode': self.thermostat_mode_to_string(self.get_system_mode(botengine)),
            'ecobee_climate': "sleep",
            'ee_start_timestamp_ms': self.ee_timestamp_ms
        }

        self.location_object.track(botengine, 'thermostat_policy', properties=policies)
Exemplo n.º 16
0
    def set_energy_efficiency_home(self, botengine):
        """
        Turn off all away and sleep energy efficiency policies
        :param botengine: BotEngine environment
        """
        if not self.ee_only:
            return ThermostatDevice.set_energy_efficiency_home(self, botengine)

        if self.ee_timestamp_ms is not None:
            # End of all EE events
            duration_s = (botengine.get_timestamp() -
                          self.ee_timestamp_ms) / 1000
            self.ee_timestamp_ms = None
            self.location_object.track(botengine,
                                       "ee_complete",
                                       properties={
                                           'duration_s': duration_s,
                                           'device_id': self.device_id,
                                           'description': self.description
                                       })
            import importlib
            try:
                analytics = importlib.import_module('analytics')

                # This number will represent the total amount of time across ALL devices.
                # For example, if you have 1 thermostat and a EE event for 10000s, then the total is 10000s.
                # But if you have 2 thermostats and a EE event for 10000s, then the total is 20000s
                analytics.get_analytics(botengine).people_increment(
                    botengine, {'ee_total_s': duration_s})

            except ImportError:
                pass

        botengine.send_command(self.device_id, self.COMMAND_CLIMATE_MODE,
                               "home")

        self.location_object.narrate(
            botengine,
            title=_("'{}': Home mode").format(self.description),
            description=_("Setting your ecobee thermostat into Home mode."),
            priority=botengine.NARRATIVE_PRIORITY_DEBUG,
            icon='thermostat')

        policies = {
            'device_id':
            self.device_id,
            'device_description':
            self.description,
            'is_connected':
            self.is_connected,
            'thermostat_mode':
            self.thermostat_mode_to_string(self.get_system_mode(botengine)),
            'ecobee_climate':
            "home"
        }

        self.location_object.track(botengine,
                                   'thermostat_policy',
                                   properties=policies)
Exemplo n.º 17
0
    def __init__(self,
                 botengine,
                 device_id,
                 device_type,
                 device_description,
                 precache_measurements=True):
        """
        Constructor
        :param botengine:
        :param device_id:
        :param device_type:
        :param device_description:
        :param precache_measurements:
        """
        ThermostatDevice.__init__(self, botengine, device_id, device_type,
                                  device_description, precache_measurements)

        # Set to True to activate the 'climate' mode switching functionality which is incompatible with demand response events.
        self.ee_only = False

        # Start timestamp of EE events for tracking
        self.ee_timestamp_ms = None
    def set_energy_efficiency_home(self, botengine):
        """
        Turn off all away and sleep energy efficiency policies
        :param botengine: BotEngine environment
        """
        if not self.ee_only:
            return ThermostatDevice.set_energy_efficiency_home(self, botengine)

        if self.ee_timestamp_ms is not None:
            # End of all EE events
            duration_s = (botengine.get_timestamp() - self.ee_timestamp_ms) / 1000
            self.ee_timestamp_ms = None
            self.location_object.track(botengine, "ee_complete", properties={'duration_s': duration_s, 'device_id': self.device_id, 'description': self.description})
            import importlib
            try:
                analytics = importlib.import_module('analytics')

                # This number will represent the total amount of time across ALL devices.
                # For example, if you have 1 thermostat and a EE event for 10000s, then the total is 10000s.
                # But if you have 2 thermostats and a EE event for 10000s, then the total is 20000s
                analytics.get_analytics(botengine).people_increment(botengine, {'ee_total_s': duration_s})

            except ImportError:
                pass

        botengine.send_command(self.device_id, self.COMMAND_CLIMATE_MODE, "home")

        self.location_object.narrate(botengine,
                                        title = _("'{}': Home mode").format(self.description),
                                        description = _("Setting your ecobee thermostat into Home mode."),
                                        priority = botengine.NARRATIVE_PRIORITY_DEBUG,
                                        icon = 'thermostat'
                                        )

        policies = {
            'device_id': self.device_id,
            'device_description': self.description,
            'is_connected': self.is_connected,
            'thermostat_mode': self.thermostat_mode_to_string(self.get_system_mode(botengine)),
            'ecobee_climate': "home"
        }

        self.location_object.track(botengine, 'thermostat_policy', properties=policies)
Exemplo n.º 19
0
    def set_energy_efficiency_sleep(self, botengine):
        """
        Add an energy efficiency policy for sleep mode
        :param botengine: BotEngine environment
        :param identifier: Identifier so we can cancel or modify this energy efficiency policy later.
        :return: The current system mode if the change went into effect, Nothing if nothing happened
        """
        if not self.ee_only:
            return ThermostatDevice.set_energy_efficiency_sleep(
                self, botengine)

        if self.ee_timestamp_ms is None:
            self.ee_timestamp_ms = botengine.get_timestamp()

        botengine.send_command(self.device_id, self.COMMAND_CLIMATE_MODE,
                               "sleep")
        self.location_object.narrate(
            botengine,
            title=_("'{}': Sleep mode").format(self.description),
            description=_("Setting your ecobee thermostat into Sleep mode."),
            priority=botengine.NARRATIVE_PRIORITY_DEBUG,
            icon='thermostat')

        policies = {
            'device_id':
            self.device_id,
            'device_description':
            self.description,
            'is_connected':
            self.is_connected,
            'thermostat_mode':
            self.thermostat_mode_to_string(self.get_system_mode(botengine)),
            'ecobee_climate':
            "sleep",
            'ee_start_timestamp_ms':
            self.ee_timestamp_ms
        }

        self.location_object.track(botengine,
                                   'thermostat_policy',
                                   properties=policies)
    def __init__(self, botengine, device_id, device_type, device_description, precache_measurements=True):
        ThermostatDevice.__init__(self, botengine, device_id, device_type, device_description, precache_measurements=precache_measurements)

        # The boolean on/off state of this device that was saved
        self.saved_state = None
    def increment_energy_efficiency(self, botengine, identifier, max_offset_c=2.4):
        """
        If the identifier is "sleep" or "away", then the thermostat is put into sleep mode or away mode.
        Otherwise we elevate the request to the generic thermostat handler.
        :param botengine: BotEngine environment
        :param max_relative_offset_c: Maximum offset in degrees C to achieve relative to our preferred temperature while in HOME mode. The thermostat increments to this max level after 3 calls to this method.
        :return: the system mode if the thermostat was paused successfully, None if the thermostat was not paused.
        """
        if not self.ee_only:
            return ThermostatDevice.increment_energy_efficiency(self, botengine, identifier, max_offset_c)

        if identifier == "sleep":
            if self.ee_timestamp_ms is None:
                self.ee_timestamp_ms = botengine.get_timestamp()

            botengine.send_command(self.device_id, self.COMMAND_CLIMATE_MODE, "sleep")

            self.location_object.narrate(botengine,
                                        title = _("'{}': Sleep mode").format(self.description),
                                        description = _("Setting your ecobee thermostat into Sleep mode."),
                                        priority = botengine.NARRATIVE_PRIORITY_DEBUG,
                                        icon = 'thermostat'
                                        )

            policies = {
                'device_id': self.device_id,
                'device_description': self.description,
                'is_connected': self.is_connected,
                'thermostat_mode': self.thermostat_mode_to_string(self.get_system_mode(botengine)),
                'ecobee_climate': "sleep",
                'ee_start_timestamp_ms': self.ee_timestamp_ms
            }

            self.location_object.track(botengine, 'thermostat_policy', properties=policies)

        elif identifier == "away":
            if self.ee_timestamp_ms is None:
                self.ee_timestamp_ms = botengine.get_timestamp()

            botengine.send_command(self.device_id, self.COMMAND_CLIMATE_MODE, "away")

            self.location_object.narrate(botengine,
                                        title = _("'{}': Away mode").format(self.description),
                                        description = _("Setting your ecobee thermostat into Away mode."),
                                        priority = botengine.NARRATIVE_PRIORITY_DEBUG,
                                        icon = 'thermostat'
                                        )

            policies = {
                'device_id': self.device_id,
                'device_description': self.description,
                'is_connected': self.is_connected,
                'thermostat_mode': self.thermostat_mode_to_string(self.get_system_mode(botengine)),
                'ecobee_climate': "away",
                'ee_start_timestamp_ms': self.ee_timestamp_ms
            }

            self.location_object.track(botengine, 'thermostat_policy', properties=policies)

        else:
            return ThermostatDevice.increment_energy_efficiency(self, botengine, identifier, max_offset_c)
Exemplo n.º 22
0
    def increment_energy_efficiency(self,
                                    botengine,
                                    identifier,
                                    max_offset_c=2.4):
        """
        If the identifier is "sleep" or "away", then the thermostat is put into sleep mode or away mode.
        Otherwise we elevate the request to the generic thermostat handler.
        :param botengine: BotEngine environment
        :param max_relative_offset_c: Maximum offset in degrees C to achieve relative to our preferred temperature while in HOME mode. The thermostat increments to this max level after 3 calls to this method.
        :return: the system mode if the thermostat was paused successfully, None if the thermostat was not paused.
        """
        if not self.ee_only:
            return ThermostatDevice.increment_energy_efficiency(
                self, botengine, identifier, max_offset_c)

        if identifier == "sleep":
            if self.ee_timestamp_ms is None:
                self.ee_timestamp_ms = botengine.get_timestamp()

            botengine.send_command(self.device_id, self.COMMAND_CLIMATE_MODE,
                                   "sleep")

            self.location_object.narrate(
                botengine,
                title=_("'{}': Sleep mode").format(self.description),
                description=_(
                    "Setting your ecobee thermostat into Sleep mode."),
                priority=botengine.NARRATIVE_PRIORITY_DEBUG,
                icon='thermostat')

            policies = {
                'device_id':
                self.device_id,
                'device_description':
                self.description,
                'is_connected':
                self.is_connected,
                'thermostat_mode':
                self.thermostat_mode_to_string(
                    self.get_system_mode(botengine)),
                'ecobee_climate':
                "sleep",
                'ee_start_timestamp_ms':
                self.ee_timestamp_ms
            }

            self.location_object.track(botengine,
                                       'thermostat_policy',
                                       properties=policies)

        elif identifier == "away":
            if self.ee_timestamp_ms is None:
                self.ee_timestamp_ms = botengine.get_timestamp()

            botengine.send_command(self.device_id, self.COMMAND_CLIMATE_MODE,
                                   "away")

            self.location_object.narrate(
                botengine,
                title=_("'{}': Away mode").format(self.description),
                description=_(
                    "Setting your ecobee thermostat into Away mode."),
                priority=botengine.NARRATIVE_PRIORITY_DEBUG,
                icon='thermostat')

            policies = {
                'device_id':
                self.device_id,
                'device_description':
                self.description,
                'is_connected':
                self.is_connected,
                'thermostat_mode':
                self.thermostat_mode_to_string(
                    self.get_system_mode(botengine)),
                'ecobee_climate':
                "away",
                'ee_start_timestamp_ms':
                self.ee_timestamp_ms
            }

            self.location_object.track(botengine,
                                       'thermostat_policy',
                                       properties=policies)

        else:
            return ThermostatDevice.increment_energy_efficiency(
                self, botengine, identifier, max_offset_c)