Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

122 add color codes for uv index #136

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions app/campaign/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,14 @@ def get_current_mean(dimension):

# Temperatur
current_temperature = get_current_mean(Dimension.TEMPERATURE)
temperature_color = Dimension.get_color(Dimension.TEMPERATURE, current_temperature) if current_temperature else None
temperature_color = Dimension.get_color(Dimension.TEMPERATURE, current_temperature) if current_temperature is not None else None

# VOC Index
current_uvi = get_current_mean(Dimension.UVS)
uvi_color = Dimension.get_color(Dimension.UVS, current_uvi) if current_uvi else None

current_uvi = get_current_mean(Dimension.UVI)
uvi_color = Dimension.get_color(Dimension.UVI, current_uvi) if current_uvi is not None else None

# dimensions to be displayed
target_dimensions = (Dimension.TEMPERATURE, Dimension.UVS)
target_dimensions = (Dimension.TEMPERATURE, Dimension.UVI)
time_range = timedelta(days=1)
start_time = datetime.now(timezone.utc) - time_range

Expand Down Expand Up @@ -374,10 +373,10 @@ def get_current_mean(dimension):
labels = [(start_time + timedelta(minutes=i)).strftime("%H:%M") for i in range(int(time_range.total_seconds() // 60))]

# Werte ins Context-Objekt packen
context['current_temperature'] = f'{current_temperature:.2f}' if current_temperature else None
context['current_temperature'] = f'{current_temperature:.2f}' if current_temperature is not None else None
context['temperature_color'] = temperature_color
context['current_tvoc'] = f'{current_uvi:.2f}' if current_uvi else None
context['tvoc_color'] = uvi_color
context['current_uvi'] = f'{current_uvi:.2f}' if current_uvi is not None else None
context['uvi_color'] = uvi_color
context['data_24h'] = np.nan_to_num(data_24h, nan=0).tolist()
context['labels'] = labels

Expand Down
44 changes: 35 additions & 9 deletions app/main/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class SensorModel():
PMS5003 = 16
PMS7003 = 17
VIRTUAL_SENSOR = 18
LTR390 = 19
BMP388 = 20
BMP390 = 21
LSM6DS = 22

_names = {
SEN5X: "SEN5X",
Expand All @@ -55,6 +59,10 @@ class SensorModel():
PMS5003: "PMS5003",
PMS7003: "PMS7003",
VIRTUAL_SENSOR: "VIRTUAL_SENSOR",
LTR390: "LTR390",
BMP388: 'BMP388',
BMP390: 'BMP390',
LSM6DS: 'lsm6ds',
}

_manufacturer = {
Expand Down Expand Up @@ -125,17 +133,23 @@ class Dimension():
ADJUSTED_TEMP_CUBE = 19
UVS = 20
LIGHT = 21
ACCELERATION = 22
GYRO = 23
ALTITUDE = 24

ALTITUDE = 22
UVI = 23
LUX = 24
ACCELERATION_X = 25
ACCELERATION_Y = 26
ACCELERATION_Z = 27
GYRO_X = 28
GYRO_Y = 29
GYRO_Z = 30

thresholds = {
TEMPERATURE: ([18, 24], [Color.BLUE, Color.GREEN, Color.RED]),
PM2_5: ([5, 15], [Color.GREEN, Color.YELLOW, Color.RED]),
TVOC: ([220, 1430], [Color.GREEN, Color.YELLOW, Color.RED]),
CO2: ([800, 1000, 1400], [Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED]),
ADJUSTED_TEMP_CUBE: ([18, 24], [Color.BLUE, Color.GREEN, Color.RED]),
UVI: ([3, 6, 8, 11], [Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED, Color.PURPLE])
}

# Dictionary für die Einheiten der Dimensionen
Expand All @@ -159,8 +173,14 @@ class Dimension():
SGP40_RAW_GAS: "Ω",
SGP40_ADJUSTED_GAS: "Ω",
ADJUSTED_TEMP_CUBE: "°C",
ACCELERATION: "m/s²",
GYRO: "radians/s"
ACCELERATION_X: "m/s²",
ACCELERATION_Y: "m/s²",
ACCELERATION_Z: "m/s²",
GYRO_X: "radians/s",
GYRO_Y: "radians/s",
GYRO_Z: "radians/s",
UVI: "UV Index",
LUX: "lx"
}

_names = {
Expand All @@ -185,12 +205,18 @@ class Dimension():
ADJUSTED_TEMP_CUBE: "Adjusted Temperature Air Cube",
UVS: "UVS",
LIGHT: "Light",
ACCELERATION: "acceleration",
GYRO: "gyro"
ACCELERATION_X: "acceleration X",
ACCELERATION_Y: "acceleration Y",
ACCELERATION_Z: "acceleration Z",
GYRO_X: "gyro X",
GYRO_Y: "gyro Y",
GYRO_Z: "gyro Z",
UVI: "UV Index",
LUX: "Lux"
}

_required_sensors = {
ADJUSTED_TEMP_CUBE: set([SensorModel.AHT20, SensorModel.SHT4X, SensorModel.SEN5X])
ADJUSTED_TEMP_CUBE: set([SensorModel.SHT4X, SensorModel.SEN5X])
}

_sensor_community_names = {
Expand Down
Loading