Skip to content

Commit

Permalink
[virtual-thermostat-addon] Update temperature ranges (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 27, 2024
1 parent 7782257 commit a6bd8f7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
36 changes: 18 additions & 18 deletions src/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ private function createDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::CURRENT_ROOM_TEMPERATURE->value,
'channel' => $stateChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand Down Expand Up @@ -791,13 +791,13 @@ private function createDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::MAXIMUM_FLOOR_TEMPERATURE->value,
'channel' => $configurationChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [0, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [0, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
'step' => Entities\Devices\Device::PRECISION,
'value' => $maxFloorTemp,
'default' => Entities\Devices\Device::MAXIMUM_FLOOR_TEMPERATURE,
'default' => Entities\Devices\Device::MAXIMUM_SET_FLOOR_TEMPERATURE,
]),
);

Expand All @@ -808,7 +808,7 @@ private function createDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::CURRENT_FLOOR_TEMPERATURE->value,
'channel' => $stateChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [0, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [0, Entities\Devices\Device::MAXIMUM_FLOOR_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand Down Expand Up @@ -898,7 +898,7 @@ private function createDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::TARGET_ROOM_TEMPERATURE->value,
'channel' => $presetChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand All @@ -924,7 +924,7 @@ private function createDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::HEATING_THRESHOLD_TEMPERATURE->value,
'channel' => $presetChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand All @@ -947,7 +947,7 @@ private function createDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::COOLING_THRESHOLD_TEMPERATURE->value,
'channel' => $presetChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand Down Expand Up @@ -1309,7 +1309,7 @@ private function editDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::CURRENT_ROOM_TEMPERATURE->value,
'channel' => $stateChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand Down Expand Up @@ -1352,13 +1352,13 @@ private function editDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::MAXIMUM_FLOOR_TEMPERATURE->value,
'channel' => $configurationChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [0, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [0, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
'step' => Entities\Devices\Device::PRECISION,
'value' => $maxFloorTemp,
'default' => Entities\Devices\Device::MAXIMUM_FLOOR_TEMPERATURE,
'default' => Entities\Devices\Device::MAXIMUM_SET_FLOOR_TEMPERATURE,
]),
$maxFloorTempProperty,
);
Expand All @@ -1370,7 +1370,7 @@ private function editDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::CURRENT_FLOOR_TEMPERATURE->value,
'channel' => $stateChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [0, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [0, Entities\Devices\Device::MAXIMUM_FLOOR_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand Down Expand Up @@ -1487,7 +1487,7 @@ private function editDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::TARGET_ROOM_TEMPERATURE->value,
'channel' => $presetChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand All @@ -1513,7 +1513,7 @@ private function editDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::HEATING_THRESHOLD_TEMPERATURE->value,
'channel' => $presetChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand All @@ -1536,7 +1536,7 @@ private function editDevice(Style\SymfonyStyle $io): void
'identifier' => Types\ChannelPropertyIdentifier::COOLING_THRESHOLD_TEMPERATURE->value,
'channel' => $presetChannel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand Down Expand Up @@ -2698,7 +2698,7 @@ private function editPreset(Style\SymfonyStyle $io, Entities\Devices\Device $dev
'identifier' => Types\ChannelPropertyIdentifier::TARGET_ROOM_TEMPERATURE->value,
'channel' => $channel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand All @@ -2718,7 +2718,7 @@ private function editPreset(Style\SymfonyStyle $io, Entities\Devices\Device $dev
'identifier' => Types\ChannelPropertyIdentifier::HEATING_THRESHOLD_TEMPERATURE->value,
'channel' => $channel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand All @@ -2736,7 +2736,7 @@ private function editPreset(Style\SymfonyStyle $io, Entities\Devices\Device $dev
'identifier' => Types\ChannelPropertyIdentifier::COOLING_THRESHOLD_TEMPERATURE->value,
'channel' => $channel,
'dataType' => MetadataTypes\DataType::FLOAT,
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_TEMPERATURE],
'format' => [Entities\Devices\Device::MINIMUM_TEMPERATURE, Entities\Devices\Device::MAXIMUM_SET_ROOM_TEMPERATURE],
'unit' => null,
'invalid' => null,
'scale' => null,
Expand Down Expand Up @@ -3556,7 +3556,7 @@ private function askMaxFloorTemperature(
'//virtual-thermostat-addon.cmd.install.questions.provide.maximumFloorTemperature',
['unit' => $unit->value],
),
$device?->getMaximumFloorTemp() ?? Entities\Devices\Device::MAXIMUM_FLOOR_TEMPERATURE,
$device?->getMaximumFloorTemp() ?? Entities\Devices\Device::MAXIMUM_SET_FLOOR_TEMPERATURE,
);
$question->setValidator(function (string|int|null $answer): float {
if ($answer === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Channels/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getMaximumFloorTemp(): float
return floatval($property->getValue());
}

return Entities\Devices\Device::MAXIMUM_FLOOR_TEMPERATURE;
return Entities\Devices\Device::MAXIMUM_SET_FLOOR_TEMPERATURE;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/Entities/Devices/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ class Device extends VirtualEntities\Devices\Device

public const MINIMUM_TEMPERATURE = 7.0;

public const MAXIMUM_TEMPERATURE = 35.0;
public const MAXIMUM_ROOM_TEMPERATURE = 1_000.0;

public const MAXIMUM_FLOOR_TEMPERATURE = 28.0;
public const MAXIMUM_FLOOR_TEMPERATURE = 1_000.0;

public const MAXIMUM_SET_ROOM_TEMPERATURE = 35.0;

public const MAXIMUM_SET_FLOOR_TEMPERATURE = 30.0;

public const TARGET_TEMPERATURE = 20.0;

Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function getMaximumFloorTemp(DevicesDocuments\Devices\Device $device): fl
);

if ($property?->getValue() === null) {
return Entities\Devices\Device::MAXIMUM_FLOOR_TEMPERATURE;
return Entities\Devices\Device::MAXIMUM_SET_FLOOR_TEMPERATURE;
}

$value = $property->getValue();
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/unit/Drivers/ThermostatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public static function processThermostatData(): array
[
'bceca543-2de7-44b1-8a33-87e9574b6731' => true, // heater_1
'd58fe894-0d1c-4bf0-bff5-a190cab20e5c' => 21.6, // target_sensor_1
'e2b98261-2a05-483d-be7c-ac3afe3888b2' => 28, // floor_sensor_1
'e2b98261-2a05-483d-be7c-ac3afe3888b2' => 31.0, // floor_sensor_1
'17627f14-ebbf-4bc1-88fd-e8fc32d3e5de' => 22.0, // target_temperature - manual
'1e196c5c-a469-4ec7-95e7-c4bb48d58fe0' => 17.0, // target_temperature - preset_away
'767ddcf6-24c5-48b0-baaa-e8c7a90d3dc0' => 20.0, // target_temperature - preset_eco
Expand Down Expand Up @@ -527,7 +527,7 @@ public static function processThermostatData(): array
'device' => '552cea8a-0e81-41d9-be2f-839b079f315e',
'channel' => 'b453987e-bbf4-46fc-830f-6448b19d9665',
'property' => 'current_floor_temperature',
'value' => 28.0,
'value' => 31.0,
'source' => MetadataTypes\Sources\Addon::VIRTUAL_THERMOSTAT->value,
],
[
Expand Down
2 changes: 1 addition & 1 deletion tests/sql/dummy.data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ IGNORE INTO `fb_devices_module_channels_properties` (`property_id`, `channel_id`
(_binary 0x1e196c5ca4694ec795e7c4bb48d58fe0, _binary 0xc55dcc2f43c84f03862ea5a2c5ba91c4, null, 'generic', 'target_room_temperature', null, 1, 1, 'float', null, '7:35', null, null, 0.1, null, null, null, '2023-10-15 11:00:00', '2023-10-15 11:00:00', 'dynamic'),
(_binary 0x767ddcf624c548b0baaae8c7a90d3dc0, _binary 0xe1cb79d9f61840ac9576258a501a98be, null, 'generic', 'target_room_temperature', null, 1, 1, 'float', null, '7:35', null, null, 0.1, null, null, null, '2023-10-15 11:00:00', '2023-10-15 11:00:00', 'dynamic'),
(_binary 0xf0b8100f5ddb4abd8015d0dbf9a11aa0, _binary 0xb453987ebbf446fc830f6448b19d9665, null, 'generic', 'preset_mode', null, 0, 1, 'enum', null, 'manual,away,eco,home', null, null, null, null, null, null, '2023-10-15 11:00:00', '2023-10-15 11:00:00', 'dynamic'),
(_binary 0xa74d06a48eb2440e8bb06ec54a0bf93c, _binary 0xb453987ebbf446fc830f6448b19d9665, null, 'generic', 'current_room_temperature', null, 0, 1, 'float', null, '7:35', null, null, 0.1, null, null, null, '2023-10-15 11:00:00', '2023-10-15 11:00:00', 'dynamic'),
(_binary 0xa74d06a48eb2440e8bb06ec54a0bf93c, _binary 0xb453987ebbf446fc830f6448b19d9665, null, 'generic', 'current_room_temperature', null, 0, 1, 'float', null, '7:1000', null, null, 0.1, null, null, null, '2023-10-15 11:00:00', '2023-10-15 11:00:00', 'dynamic'),
(_binary 0x17627f14ebbf4bc188fde8fc32d3e5de, _binary 0x62f00da6eff74ce6ac1c81523627987e, null, 'generic', 'target_room_temperature', null, 1, 1, 'float', null, '7:35', null, null, 0.1, null, null, null, '2023-10-15 11:00:00', '2023-10-15 11:00:00', 'dynamic'),
(_binary 0xa326ba38d1884eaca6ad43bdcc84a730, _binary 0xb453987ebbf446fc830f6448b19d9665, null, 'generic', 'hvac_mode', null, 1, 1, 'enum', null, 'off,heat', null, null, null, null, null, null, '2023-10-15 11:00:00', '2023-10-15 11:00:00', 'dynamic'),
(_binary 0xc07dbed51a6d4a9cbdc831fe5b77cccd, _binary 0xc2c572b3324844daaca0fd329e1d9418, null, 'generic', 'high_target_temperature_tolerance', null, 0, 0, 'float', null, null, null, null, 0.1, '0.3', null, null, '2023-10-15 11:00:00', '2023-10-15 11:00:00', 'variable'),
Expand Down

0 comments on commit a6bd8f7

Please sign in to comment.