|
| 1 | +"""Verify that init() calls the expected set of endpoints for each Daikin device.""" |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from pydaikin.daikin_skyfi import DaikinSkyFi |
| 6 | + |
| 7 | +from .test_init import client_session |
| 8 | + |
| 9 | +assert client_session |
| 10 | + |
| 11 | + |
| 12 | +@pytest.mark.asyncio |
| 13 | +async def test_daikinSkiFi(aresponses, client_session): |
| 14 | + aresponses.add( |
| 15 | + path_pattern="/zones.cgi", |
| 16 | + method_pattern="GET", |
| 17 | + response="nz=8&zone1=Zone%201&zone2=Zone%202&zone3=Zone%203&zone4=Zone%204&zone5=Zone%205&zone6=Zone%206&zone7=Zone%207&zone8=Zone%208", |
| 18 | + ) |
| 19 | + aresponses.add( |
| 20 | + path_pattern="/ac.cgi", |
| 21 | + method_pattern="GET", |
| 22 | + response="opmode=0&units=.&settemp=24.0&fanspeed=3&fanflags=3&acmode=16&tonact=0&toffact=0&prog=0&time=23:36&day=6&roomtemp=23&outsidetemp=0&louvre=1&zone=0&flt=0&test=0&errdata=146&sensors=1", |
| 23 | + ) |
| 24 | + |
| 25 | + device = DaikinSkyFi('ip', session=client_session, password="xxxpasswordxxx") |
| 26 | + |
| 27 | + await device.init() |
| 28 | + |
| 29 | + aresponses.assert_all_requests_matched() |
| 30 | + aresponses.assert_no_unused_routes() |
| 31 | + |
| 32 | + assert device["mode"] == '16' |
| 33 | + assert device.support_away_mode is False |
| 34 | + assert device.support_fan_rate is True |
| 35 | + assert device.support_swing_mode is False |
| 36 | + assert device.represent("zone1") == ("zone1", "Zone 1") |
| 37 | + assert device.represent("zone") == ('zone', '00000000') |
| 38 | + assert device.inside_temperature == 23.0 |
| 39 | + assert device.target_temperature == 24.0 |
| 40 | + assert device.outside_temperature == 0 |
| 41 | + |
| 42 | + assert device.represent("mode") == ('mode', 'off') |
| 43 | + |
| 44 | + aresponses.add( |
| 45 | + path_pattern="/ac.cgi", |
| 46 | + method_pattern="GET", |
| 47 | + response="opmode=0&units=.&settemp=20.0&fanspeed=3&fanflags=1&acmode=16&tonact=0&toffact=0&prog=0&time=23:36&day=6&roomtemp=23&outsidetemp=0&louvre=1&zone=0&flt=0&test=0&errdata=146&sensors=1", |
| 48 | + ) |
| 49 | + aresponses.add( |
| 50 | + path_pattern="/set.cgi", |
| 51 | + method_pattern="GET", |
| 52 | + response="opmode=1&units=.&settemp=20.0&fanspeed=3&fanflags=1&acmode=8&tonact=0&toffact=0&prog=0&time=23:36&day=6&roomtemp=23&outsidetemp=0&louvre=1&zone=0&flt=0&test=0&errdata=146&sensors=1", |
| 53 | + ) |
| 54 | + |
| 55 | + await device.set({"mode": "cool"}) |
| 56 | + aresponses.assert_all_requests_matched() |
| 57 | + assert device.represent("mode") == ('mode', 'cool') |
| 58 | + assert device.target_temperature == 20.0 |
| 59 | + |
| 60 | + aresponses.add( |
| 61 | + path_pattern="/ac.cgi", |
| 62 | + method_pattern="GET", |
| 63 | + response="opmode=1&units=.&settemp=20.0&fanspeed=3&fanflags=1&acmode=8&tonact=0&toffact=0&prog=0&time=23:36&day=6&roomtemp=23&outsidetemp=0&louvre=1&zone=0&flt=0&test=0&errdata=146&sensors=1", |
| 64 | + ) |
| 65 | + aresponses.add( |
| 66 | + path_pattern="/set.cgi", |
| 67 | + method_pattern="GET", |
| 68 | + response="opmode=0&units=.&settemp=20.0&fanspeed=3&fanflags=1&acmode=8&tonact=0&toffact=0&prog=0&time=23:36&day=6&roomtemp=23&outsidetemp=0&louvre=1&zone=0&flt=0&test=0&errdata=146&sensors=1", |
| 69 | + ) |
| 70 | + await device.set({"mode": "off"}) |
| 71 | + assert device.zones == [ |
| 72 | + ('Zone 1', '0'), |
| 73 | + ('Zone 2', '0'), |
| 74 | + ('Zone 3', '0'), |
| 75 | + ('Zone 4', '0'), |
| 76 | + ('Zone 5', '0'), |
| 77 | + ('Zone 6', '0'), |
| 78 | + ('Zone 7', '0'), |
| 79 | + ('Zone 8', '0'), |
| 80 | + ] |
| 81 | + |
| 82 | + await device.set_zone(0, "zone_onoff_", 1) |
| 83 | + aresponses.add( |
| 84 | + path_pattern="/setzone.cgi", |
| 85 | + method_pattern="GET", |
| 86 | + response="opmode=0&units=.&settemp=20.0&fanspeed=3&fanflags=1&acmode=8&tonact=0&toffact=0&prog=0&time=23:36&day=6&roomtemp=23&outsidetemp=0&louvre=1&zone=128&flt=0&test=0&errdata=146&sensors=1", |
| 87 | + ) |
| 88 | + await device.set_zone(0, "zone_onoff", 1) |
0 commit comments