#NEWLINE# def test_state_attributes_current_position( self ) : #NEWLINE# #INDENT# 'Test the current position.' #NEWLINE# self . hass . config . components = [ 'mqtt' ] #NEWLINE# assert _setup_component ( self . hass , rollershutter . DOMAIN , { #NEWLINE# #INDENT# rollershutter . DOMAIN : { #NEWLINE# #INDENT# 'platform' : 'mqtt' , #NEWLINE# 'name' : 'test' , #NEWLINE# 'state_topic' : 'state-topic' , #NEWLINE# 'command_topic' : 'command-topic' , #NEWLINE# 'payload_up' : 'UP' , #NEWLINE# 'payload_down' : 'DOWN' , #NEWLINE# 'payload_stop' : 'STOP' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# state_attributes_dict = self . hass . states . get ( 'rollershutter.test' ) . attributes #NEWLINE# self . assertFalse ( ( 'current_position' in state_attributes_dict ) ) #NEWLINE# fire_mqtt_message ( state_attributes_dict . hass , 'state-topic' , '0' ) #NEWLINE# self . hass . pool . block_till_done ( ) #NEWLINE# current_position = self . hass . states . get ( 'rollershutter.test' ) . attributes [ 'current_position' ] #NEWLINE# self . assertEqual ( 0 , current_position ) #NEWLINE# fire_mqtt_message ( self . hass , 'state-topic' , '50' ) #NEWLINE# self . hass . pool . block_till_done ( ) #NEWLINE# current_position = self . hass . states . get ( 'rollershutter.test' ) . attributes [ 'current_position' ] #NEWLINE# self . assertEqual ( 50 , current_position ) #NEWLINE# fire_mqtt_message ( self . hass , 'state-topic' , '101' ) #NEWLINE# self . hass . pool . block_till_done ( ) #NEWLINE# current_position = self . hass . states . get ( 'rollershutter.test' ) . attributes [ 'current_position' ] #NEWLINE# self . assertEqual ( 50 , current_position ) #NEWLINE# fire_mqtt_message ( self . hass , 'state-topic' , 'non-numeric' ) #NEWLINE# self . hass . pool . block_till_done ( ) #NEWLINE# current_position = self . hass . states . get ( 'rollershutter.test' ) . attributes [ 'current_position' ] #NEWLINE# self . assertEqual ( 50 , current_position )