Coverage for janitoo.value : 84%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
"""
This file is part of Janitoo.
Janitoo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Janitoo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Janitoo. If not, see <http://www.gnu.org/licenses/>.
"""
# Set default logging handler to avoid "No handler found" warnings.
############################################################## #Check that we are in sync with the official command classes #Must be implemented for non-regression
##############################################################
""" :param int uuid: the unique uuid of the value on the controller """ """The UUID of the value""" """The UUID of the node the valuse is attached to""" """The voice_uuid of this value. Can be use to a""" """The HADD of the node associated to this value""" """The command class implemented by the value""" """Is the value readonly""" """Is the value writeonly""" """The default data of the value""" """The help of the value""" """The label of the value""" """The units of the value""" """The list of all valid items when the value type is list. This list is separated with pipe : '|'""" """The max of the value""" """The min of the value""" """The genre of the value""" """The type of the value""" """Get the value index (use with multi_instance nodes)""" """Say if the value is polled""" """The delay between 2 polls""" """The callback to get the value""" """The callback to get the value""" """The last known data of the value""" """The hadd to reply to"""
""" Convert data to the type of value
:return: The data of the value :rtype: depending of the type of the value
""" if data is not None: try: if self.type == 0x01: #Bool return string_to_bool(data) elif self.type == 0x02 or self.type == 0x04 or self.type == 0x07: #Byte or Int or Short #Decimal #Array logger.warning('[%s] - Do not convert data %s to %s.', self.__class__.__name__, data, VALUE_DESC[self.type]['label']) return data except: logger.exception('[%s] - Exception when converting data %s to %s', self.__class__.__name__, data, VALUE_DESC[self.type]['label']) return None return None
def data(self): """ Get the current data of the value.
:return: The data of the value :rtype: depending of the type of the value
"""
def data(self, value): """ Set the data of the value.
Best practice: Use check_data before setting it:
new_val = value.check_data(some_data) if new_val != None: value.data = new_val
:param value: The new data value :type value:
""" res = True res = self._set_data_cb(self.node_uuid, self.index, value) if res == True: self._data = value return res
"""Start the value. Can be used to start a thread to acquire data. This method is not called in the nodeman process. Programmer must call it manually, ie at stat machine change.
"""
"""Stop the value. This method is not called in the nodeman process. Programmer must call it manually, ie at stat machine change.
"""
"""Update internal dict from adict """
"""Retrieve a dict version of the value. Include all properties except : - ends with lock, _cb, - starts with timer, _ So use the naming convention above or ask for update if you really need it.
""" or key.startswith('_') or key.startswith('timer') \ or key in ['instances', 'options', 'master_config_value']:
"""Retrieve a json version of the value """
help='The heartbeat delay in seconds', label='heartbeat', units='seconds', index=0, cmd_class=COMMAND_CONFIGURATION, genre=0x04, max=3000, min=0, type=0x04, is_readonly=False, is_writeonly=False, is_polled=False, poll_delay=0, get_data_cb = get_data_cb, set_data_cb = set_data_cb )
help='The config timeout before applying configuration and rebooting', label='config_timeout', units='seconds', index=0, cmd_class=COMMAND_CONFIGURATION, genre=0x04, max=3000, min=0, type=0x04, is_readonly=False, is_writeonly=False, is_polled=False, poll_delay=0, get_data_cb = get_data_cb, set_data_cb = set_data_cb )
help='The Janitoo Home address', label='hadd', units='', index=0, cmd_class=COMMAND_CONFIGURATION, genre=0x04, type=0x20, is_readonly=False, is_writeonly=False, is_polled=False, poll_delay=0, get_data_cb = get_data_cb, set_data_cb = set_data_cb )
help='The name of the node', label='name', index=0, cmd_class=COMMAND_CONFIGURATION, genre=0x03, type=0x08, is_readonly=False, is_writeonly=False, is_polled=False, poll_delay=0, get_data_cb = get_data_cb, set_data_cb = set_data_cb )
help='The location of the node', label='location', index=0, cmd_class=COMMAND_CONFIGURATION, genre=0x03, type=0x08, is_readonly=False, is_writeonly=False, is_polled=False, poll_delay=0, get_data_cb = get_data_cb, set_data_cb = set_data_cb )
return JNTValue( uuid=uuid, help=help, label=label, index=index, cmd_class=COMMAND_CONFIGURATION, genre=0x03, type=0x04, is_readonly=False, is_writeonly=False, is_polled=False, default = default, poll_delay=0, get_data_cb = get_data_cb, set_data_cb = set_data_cb ) |