'Test if logbook message is correctly created for switches.
Especially test if the special handling for turn on/off events is done.'

def test_entry_message_from_state_device(self):

    pointA = dt_util.utcnow()
    eventA = self.create_state_changed_event(pointA, 'switch.bla', 10)
    to_state = ha.State.from_dict(eventA.data.get('new_state'))
    message = logbook._entry_message_from_state(to_state.domain, to_state)
    self.assertEqual('changed    to    10', message)
    eventA = self.create_state_changed_event(pointA, 'switch.bla', STATE_ON)
    to_state = ha.State.from_dict(eventA.data.get('new_state'))
    message = logbook._entry_message_from_state(to_state.domain, to_state)
    self.assertEqual('turned    on', message)
    eventA = self.create_state_changed_event(pointA, 'switch.bla', STATE_OFF)
    to_state = ha.State.from_dict(eventA.data.get('new_state'))
    message = logbook._entry_message_from_state(to_state.domain, to_state)
    self.assertEqual('turned    off', message)
