Git Product home page Git Product logo

hap's People

Contributors

dependabot[bot] avatar hermanverschooten avatar hez avatar mtrudel avatar optikfluffel avatar petermm avatar philipgiuliani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hap's Issues

Bandit terminating with missing :opts key

Hi,
I updated my dependencies in a Nerves project where I am using HAP successfully.
With the update it also upgraded 'ThousandIlands and Bandit, now in my nerves device Bandit crashes with

05:39:15.703 [error] GenServer #PID<0.2062.0> terminating
** (KeyError) key :opts not found in: %{plug: {HAP.HTTPServer, []}}
    (bandit 0.7.5) lib/bandit/http1/handler.ex:18: Bandit.HTTP1.Handler.handle_data/3
    (hap 0.4.7) /Users/herman/Projects/garage/deps/thousand_island/lib/thousand_island/handler.ex:343: HAP.HAPSessionHandler.handle_info/2
    (stdlib 4.3) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.3) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:tcp, #Port<0.307>, <<80, 79, 83, 84, 32, 47, 112, 97, 105, 114, 45, 118, 101, 114, 105, 102, 121, 32, 72, 84, 84, 80, 47, 49, 46, 49, 13, 10, 72, 111, 115, 116, 58, 32, 72, 101, 114, 109, 97, 110, 39, 115, 92, 48, 51, 50, 71, ...>>}
State: {%ThousandIsland.Socket{socket: #Port<0.307>, transport_module: HAP.HAPSessionTransport, read_timeout: 60000, span: %ThousandIsland.Telemetry{span_name: :connection, telemetry_span_context: #Reference<0.3405112061.268435457.195241>, start_time: 1779255243708, start_metadata: %{parent_telemetry_span_context: #Reference<0.3405112061.268435457.182629>, remote_address:
 {192, 168, 17, 65}, remote_port: 60529, telemetry_span_context: #Reference<0.3405112061.268435457.195241>}}}, %{plug: {HAP.HTTPServer, []}}}

I tried with the current master version, where I noticed you updated the child spec for Bandit, and that works.
Could you please release a new version?

Thanks,
Herman

Summary of services implemented

This is a long term issue tracking which services are implemented:
(the number in parenthesis is a quick count of the characteristics used by the service)

  • 8.1 Accessory Information
  • 8.2 Air Purifier (5)
  • 8.3 Air quality sensor (9)
  • 8.4 Audio Stream Management (2)
  • 8.5 Battery service (3)
  • 8.6 Camera RTP Stream Management (6)
  • 8.7 Carbon dioxide sensor (3)
  • 8.8 Carbon monoxide sensor (3)
  • 8.9 Contact sensor
  • 8.10 Data Stream Transport Management (3)
  • 8.11 Door (4)
  • 8.12 Doorbell (4)
  • 8.13 Fan (3)
  • 8.13 Fan V2 (7)
  • 8.14 Faucet (0)
  • 8.15 Filter Maintenance (3)
  • 8.16 Garage Door Opener (5)
  • 8.17 HAP Protocol Information
  • 8.18 Heater cooler
  • 8.19 Humidifier dehumidifier (9)
  • 8.20 Humidity sensor
  • 8.21 Irrigation System (3)
  • 8.22 Leak sensor
  • 8.23 Lightbulb
  • 8.24 Light sensor
  • 8.25 Lock Management (7)
  • 8.26 Lock mechanism (2)
  • 8.27 Microphone (2)
  • 8.28 Motion sensor
  • 8.29 Occupancy sensor
  • 8.30 Outlet
  • 8.31 Security system (3)
  • 8.32 Service Label (1)
  • 8.33 Siri (1)
  • 8.34 Slat (5)
  • 8.35 Smoke sensor (1)
  • 8.36 Speaker (2)
  • 8.37 Stateless Programmable Switch (2)
  • 8.38 Switch
  • 8.39 Target Control (2)
  • 8.40 Target Control Management (2)
  • 8.41 Temperature sensor
  • 8.42 Thermostat (8) (Timed write support is supported, but timeouts are not enforced)
  • 8.43 Valve (6)
  • 8.44 Window
  • 8.45 Window covering
  • Television (12)

Outlet service receiving `0`, `1`, `false` for its `:on` characteristic

The Outlet service has a required on characteristic which is labelled as type bool.

Issue

In my testing it received all of these values, 0 1 false to the put_value/2 on my accessory.

Reproducing

I have a simple implementation of an outlet which here

Steps

  1. exlixir install, mix deps.get, mix compile, etc
  2. Run with CEC_ADDRESS=0 iex -S mix
  3. Add the accessory to your Home
  4. Turning on and off the outlet from Home app, will call put_value(0 | 1, :on)
  5. Create an automation where the outlet will automaticly turn off after some time (1min!) and put_value(false, :on) will be called.

Pairing Accessory is failing

Hi,

I am trying to use this library, but I am unable to pair with the Apple Home app on the iPhone. I followed the demo code. First, if I use the latest hex.pm package (0.4.8), ThousandIsland refuses to start because HAP.HAPSessionTransport.sockname/1 is undefined or private. I noticed this was fixed in the recent commits, so I used the git repo in mix.exs instead.

Now, when I try to pair, Apple Home does request details (as visible in the console), but the HAP.PairSetup GenServer crashes due to bad IV length.

Here are the logs:

12:42:54.688 [info] POST /pair-setup

12:42:54.698 [info] Sent 200 in 9ms

12:42:54.751 [info] POST /pair-setup

12:42:54.752 [info] Sent 200 in 1ms

12:42:54.758 [info] POST /pair-setup

12:42:54.761 [error] GenServer HAP.PairSetup terminating
** (stop) {:badarg, {~c"aead.c", 111}, ~c"Bad IV length"}
    (crypto 5.2) crypto.erl:1023: :crypto.crypto_one_time_aead(:chacha20_poly1305, <<140, 134, 89, 123, 121, 178, 138, 33, 27, 220, 164, 31, 200, 248, 154, 52, 178, 117, 38, 128, 158, 119, 53, 41, 228, 79, 0, 123, 2, 90, 19, 142>>, "PS-Msg05", <<142, 52, 148, 112, 87, 220, 56, 54, 225, 232, 91, 209, 194, 240, 6, 138, 18, 142, 101, 140, 36, 61, 108, 156, 5, 170, 90, 213, 64, 203, 101, 216, 34, 224, 19, 185, 58, 129, 84, 154, 58, 171, 121, 190, 205, 111, 10, 141, 32, 5, ...>>, "", <<151, 111, 233, 169, 209, 103, 60, 53, 218, 80, 101, 129, 96, 93, 141, 149>>, false)
    (hap 0.4.8) lib/hap/crypto/cha_cha_20.ex:24: HAP.Crypto.ChaCha20.decrypt_and_verify/4
    (hap 0.4.8) lib/hap/pair_setup.ex:97: HAP.PairSetup.handle_call/3
    (stdlib 5.0.2) gen_server.erl:1113: :gen_server.try_handle_call/4
    (stdlib 5.0.2) gen_server.erl:1142: :gen_server.handle_msg/6
    (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

I tried experimenting with the :crypto.crypto_one_time_aead function, but every variation I try gives me the same Bad IV Length error, even though the lengths described in the Erlang manual are what I'm using.

I am using a Mac with Elixir installed from brew. I also tried it in a ARM Alpine Linux VM, and it gave the same error.

Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]

Elixir 1.15.7 (compiled with Erlang/OTP 26)
OpenSSL 3.1.4 24 Oct 2023 (Library: OpenSSL 3.1.4 24 Oct 2023)

I'm guessing I'm doing something wrong, or there's some recent bug?

Also, slightly off-topic, but I cannot find the HomeKit Accessory Protocol Specification PDF anywhere. Did Apple remove it? Their help pages say it's available for hobbyists, but I can't find it anywhere on their website.

Failing to start HAP.HAPSessionTransport.sockname/1 with ThousandIsland 1.x

There has been an update to ThousandIsland, I have 0.6.7 and the recent Phoenix update brought in 1.2.0 which causes the HAPSessionTransport to fail to start with:

** (Mix) Could not start application home_hub: HomeHub.Application.start(:normal, []) returned an error: shutdown: failed to start child: HomeHub.HAP.Supervisor
    ** (EXIT) shutdown: failed to start child: HAP
        ** (EXIT) shutdown: failed to start child: {Bandit, #Reference<0.1159261075.658505729.90071>}
            ** (EXIT) shutdown: failed to start child: :listener
                ** (EXIT) an exception was raised:
                    ** (UndefinedFunctionError) function HAP.HAPSessionTransport.sockname/1 is undefined or private
                        (hap 0.4.8) HAP.HAPSessionTransport.sockname(#Port<0.19>)
                        (thousand_island 1.2.0) lib/thousand_island/listener.ex:34: ThousandIsland.Listener.init/1
                        (stdlib 5.1.1) gen_server.erl:962: :gen_server.init_it/2
                        (stdlib 5.1.1) gen_server.erl:917: :gen_server.init_it/6
                        (stdlib 5.1.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

How to send a notify

Hi,
I am very impressed with your HAP library.
I added it to an existing nerves project and I can turn on/off my light with my iPhone. Nice!
But I also have another way to turn on the light.
I would like to reflect the current state of the light in my Home app.
Can you tell me how I can do this?
eg, If I turn on the light using put_value from the console, do I then need to send something, somewhere, somehow?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.