<commit_before>from .devicebase import DeviceBase
from insteonplm.statechangesignal import StateChangeSignal
from insteonplm.constants import *

class SecurityHealthSafety(DeviceBase):
    """Security Health Safety Control Device Class 0x10
    
    INSTEON Security Health Safety Control Device Class. 
    These are typically binary sensors with On/Off status.
    There are no state change commands that can be sent to the device.
    
    To monitor the state of the device subscribe to the state monitor:
         - sensor.connect(callback)  (state='Sensor')

    where callback defined as:
        - callback(self, device_id, state, state_value)
    """
    

    def __init__(self, plm, address, cat, subcat, product_key=None, description=None, model=None, groupbutton=0x01):
        DeviceBase.__init__(self, plm, address, cat, subcat, product_key, description, model, groupbutton)

        # Binary sensors are assumed to be readonly therefore no update method is necessary
        # Assuming the default for the sensor is 0
        self.sensor = StateChangeSignal('Sensor', None, 0x00)

        # Tell PLM not to just use the ALDB record for device info
        # This is likely the case for all devices in this category 
        self._product_data_in_aldb = True

        self._message_callbacks.add_message_callback(MESSAGE_STANDARD_MESSAGE_RECEIVED_0X50, COMMAND_LIGHT_ON_0X11_NONE, self._sensor_on_command_received)
        self._message_callbacks.add_message_callback(MESSAGE_EXTENDED_MESSAGE_RECEIVED_0X51, COMMAND_LIGHT_ON_0X11_NONE, self._sensor_on_command_received)
        self._message_callbacks.add_message_callback(MESSAGE_STANDARD_MESSAGE_RECEIVED_0X50, COMMAND_LIGHT_OFF_0X13_0X00, self._sensor_off_command_received)
        self._message_callbacks.add_message_callback(MESSAGE_EXTENDED_MESSAGE_RECEIVED_0X51, COMMAND_LIGHT_OFF_0X13_0X00, self._sensor_off_command_received)


    def _sensor_on_command_received(self, msg):
        """
        Message handler for Standard (0x50) or Extended (0x51) message commands 0x11 Sensor On
        When a message is received any state listeners are updated with the 
        return 0x01 for on
        """
        self.lightOnLevel.update(self.id, self.lightOnLevel._stateName, 0x01)

    def _sensor_offcommand_received(self, msg):
        """
        Message handler for Standard (0x50) or Extended (0x51) message commands 0x13 Sensor Off
        When a message is received any state listeners are updated with the 
        return 0x00 for off
        """
        self.lightOnLevel.update(self.id, self.lightOnLevel._stateName, 0x00)
            <commit_msg>Corrected _sensor_off_command_received<commit_after>from .devicebase import DeviceBase
from insteonplm.statechangesignal import StateChangeSignal
from insteonplm.constants import *

class SecurityHealthSafety(DeviceBase):
    """Security Health Safety Control Device Class 0x10
    
    INSTEON Security Health Safety Control Device Class. 
    These are typically binary sensors with On/Off status.
    There are no state change commands that can be sent to the device.
    
    To monitor the state of the device subscribe to the state monitor:
         - sensor.connect(callback)  (state='Sensor')

    where callback defined as:
        - callback(self, device_id, state, state_value)
    """
    

    def __init__(self, plm, address, cat, subcat, product_key=None, description=None, model=None, groupbutton=0x01):
        DeviceBase.__init__(self, plm, address, cat, subcat, product_key, description, model, groupbutton)

        # Binary sensors are assumed to be readonly therefore no update method is necessary
        # Assuming the default for the sensor is 0
        self.sensor = StateChangeSignal('Sensor', None, 0x00)

        # Tell PLM not to just use the ALDB record for device info
        # This is likely the case for all devices in this category 
        self._product_data_in_aldb = True

        self._message_callbacks.add_message_callback(MESSAGE_STANDARD_MESSAGE_RECEIVED_0X50, COMMAND_LIGHT_ON_0X11_NONE, self._sensor_on_command_received)
        self._message_callbacks.add_message_callback(MESSAGE_EXTENDED_MESSAGE_RECEIVED_0X51, COMMAND_LIGHT_ON_0X11_NONE, self._sensor_on_command_received)
        self._message_callbacks.add_message_callback(MESSAGE_STANDARD_MESSAGE_RECEIVED_0X50, COMMAND_LIGHT_OFF_0X13_0X00, self._sensor_off_command_received)
        self._message_callbacks.add_message_callback(MESSAGE_EXTENDED_MESSAGE_RECEIVED_0X51, COMMAND_LIGHT_OFF_0X13_0X00, self._sensor_off_command_received)


    def _sensor_on_command_received(self, msg):
        """
        Message handler for Standard (0x50) or Extended (0x51) message commands 0x11 Sensor On
        When a message is received any state listeners are updated with the 
        return 0x01 for on
        """
        self.lightOnLevel.update(self.id, self.lightOnLevel._stateName, 0x01)

    def _sensor_off_command_received(self, msg):
        """
        Message handler for Standard (0x50) or Extended (0x51) message commands 0x13 Sensor Off
        When a message is received any state listeners are updated with the 
        return 0x00 for off
        """
        self.lightOnLevel.update(self.id, self.lightOnLevel._stateName, 0x00)
            
{'fraction_non_alphanumeric': 0.05721864342553998, 'fraction_numerical': 0.026525198938992044, 'mean_word_length': 3.7730560578661843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3094914', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1502, 'n_words': 443}