Class: MideaAirCondition::Client
- Inherits:
-
Object
- Object
- MideaAirCondition::Client
- Defined in:
- lib/client.rb
Overview
Client for Midea AC server
Constant Summary collapse
- SERVER_URL =
'https://mapp.appsmb.com/v1'
- CLIENT_TYPE =
Android
1
- FORMAT =
JSON
2
- LANGUAGE =
'en_US'
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
Instance Method Summary collapse
- #appliance_list ⇒ Object
- #appliance_transparent_send(appliance_id, data) ⇒ Object
-
#initialize(email, password, app_key:, app_id: 1017, src: 17) ⇒ Client
constructor
A new instance of Client.
- #login ⇒ Object
- #new_packet_builder ⇒ Object
Constructor Details
#initialize(email, password, app_key:, app_id: 1017, src: 17) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/client.rb', line 18 def initialize(email, password, app_key:, app_id: 1017, src: 17) @app_id = app_id @src = src @email = email @password = password @app_key = app_key @debug = false @security = Security.new(app_key: @app_key) @current = nil end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
16 17 18 |
# File 'lib/client.rb', line 16 def debug @debug end |
Instance Method Details
#appliance_list ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/client.rb', line 43 def appliance_list response = api_request( 'appliance/list/get', homegroupId: default_home['id'] ) response['list'] end |
#appliance_transparent_send(appliance_id, data) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/client.rb', line 51 def appliance_transparent_send(appliance_id, data) response = api_request( 'appliance/transparent/send', order: encode(@security.transcode(data).join(',')), funId: '0000', applianceId: appliance_id ) response = decode(response['reply']).split(',').map { |p| p.to_i & 0xff } response end |
#login ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/client.rb', line 31 def login login_id = user_login_id_get['loginId'] encrypted_password = @security.encrypt_password(@password, login_id) @current = api_request( 'user/login', loginAccount: @email, password: encrypted_password ) @security.access_token = @current['accessToken'] end |
#new_packet_builder ⇒ Object
64 65 66 |
# File 'lib/client.rb', line 64 def new_packet_builder PacketBuilder.new(@security) end |