11import 'package:chopper/chopper.dart' ;
2+ import 'package:color/color.dart' ;
23
4+ import 'models/blind_state.dart' ;
5+ import 'models/color_defaults.dart' ;
6+ import 'models/device.dart' ;
37import 'models/device_list.dart' ;
48import 'models/device_stats.dart' ;
9+ import 'models/energy.dart' ;
510import 'models/hkr_temperature.dart' ;
11+ import 'models/level.dart' ;
612import 'models/percentage.dart' ;
13+ import 'models/power.dart' ;
14+ import 'models/subscription_state.dart' ;
715import 'models/switch_action.dart' ;
16+ import 'models/switch_duration.dart' ;
817import 'models/temperature.dart' ;
18+ import 'models/timestamp.dart' ;
919
1020part 'aha_service.chopper.dart' ;
1121
@@ -15,14 +25,20 @@ abstract class AhaService extends ChopperService {
1525
1626 static AhaService create ([ChopperClient ? client]) => _$AhaService (client);
1727
18- // all devices
28+ // all devices / global
1929
2030 @Get (path: '$_baseUrl =getdevicelistinfos' )
2131 Future <Response <DeviceList >> getDeviceListInfos ();
2232
33+ @Get (path: '$_baseUrl =getdeviceinfos' )
34+ Future <Response <Device >> getDeviceInfos (@Query () String ain);
35+
2336 @Get (path: '$_baseUrl =getbasicdevicestats' )
2437 Future <Response <DeviceStats >> getBasicDeviceStats (@Query () String ain);
2538
39+ @Get (path: '$_baseUrl =setname' )
40+ Future <Response <void >> setName (@Query () String ain, @Query () String name);
41+
2642 // switches
2743
2844 @Get (path: '$_baseUrl =getswitchlist' )
@@ -43,13 +59,12 @@ abstract class AhaService extends ChopperService {
4359 @Get (path: '$_baseUrl =getswitchpresent' )
4460 Future <Response <bool >> getSwitchPresent (@Query () String ain);
4561
46- /// Returns the power in mW
4762 @Get (path: '$_baseUrl =getswitchpower' )
48- Future <Response <int ?>> getSwitchPower (@Query () String ain);
63+ Future <Response <Power ?>> getSwitchPower (@Query () String ain);
4964
5065 /// Returns the energy in Wh
5166 @Get (path: '$_baseUrl =getswitchenergy' )
52- Future <Response <int ?>> getSwitchEnergy (@Query () String ain);
67+ Future <Response <Energy ?>> getSwitchEnergy (@Query () String ain);
5368
5469 @Get (path: '$_baseUrl =getswitchname' )
5570 Future <Response <String >> getSwitchName (@Query () String ain);
@@ -73,9 +88,21 @@ abstract class AhaService extends ChopperService {
7388 @Get (path: '$_baseUrl =sethkrtsoll' )
7489 Future <Response <void >> setHkrTSoll (
7590 @Query () String ain,
76- @Query ('param' ) HkrTemperature temperature ,
91+ @Query () HkrTemperature param ,
7792 );
7893
94+ @Get (path: '$_baseUrl =sethkrboost' )
95+ Future <Response <Timestamp >> setHkrBoost (
96+ @Query () String ain, [
97+ @Query ('endtimestamp' ) Timestamp endTimestamp = Timestamp .deactivated,
98+ ]);
99+
100+ @Get (path: '$_baseUrl =sethkrwindowopen' )
101+ Future <Response <Timestamp >> setHkrWindowOpen (
102+ @Query () String ain, [
103+ @Query ('endtimestamp' ) Timestamp endTimestamp = Timestamp .deactivated,
104+ ]);
105+
79106 // templates
80107
81108 // @Get(path: '$_baseUrl=gettemplatelistinfos')
@@ -92,13 +119,71 @@ abstract class AhaService extends ChopperService {
92119 @Query ('onoff' ) SwitchAction onOff,
93120 );
94121
95- /// Level must be [0, 255]
122+ // level controllable
123+
96124 @Get (path: '$_baseUrl =setlevel' )
97- Future <Response <void >> setLevel (@Query () String ain, @Query () int level);
125+ Future <Response <void >> setLevel (@Query () String ain, @Query () Level level);
98126
99127 @Get (path: '$_baseUrl =setlevelpercentage' )
100128 Future <Response <void >> setLevelPercentage (
101129 @Query () String ain,
102130 @Query () Percentage level,
103131 );
132+
133+ // light bulbs
134+
135+ @Get (path: '$_baseUrl =setcolor' )
136+ Future <Response <void >> _setColor (
137+ @Query () String ain, {
138+ @Query () required int hue,
139+ @Query () required int saturation,
140+ @Query () required SwitchDuration duration,
141+ });
142+
143+ Future <Response <void >> setColorHs (
144+ String ain,
145+ HsvColor color,
146+ SwitchDuration duration,
147+ ) =>
148+ _setColor (
149+ ain,
150+ hue: color.h.round (),
151+ saturation: color.s.round (),
152+ duration: duration,
153+ );
154+
155+ Future <Response <void >> setColorV (
156+ String ain,
157+ HsvColor color,
158+ ) =>
159+ setLevel (
160+ ain,
161+ Percentage (rawValue: color.v.round ()).toLevel (),
162+ );
163+
164+ @Get (path: '$_baseUrl =setcolortemperature' )
165+ Future <Response <void >> setColorTemperature (
166+ @Query () String ain,
167+ @Query () int temperature,
168+ @Query () SwitchDuration duration,
169+ );
170+
171+ @Get (path: '$_baseUrl =getcolordefaults' )
172+ Future <Response <ColorDefaults >> getColorDefaults ();
173+
174+ // blinds
175+
176+ @Get (path: '$_baseUrl =setblind' )
177+ Future <Response <void >> setBlind (
178+ @Query () String ain,
179+ @Query () BlindState target,
180+ );
181+
182+ // device registration
183+
184+ @Get (path: '$_baseUrl =startulesubscription' )
185+ Future <Response <void >> startUleSubscription ();
186+
187+ @Get (path: '$_baseUrl =getsubscriptionstate' )
188+ Future <Response <State >> getSubscriptionState ();
104189}
0 commit comments