Skip to content

Commit

Permalink
Schedule Criteria: weather "clear sky" condition does not match (#3487)
Browse files Browse the repository at this point in the history
relates to xibosignage/xibo#3487

- Fixed the formatting of weather condition values.
- Set the `type` criteria as the prefix for the metric's value
  • Loading branch information
nadzpogi committed Oct 2, 2024
1 parent c1b4017 commit 94f7506
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
35 changes: 17 additions & 18 deletions lib/Connector/OpenWeatherMapConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,26 +665,26 @@ public function onScheduleCriteriaRequest(ScheduleCriteriaRequestInterface $even
{
// Initialize Open Weather Schedule Criteria parameters
$event->addType('weather', __('Weather'))
->addMetric('weather_condition', __('Weather Condition'))
->addMetric('condition', __('Weather Condition'))
->addValues('dropdown', [
'Thunderstorm' => __('Thunderstorm'),
'Drizzle' => __('Drizzle'),
'Rain' => __('Rain'),
'Snow' => __('Snow'),
'Clear' => __('Clear'),
'Clouds' => __('Clouds')
'thunderstorm' => __('Thunderstorm'),
'drizzle' => __('Drizzle'),
'rain' => __('Rain'),
'snow' => __('Snow'),
'clear' => __('Clear'),
'clouds' => __('Clouds')
])
->addMetric('weather_temp_imperial', __('Temperature (Imperial)'))
->addMetric('temp_imperial', __('Temperature (Imperial)'))
->addValues('number', [])
->addMetric('weather_temp_metric', __('Temperature (Metric)'))
->addMetric('temp_metric', __('Temperature (Metric)'))
->addValues('number', [])
->addMetric('weather_feels_like_imperial', __('Apparent Temperature (Imperial)'))
->addMetric('feels_like_imperial', __('Apparent Temperature (Imperial)'))
->addValues('number', [])
->addMetric('weather_feels_like_metric', __('Apparent Temperature (Metric)'))
->addMetric('feels_like_metric', __('Apparent Temperature (Metric)'))
->addValues('number', [])
->addMetric('weather_wind_speed', __('Wind Speed'))
->addMetric('wind_speed', __('Wind Speed'))
->addValues('number', [])
->addMetric('weather_wind_direction', __('Wind Direction'))
->addMetric('wind_direction', __('Wind Direction'))
->addValues('dropdown', [
'N' => __('North'),
'NE' => __('Northeast'),
Expand All @@ -695,13 +695,13 @@ public function onScheduleCriteriaRequest(ScheduleCriteriaRequestInterface $even
'W' => __('West'),
'NW' => __('Northwest'),
])
->addMetric('weather_wind_degrees', __('Wind Direction (degrees)'))
->addMetric('wind_degrees', __('Wind Direction (degrees)'))
->addValues('number', [])
->addMetric('weather_humidity', __('Humidity (Percent)'))
->addMetric('humidity', __('Humidity (Percent)'))
->addValues('number', [])
->addMetric('weather_pressure', __('Pressure'))
->addMetric('pressure', __('Pressure'))
->addValues('number', [])
->addMetric('weather_visibility', __('Visibility (meters)'))
->addMetric('visibility', __('Visibility (meters)'))
->addValues('number', []);
}

Expand Down Expand Up @@ -738,7 +738,6 @@ private function processXmdsWeatherData($item, $unit, $requestUnit): array
$data['weather_temp_metric'] = round($tempMetric, 0);
$data['weather_feels_like_metric'] = round($apparentTempMetric, 0);


// Humidity
$data['weather_humidity'] = $item['humidity'];

Expand Down
2 changes: 1 addition & 1 deletion lib/Xmds/Soap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ protected function doSchedule($serverKey, $hardwareKey, $options = [])

foreach ($schedule->criteria as $scheduleCriteria) {
$criteriaNode = $scheduleXml->createElement('criteria');
$criteriaNode->setAttribute('metric', $scheduleCriteria->metric);
$criteriaNode->setAttribute('metric', $scheduleCriteria->type . '_' . $scheduleCriteria->metric);
$criteriaNode->setAttribute('condition', $scheduleCriteria->condition);
$criteriaNode->setAttribute('type', $scheduleCriteria->type);
$criteriaNode->textContent = $scheduleCriteria->value;
Expand Down

0 comments on commit 94f7506

Please sign in to comment.