teslanotify

package module
v0.0.0-...-8cca078 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 4 Imported by: 0

README

teslanotify | Receive notifications when car state changes

Simple addon to TeslaMate that uses ntfy.sh to notify when car state changes.

Usage

Environment Variables
Variable  Description Default
DEBUG Outputs more verbose logging if set to 1. 0
NTFY_URL ntfy instance. https://ntfy.sh/
NTFY_TOPIC ntfy topic. You want to change this. teslas
NTFY_MSG Notification message template. This is the message your notification device receives. Car is {{.State}}
MQTT_HOST The host of the TeslaMate MQTT server. moquitto
MQTT_PORT The port of the TeslaMate MQTT server. 1883
TESLA_STATES Comma separated list of states to notify about. Can be charging, driving, suspended, online or offline charging
TESLA_CAR_ID The TeslaMate ID of the car. 1
Setup

To use together with TeslaMate under docker-compose, you can add this to the services section of your docker-compose file. A prebuilt image of this repo is available on Docker Hub.

services:

  teslanotify:
    image: hnesland/teslanotify:latest
    restart: always
    environment:
      - NTFY_TOPIC=secret_tesla_topic
      - TESLA_STATES=charging

Or you can run the binary anywhere you like, it reads configuration from the environment variables like above.

Build the binary with go build -o teslanotify ./cmd/teslanotify and run it like:

export NTFY_TOPIC=secret_tesla_topic
export MQTT_HOST=127.0.0.1
export MQTT_PORT=1883
export TESLA_STATES=charging
export DEBUG=1
./teslanotify

Documentation

Index

Constants

View Source
const (
	TeslaMateCarState = "teslamate/cars/%d/state"
)

Variables

View Source
var (
	ErrMQTTHostMissing = errors.New("MQTT host missing")
	ErrMQTTPortMissing = errors.New("MQTT port missing")
)

Functions

This section is empty.

Types

type Service

type Service struct {
	Debug         bool
	Log           *log.Logger
	MQTTHost      string
	MQTTPort      string
	CarID         int
	OnStateChange func(state string) error
}

func (*Service) Connect

func (s *Service) Connect() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL