smartrent / grizzly

Elixir Z-Wave Library

Home Page:https://hex.pm/packages/grizzly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aggregate Report Check Name

mattludwigs opened this issue · comments

Currently, the aggregate report handler does not guard against the name of the incoming report: https://github.com/smartrent/grizzly/blob/main/lib/grizzly/command_handlers/aggregate_report.ex#L31.

This can cause issues when the same node has a different command sent the same time.

iex(15)> thermostat_id=22
22
iex(16)> Grizzly.send_command(thermostat_id, :association_get)
** (exit) exited in: GenServer.call({:via, Registry, {Grizzly.ConnectionRegistry, 22}}, {:send_command, %Grizzly.ZWave.Command{command_byte: 2, command_class: Grizzly.ZWave.CommandClasses.Association, impl: Grizzly.ZWave.Commands.AssociationGet, name: :association_get, params: []}, 22, [handler: {Grizzly.CommandHandlers.AggregateReport, [complete_report: :association_report, aggregate_param: :nodes]}]}, 140000)
    ** (EXIT) exited in: GenServer.call(#PID<0.3282.0>, {:handle_zip_command, %Grizzly.ZWave.Command{command_byte: 2, command_class: Grizzly.ZWave.CommandClasses.ZIP, impl: Grizzly.ZWave.Commands.ZIPPacket, name: :zip_packet, params: [seq_number: 54, source: 0, dest: 0, secure: false, header_extensions: [encapsulation_format_info: [:non_secure]], command: %Grizzly.ZWave.Command{command_byte: 18, command_class: Grizzly.ZWave.CommandClasses.Version, impl: Grizzly.ZWave.Commands.VersionReport, name: :version_report, params: [library_type: :routing_slave, protocol_version: "4.5", firmware_version: "1.0", hardware_version: 1, other_firmware_versions: ["2.16"]]}, flag: nil]}}, 5000)
        ** (EXIT) an exception was raised:
            ** (KeyError) It looks like you tried to get the :reports_to_follow from your command.
Here is a list of available params for your command:
  * :library_type
  * :protocol_version
  * :firmware_version
  * :hardware_version
  * :other_firmware_versions
                (grizzly 0.14.4) lib/grizzly/zwave/command.ex:87: Grizzly.ZWave.Command.param!/2
                (grizzly 0.14.4) lib/grizzly/command_handlers/aggregate_report.ex:31: Grizzly.CommandHandlers.AggregateReport.handle_command/2
                (grizzly 0.14.4) lib/grizzly/commands/command.ex:171: Grizzly.Commands.Command.do_handle_zip_command/2
                (grizzly 0.14.4) lib/grizzly/commands/command_runner.ex:64: Grizzly.Commands.CommandRunner.handle_call/3
                (stdlib 3.13) gen_server.erl:706: :gen_server.try_handle_call/4
                (stdlib 3.13) gen_server.erl:735: :gen_server.handle_msg/6
                (stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
    (elixir 1.10.4) lib/gen_server.ex:1023: GenServer.call/3

If the report that is coming in this handler is different then the expected one we should return {:continue, state}