Files
archived-hipudding-teslamate/lib/teslamate/mqtt/handler.ex
2024-03-16 11:55:04 +01:00

28 lines
589 B
Elixir

defmodule TeslaMate.Mqtt.Handler do
use Tortoise311.Handler
require Logger
@impl true
def connection(:up, state) do
Logger.info("MQTT connection has been established")
{:ok, state}
end
def connection(:down, state) do
Logger.warning("MQTT connection has been dropped")
{:ok, state}
end
def connection(:terminating, state) do
Logger.warning("MQTT connection is terminating")
{:ok, state}
end
@impl true
def terminate(reason, _state) do
Logger.warning("MQTT Client has been terminated with reason: #{inspect(reason)}")
:ok
end
end