test_ble_smartplant.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """
  2. Test BLE smart plant sensor.
  3. Primarily for testing the refresh button used in this device, which is
  4. made by sending the temperature unit as the current setting so as to
  5. give the device a command to initiate a data transmission without actually
  6. changing anything.
  7. """
  8. from ..const import BLE_SMARTPLANT_PAYLOAD
  9. from ..helpers import assert_device_properties_set
  10. from .base_device_tests import TuyaDeviceTestCase
  11. MOISTURE_DP = "3"
  12. TEMPERATURE_DP = "5"
  13. TEMPERATURE_UNIT_DP = "9"
  14. BATTERY_STATE_DP = "14"
  15. BATTERY_DP = "15"
  16. class TestBleSmartPlant(TuyaDeviceTestCase):
  17. __test__ = True
  18. def setUp(self):
  19. self.setUpForConfig(
  20. "ble_smart_plant_moisture.yaml",
  21. BLE_SMARTPLANT_PAYLOAD,
  22. )
  23. self.refresh_button = self.entities.get("button_refresh")
  24. self.mark_secondary(
  25. [
  26. "sensor_battery",
  27. "select_temperature_unit",
  28. "button_refresh",
  29. ]
  30. )
  31. async def test_refresh_logic(self):
  32. self.dps[TEMPERATURE_UNIT_DP] = "c"
  33. async with assert_device_properties_set(
  34. self.refresh_button._device,
  35. {TEMPERATURE_UNIT_DP: "c"},
  36. ):
  37. await self.refresh_button.async_press()
  38. self.dps[TEMPERATURE_UNIT_DP] = "f"
  39. async with assert_device_properties_set(
  40. self.refresh_button._device,
  41. {TEMPERATURE_UNIT_DP: "f"},
  42. ):
  43. await self.refresh_button.async_press()