intesis

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 9 Imported by: 0

README

intesis

Interface to control and monitor Intesis adapters (Mitsubishi Air Conditioning systems) with Go.

Usage example

package main

import (
	"context"
	"github.com/and3rson/intesis"
)

func main() {
	intesisManager := intesis.NewManager()
	intesisManager.AddDevice(intesis.NewDevice("ac_one", "192.168.1.101"))
	intesisManager.AddDevice(intesis.NewDevice("ac_two", "192.168.1.102"))
	intesisManager.AddDevice(intesis.NewDevice("ac_three", "192.168.1.103"))
	intesisManager.Run()

	// Set a datapoint
	intesisManager.Devices[0].Set(intesis.UserSetpoint, 250) // Set temperature to 25.0°C
	intesisManager.Devices[1].Set(intesis.OnOff, 1) // Turn on

	for {
		select {
		case event := <-intesisManager.Events:
			// Handle event
			fmt.Printf("Got event: device=%s, datapoint=%s\n", event.Device.Name, event.Datapoint)
		}
	}
}

Documentation

Overview

Interface to control and monitor Intesis adapters (Mitsubishi Air Conditioning systems).

Usage example:

package main

import (
	"context"
	"github.com/and3rson/intesis"
)

func main() {
	intesisManager := intesis.NewManager()
	intesisManager.AddDevice(intesis.NewDevice("ac_one", "192.168.1.101"))
	intesisManager.AddDevice(intesis.NewDevice("ac_two", "192.168.1.102"))
	intesisManager.AddDevice(intesis.NewDevice("ac_three", "192.168.1.103"))
	intesisManager.Run()

	// Set a datapoint
	intesisManager.Devices[0].Set(intesis.UserSetpoint, 250) // Set temperature to 25.0°C
	intesisManager.Devices[1].Set(intesis.OnOff, 1) // Turn on

	for {
		select {
		case event := <-intesisManager.Events:
			// Handle event
			fmt.Printf("Got event: device=%s, datapoint=%s\n", event.Device.Name, event.Datapoint)
		}
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datapoint

type Datapoint struct {
	// UID of the datapoint (see DatapointUID)
	UID DatapointUID `mapstructure:"uid"`
	// Value of the datapoint
	Value int `mapstructure:"value"`
	// Status of the datapoint (?) (not used)
	Status int `mapstructure:"status"`
}

Datapoint struct

func (Datapoint) Compare

func (dp Datapoint) Compare(other Datapoint) bool

Compare compares two datapoints

func (Datapoint) Name

func (dp Datapoint) Name() string

Name returns the name of the datapoint

func (Datapoint) String

func (dp Datapoint) String() string

String returns a string representation of the datapoint

type DatapointUID

type DatapointUID int

Enum of datapoint UIDs

const (
	OnOff                   DatapointUID = 1
	UserMode                DatapointUID = 2
	FanSpeed                DatapointUID = 4
	VaneUpDown              DatapointUID = 5
	UserSetpoint            DatapointUID = 9
	ReturnPathTemperture    DatapointUID = 10
	RemoteDisable           DatapointUID = 12
	OnTime                  DatapointUID = 13
	AlarmStatus             DatapointUID = 14
	ErrorCode               DatapointUID = 15
	MinTemperatureSetpoint  DatapointUID = 35
	MaxTemperatureSetpoint  DatapointUID = 36
	OutoorTemperature       DatapointUID = 37
	MaintenanceTime         DatapointUID = 181
	MaintenanceConfig       DatapointUID = 182
	MaintenanceFilterTime   DatapointUID = 183
	MaintenanceFilterConfig DatapointUID = 184
)

type Device

type Device struct {
	// Name of the device
	Name string

	// Datapoints
	Datapoints map[DatapointUID]Datapoint
	// Events channel: receives events when a datapoint changes
	Events chan Event
	// contains filtered or unexported fields
}

Device struct represents an Intesis device

func NewDevice

func NewDevice(name string, host string) *Device

NewDevice creates a new Device

func (*Device) Run

func (dev *Device) Run(ctx context.Context, wg *sync.WaitGroup)

Run starts polling the device When a datapoint changes, it sends an event to the Events channel.

func (*Device) Set

func (dev *Device) Set(ctx context.Context, uid DatapointUID, value int) error

Set sets a datapoint value

type Event

type Event struct {
	// Device that produced the event
	Device *Device
	// New datapoint value
	Datapoint Datapoint
}

Event struct represents an event produced by the device

type Manager

type Manager struct {
	// Array of devices
	Devices []*Device
	// Events channel: receives events from all devices
	Events chan Event
}

Manager struct is a convenience manager for multiple Intesis devices that collects events from all devices

func NewManager

func NewManager() *Manager

NewManager creates a new Manager

func (*Manager) AddDevice

func (man *Manager) AddDevice(device *Device)

AddDevice adds a device to the manager

func (*Manager) Run

func (man *Manager) Run(ctx context.Context, wg *sync.WaitGroup)

Run starts polling all devices When a datapoint changes, it sends an event to the Events channel.

type Response

type Response struct {
	Success bool `json:"success"`
	Error   struct {
		Message string `json:"message"`
	} `json:"error"`
	Data map[string]interface{} `json:"data"`
}

Response struct represents the payload of the API response

Jump to

Keyboard shortcuts

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