func Switch(instance Instance, state model.State) (Logic, error) {
    s, ok := state.(*model.SwitchState)
    if !ok {
        return nil, derrors.NewInternalError(errors.New("bad state object"))
    }