def test_sensor_value_from_code():
 with assert_setup_component(1):
  setup_component(HASS, sensor.DOMAIN, {sensor.DOMAIN: {'platform': 'pilight', 'name': 'test', 'variable': 'test', 'payload': {'protocol': 'test-protocol'}, 'unit_of_measurement': 'fav unit'}})
  state = HASS.states.get('sensor.test')
  assert (state.state == 'unknown')
  unit_of_measurement = state.attributes.get('unit_of_measurement')
  assert (unit_of_measurement == 'fav unit')
  fire_pilight_message(protocol='test-protocol', data={'test': 42})
  HASS.block_till_done()
  state = HASS.states.get('sensor.test')
  assert (state.state == '42')

def test_sensor_value_from_code ( ) : with assert_setup_component ( 1 ) : setup_component ( HASS , sensor . DOMAIN , { sensor . DOMAIN : { 'platform' : 'pilight' , 'name' : 'test' , 'variable' : 'test' , 'payload' : { 'protocol' : 'test-protocol' } , 'unit_of_measurement' : 'fav unit' } } ) state = HASS . states . get ( 'sensor.test' ) assert ( state . state == 'unknown' ) unit_of_measurement = state . attributes . get ( 'unit_of_measurement' ) assert ( unit_of_measurement == 'fav unit' ) fire_pilight_message ( protocol = 'test-protocol' , data = { 'test' : 42 } ) HASS . block_till_done ( ) state = HASS . states . get ( 'sensor.test' ) assert ( state . state == '42' )
test the setting of value via pilight .