#NEWLINE# def _report_attributes( self , entity_id , new_state ) : #NEWLINE# #INDENT# 'Report the attributes.' #NEWLINE# now = time . time ( ) #NEWLINE# things = dict ( new_state . attributes ) #NEWLINE# try : #NEWLINE# #INDENT# things [ 'state' ] = state . state_as_number ( new_state ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# lines = [ ( '%s.%s.%s %f %i' % ( self . _prefix , now , key . replace ( ' ' , '_' ) , value , now ) ) for ( key , value ) in things . items ( ) if isinstance ( value , ( float , int ) ) ] #NEWLINE# if ( not lines ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# _LOGGER . debug ( 'Sending to graphite: %s' , lines ) #NEWLINE# try : #NEWLINE# #INDENT# self . _send_to_graphite ( '\n' . join ( lines ) ) #NEWLINE# #UNINDENT# except socket . gaierror : #NEWLINE# #INDENT# _LOGGER . error ( 'Unable to connect to host %s' , self . _host ) #NEWLINE# #UNINDENT# except socket . error : #NEWLINE# #INDENT# _LOGGER . exception ( 'Failed to send data to graphite' )