What's wrong?

Hello,
I have a question what's wrong with my code?
I get this error:

intelligenter_Thermostat:42: error: expected unqualified-id before '{' token

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <dht.h>
int Thermostat = D1;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "1ccc9fb81c384a069af64fbafb59fa3c";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "QuickbornDomek";
char pass[] = "Becina300";

#define dataPin 8       // What digital pin we're connected to

// Uncomment whatever type you're using!


dht DHT;
SimpleTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.

 
void termometer()
{
  float readData = DHT.read22(dataPin); // Reads the data from the sensor
  float p = DHT.temperature; // Gets the values of the temperature
  float k = DHT.humidity; // Gets the values of the humidity
}
BLYNK_WRITE(V4) // V4 is the number of Virtual Pin  
{
  int pinValue2 = param.asInt();
}

{
  if (p > pinValue2)
  {
    digitalWrite(Thermostat, LOW);
  }
  else 
  {
    digitalWrite(Thermostat, HIGH);
  }
}



void setup()
{
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin(auth, ssid, pass);
  pinMode(Thermostat, OUTPUT);
timer.setInterval(2000L, termometer);
  // Setup a function to be called every second
  
}

void loop()
{
  Blynk.run(); // Initiates Blynk
  timer.run(); // Initiates SimpleTimer
}
{
  if (p > pinValue2)
  {
    digitalWrite(Thermostat, LOW);
  }
  else 
  {
    digitalWrite(Thermostat, HIGH);
  }
}

This code is not in a function

This function doesn't do anything with the data it collects:

void termometer()
{
  float readData = DHT.read22(dataPin); // Reads the data from the sensor
  float p = DHT.temperature; // Gets the values of the temperature
  float k = DHT.humidity; // Gets the values of the humidity
}

This function is not correctly defined, and does not return a value:

BLYNK_WRITE(V4) // V4 is the number of Virtual Pin 
{
  int pinValue2 = param.asInt();
}

jremington:
This function is not correctly defined, and does not return a value:

BLYNK_WRITE(V4) // V4 is the number of Virtual Pin 

{
 int pinValue2 = param.asInt();
}

The Blynk library is kind of "unique". The BLYNK_WRITE() 'function' is really a rather complex macro. The 'parameter' ('V4' in this case) isn't actually used by the application code. You are correct that the return value from param.asInt() is thrown away as 'pinValue2' is a local variable. OP should use a global for this.