J1605 is a switch hub with 16 relays can be controlled on TCP.
If available in Hex, the package can be installed
by adding j1605
to your list of dependencies in mix.exs
:
def deps do
[{:j1605, "~> 0.2.0"}]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/j1605.
use Mix.Config
config :j1605,
device: [
address: "192.168.1.250",
port: 2000
]
- Subscribe the switch events:
J1605.subscribe()
- Receive the switch states:
{:states, {true, true, false, false, false, false, false, false,
true, false, false, false, false, false, false, false}}
- Turn on a switch:
J1605.turn_on(0) # between 0 and 15
- Turn off a switch:
J1605.turn_off(0) # between 0 and 15
- Update states:
J1605.update_states()