def test_disregard_wrong_payload():
 with assert_setup_component(1):
  setup_component(HASS, sensor.DOMAIN, {sensor.DOMAIN: {'platform': 'pilight', 'name': 'test_2', 'variable': 'test', 'payload': {'uuid': '1-2-3-4', 'protocol': 'test-protocol_2'}}})
  fire_pilight_message(protocol='test-protocol_2', data={'test': 'data', 'uuid': '0-0-0-0'})
  HASS.block_till_done()
  state = HASS.states.get('sensor.test_2')
  assert (state.state == 'unknown')
  fire_pilight_message(protocol='wrong-protocol', data={'test': 'data', 'uuid': '1-2-3-4'})
  HASS.block_till_done()
  state = HASS.states.get('sensor.test_2')
  assert (state.state == 'unknown')
  fire_pilight_message(protocol='test-protocol_2', data={'test': 'data', 'uuid': '1-2-3-4', 'other_payload': 3.141})
  HASS.block_till_done()
  state = HASS.states.get('sensor.test_2')
  assert (state.state == 'data')

def test_disregard_wrong_payload ( ) : with assert_setup_component ( 1 ) : setup_component ( HASS , sensor . DOMAIN , { sensor . DOMAIN : { 'platform' : 'pilight' , 'name' : 'test_2' , 'variable' : 'test' , 'payload' : { 'uuid' : '1-2-3-4' , 'protocol' : 'test-protocol_2' } } } ) fire_pilight_message ( protocol = 'test-protocol_2' , data = { 'test' : 'data' , 'uuid' : '0-0-0-0' } ) HASS . block_till_done ( ) state = HASS . states . get ( 'sensor.test_2' ) assert ( state . state == 'unknown' ) fire_pilight_message ( protocol = 'wrong-protocol' , data = { 'test' : 'data' , 'uuid' : '1-2-3-4' } ) HASS . block_till_done ( ) state = HASS . states . get ( 'sensor.test_2' ) assert ( state . state == 'unknown' ) fire_pilight_message ( protocol = 'test-protocol_2' , data = { 'test' : 'data' , 'uuid' : '1-2-3-4' , 'other_payload' : 3.141 } ) HASS . block_till_done ( ) state = HASS . states . get ( 'sensor.test_2' ) assert ( state . state == 'data' )
test omitting setting of value with wrong payload .