|
2 | 2 | -- Licensed under the Apache License, Version 2.0 |
3 | 3 |
|
4 | 4 | local test = require "integration_test" |
| 5 | +local capabilities = require "st.capabilities" |
5 | 6 | local t_utils = require "integration_test.utils" |
6 | 7 | local clusters = require "st.zigbee.zcl.clusters" |
7 | 8 | local zigbee_test_utils = require "integration_test.zigbee_test_utils" |
@@ -53,14 +54,30 @@ local mock_vimar_device = test.mock_device.build_test_zigbee_device( |
53 | 54 | } |
54 | 55 | ) |
55 | 56 |
|
| 57 | +local mock_climax_device = test.mock_device.build_test_zigbee_device( |
| 58 | + { profile = t_utils.get_profile_definition("switch-power-smartplug.yml"), |
| 59 | + fingerprinted_endpoint_id = 0x01, |
| 60 | + zigbee_endpoints = { |
| 61 | + [1] = { |
| 62 | + id = 1, |
| 63 | + manufacturer = "ClimaxTechnology", |
| 64 | + model = "PSM_00.00.00.35TC", |
| 65 | + server_clusters = {0x0006, 0x0B04, 0x0702} |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | +) |
| 70 | + |
56 | 71 |
|
57 | 72 | zigbee_test_utils.prepare_zigbee_env_info() |
58 | 73 |
|
59 | 74 | local function test_init() |
60 | 75 | mock_device:set_field("_configuration_version", 1, {persist = true}) |
| 76 | + mock_climax_device:set_field("_configuration_version", 1, {persist = true}) |
61 | 77 | test.mock_device.add_test_device(mock_device) |
62 | 78 | test.mock_device.add_test_device(mock_aurora_relay_device) |
63 | 79 | test.mock_device.add_test_device(mock_vimar_device) |
| 80 | + test.mock_device.add_test_device(mock_climax_device) |
64 | 81 | end |
65 | 82 |
|
66 | 83 | test.set_test_init_function(test_init) |
@@ -316,5 +333,182 @@ test.register_coroutine_test( |
316 | 333 | } |
317 | 334 | ) |
318 | 335 |
|
| 336 | +test.register_message_test( |
| 337 | + "Climax ActivePower should apply multiplier and divisor", |
| 338 | + { |
| 339 | + { |
| 340 | + channel = "zigbee", |
| 341 | + direction = "receive", |
| 342 | + message = { |
| 343 | + mock_climax_device.id, |
| 344 | + ElectricalMeasurement.attributes.ACPowerMultiplier:build_test_attr_report(mock_climax_device, 3) |
| 345 | + } |
| 346 | + }, |
| 347 | + { |
| 348 | + channel = "zigbee", |
| 349 | + direction = "receive", |
| 350 | + message = { |
| 351 | + mock_climax_device.id, |
| 352 | + ElectricalMeasurement.attributes.ACPowerDivisor:build_test_attr_report(mock_climax_device, 10) |
| 353 | + } |
| 354 | + }, |
| 355 | + { |
| 356 | + channel = "zigbee", |
| 357 | + direction = "receive", |
| 358 | + message = { |
| 359 | + mock_climax_device.id, |
| 360 | + ElectricalMeasurement.attributes.ActivePower:build_test_attr_report(mock_climax_device, 20) |
| 361 | + } |
| 362 | + }, |
| 363 | + { |
| 364 | + channel = "capability", |
| 365 | + direction = "send", |
| 366 | + message = mock_climax_device:generate_test_message( |
| 367 | + "main", |
| 368 | + capabilities.powerMeter.power({ value = 6.0, unit = "W" }) |
| 369 | + ) |
| 370 | + } |
| 371 | + }, |
| 372 | + { |
| 373 | + min_api_version = 14, |
| 374 | + max_api_version = 14 |
| 375 | + } |
| 376 | +) |
| 377 | + |
| 378 | +test.register_message_test( |
| 379 | + "Climax ActivePower should apply multiplier and divisor with native registration", |
| 380 | + { |
| 381 | + { |
| 382 | + channel = "zigbee", |
| 383 | + direction = "receive", |
| 384 | + message = { |
| 385 | + mock_climax_device.id, |
| 386 | + ElectricalMeasurement.attributes.ACPowerMultiplier:build_test_attr_report(mock_climax_device, 3) |
| 387 | + } |
| 388 | + }, |
| 389 | + { |
| 390 | + channel = "zigbee", |
| 391 | + direction = "receive", |
| 392 | + message = { |
| 393 | + mock_climax_device.id, |
| 394 | + ElectricalMeasurement.attributes.ACPowerDivisor:build_test_attr_report(mock_climax_device, 10) |
| 395 | + } |
| 396 | + }, |
| 397 | + { |
| 398 | + channel = "zigbee", |
| 399 | + direction = "receive", |
| 400 | + message = { |
| 401 | + mock_climax_device.id, |
| 402 | + ElectricalMeasurement.attributes.ActivePower:build_test_attr_report(mock_climax_device, 20) |
| 403 | + } |
| 404 | + }, |
| 405 | + { |
| 406 | + channel = "capability", |
| 407 | + direction = "send", |
| 408 | + message = mock_climax_device:generate_test_message( |
| 409 | + "main", |
| 410 | + capabilities.powerMeter.power({ value = 6.0, unit = "W" }) |
| 411 | + ) |
| 412 | + }, |
| 413 | + { |
| 414 | + channel = "devices", |
| 415 | + direction = "send", |
| 416 | + message = { |
| 417 | + "register_native_capability_attr_handler", |
| 418 | + { |
| 419 | + device_uuid = mock_climax_device.id, |
| 420 | + capability_id = "powerMeter", |
| 421 | + capability_attr_id = "power" |
| 422 | + } |
| 423 | + } |
| 424 | + } |
| 425 | + }, |
| 426 | + { |
| 427 | + min_api_version = 15 |
| 428 | + } |
| 429 | +) |
| 430 | + |
| 431 | +test.register_message_test( |
| 432 | + "Climax InstantaneousDemand should convert kilowatts to watts", |
| 433 | + { |
| 434 | + { |
| 435 | + channel = "zigbee", |
| 436 | + direction = "receive", |
| 437 | + message = { |
| 438 | + mock_climax_device.id, |
| 439 | + SimpleMetering.attributes.Multiplier:build_test_attr_report(mock_climax_device, 1) |
| 440 | + } |
| 441 | + }, |
| 442 | + { |
| 443 | + channel = "zigbee", |
| 444 | + direction = "receive", |
| 445 | + message = { |
| 446 | + mock_climax_device.id, |
| 447 | + SimpleMetering.attributes.Divisor:build_test_attr_report(mock_climax_device, 1000) |
| 448 | + } |
| 449 | + }, |
| 450 | + { |
| 451 | + channel = "zigbee", |
| 452 | + direction = "receive", |
| 453 | + message = { |
| 454 | + mock_climax_device.id, |
| 455 | + SimpleMetering.attributes.InstantaneousDemand:build_test_attr_report(mock_climax_device, 800) |
| 456 | + } |
| 457 | + }, |
| 458 | + { |
| 459 | + channel = "capability", |
| 460 | + direction = "send", |
| 461 | + message = mock_climax_device:generate_test_message( |
| 462 | + "main", |
| 463 | + capabilities.powerMeter.power({ value = 800.0, unit = "W" }) |
| 464 | + ) |
| 465 | + } |
| 466 | + }, |
| 467 | + { |
| 468 | + min_api_version = 14 |
| 469 | + } |
| 470 | +) |
| 471 | + |
| 472 | +test.register_message_test( |
| 473 | + "Climax InstantaneousDemand should apply multiplier", |
| 474 | + { |
| 475 | + { |
| 476 | + channel = "zigbee", |
| 477 | + direction = "receive", |
| 478 | + message = { |
| 479 | + mock_climax_device.id, |
| 480 | + SimpleMetering.attributes.Multiplier:build_test_attr_report(mock_climax_device, 2) |
| 481 | + } |
| 482 | + }, |
| 483 | + { |
| 484 | + channel = "zigbee", |
| 485 | + direction = "receive", |
| 486 | + message = { |
| 487 | + mock_climax_device.id, |
| 488 | + SimpleMetering.attributes.Divisor:build_test_attr_report(mock_climax_device, 1000) |
| 489 | + } |
| 490 | + }, |
| 491 | + { |
| 492 | + channel = "zigbee", |
| 493 | + direction = "receive", |
| 494 | + message = { |
| 495 | + mock_climax_device.id, |
| 496 | + SimpleMetering.attributes.InstantaneousDemand:build_test_attr_report(mock_climax_device, 800) |
| 497 | + } |
| 498 | + }, |
| 499 | + { |
| 500 | + channel = "capability", |
| 501 | + direction = "send", |
| 502 | + message = mock_climax_device:generate_test_message( |
| 503 | + "main", |
| 504 | + capabilities.powerMeter.power({ value = 1600.0, unit = "W" }) |
| 505 | + ) |
| 506 | + } |
| 507 | + }, |
| 508 | + { |
| 509 | + min_api_version = 14 |
| 510 | + } |
| 511 | +) |
| 512 | + |
319 | 513 |
|
320 | 514 | test.run_registered_tests() |
0 commit comments