Documentation
¶
Index ¶
- Constants
- func DeviceTrackerLocationAttributes(lat, lon, accuracy float64) map[string]interface{}
- type Client
- type Component
- type DiscoveryOptions
- type DiscoveryOptionsDevice
- type Entity
- func NewBinarySensorEntity(id string, name string, opts DiscoveryOptions) *Entity
- func NewCameraEntity(id string, name string, opts DiscoveryOptions) *Entity
- func NewCoverEntity(id string, name string, opts DiscoveryOptions) *Entity
- func NewDeviceTrackerEntity(id string, name string, opts DiscoveryOptions) *Entity
- func NewEntityWithDiscoveryOpts(id string, component Component, name string, opts DiscoveryOptions) *Entity
- func NewLightEntity(id string, name string, opts DiscoveryOptions) *Entity
- func NewSensor(id string, name string, deviceClass string, prefix TopicPrefix, ...) *Entity
- func NewSensorEntity(id string, name string, opts DiscoveryOptions) *Entity
- func NewSwitchEntity(id string, name string, opts DiscoveryOptions) *Entity
- type IconId
- type InboundCommand
- type MQTTConfig
- type MQTTConfigCredentials
- type MqttClient
- func (h *MqttClient) AutodiscoverEntities(entities ...*Entity) error
- func (h *MqttClient) PublishAttributes(entity *Entity, attributes map[string]interface{}) <-chan error
- func (h *MqttClient) PublishState(sensor *Entity, state string) <-chan error
- func (h *MqttClient) PublishTopic(sensor *Entity, payload []byte) <-chan error
- func (h *MqttClient) SubscribeForCommands(prefix TopicPrefix) (<-chan InboundCommand, error)
- type State
- type TopicPrefix
- func (t TopicPrefix) AttributesTopic(entityId string) string
- func (t TopicPrefix) CommandTopic(entityId string) string
- func (t TopicPrefix) ExtractEntityID(topicName string) string
- func (t TopicPrefix) StateTopic(entityId string) string
- func (t TopicPrefix) WildcardCommandSubscriptionPattern() string
Constants ¶
View Source
const ( DeviceClassDefault = "" DeviceClassMotion = "motion" // component=binary_sensor DeviceClassOccupancy = "occupancy" // component=binary_sensor DeviceClassDoor = "door" // component=binary_sensor DeviceClassTemperature = "temperature" // component=sensor DeviceClassHumidity = "humidity" // component=sensor DeviceClassPressure = "pressure" // component=sensor DeviceClassBattery = "battery" // component=sensor DeviceClassIlluminance = "illuminance" // component=sensor DeviceClassShade = "shade" // component=cover )
NOTE: device classes are platform-specific, i.e. "door" device class is only recognized by
binary_sensor platform
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DiscoveryOptions ¶
type DiscoveryOptions struct { Name string `json:"name"` DeviceClass string `json:"device_class,omitempty"` // https://www.home-assistant.io/integrations/binary_sensor/ | https://www.home-assistant.io/integrations/sensor/ Topic string `json:"topic,omitempty"` // *state_topic* or *topic* required StateTopic string `json:"state_topic,omitempty"` // *state_topic* or *topic* required CommandTopic string `json:"command_topic,omitempty"` // optional (unset if isn't commandable) JsonAttributesTopic string `json:"json_attributes_topic,omitempty"` ValueTemplate string `json:"value_template,omitempty"` PayloadOn interface{} `json:"payload_on,omitempty"` // can be a string describing MQTT message or a boolean indicating property value resolved by *ValueTemplate* PayloadOff interface{} `json:"payload_off,omitempty"` // same as for *on* UniqueId string `json:"unique_id,omitempty"` // really important to specify (otherwise you can't customize the entity in H-A) Icon IconId `json:"icon,omitempty"` // e.g. "mdi:gesture-double-tap" UnitOfMeasurement string `json:"unit_of_measurement,omitempty"` Schema string `json:"schema,omitempty"` // use 'json' to receive commands in JSON. only applicable for controllable things, like lights (at least not applicable for sensors) Device *DiscoveryOptionsDevice `json:"device,omitempty"` Optimistic bool `json:"optimistic,omitempty"` // whether Home Assistant just assumes that the command it sent succeeded PositionOpen *int `json:"position_open,omitempty"` PositionClosed *int `json:"position_closed,omitempty"` Brightness bool `json:"brightness,omitempty"` // can control brightness ColorTemp bool `json:"color_temp,omitempty"` // can control color temperature XY bool `json:"xy,omitempty"` // can control color }
keys: https://www.home-assistant.io/docs/mqtt/discovery/#configuration-variables many of the "omitempty" attributes are strictly required
type DiscoveryOptionsDevice ¶
type DiscoveryOptionsDevice struct { Name string `json:"name,omitempty"` Manufacturer string `json:"manufacturer,omitempty"` Model string `json:"model,omitempty"` SoftwareVersion string `json:"sw_version,omitempty"` AreaSuggested string `json:"suggested_area,omitempty"` Identifiers []string `json:"identifiers,omitempty"` }
type Entity ¶
type Entity struct { Id string // contains filtered or unexported fields }
func NewBinarySensorEntity ¶
func NewBinarySensorEntity(id string, name string, opts DiscoveryOptions) *Entity
https://www.home-assistant.io/integrations/binary_sensor.mqtt
func NewCameraEntity ¶
func NewCameraEntity(id string, name string, opts DiscoveryOptions) *Entity
func NewCoverEntity ¶
func NewCoverEntity(id string, name string, opts DiscoveryOptions) *Entity
func NewDeviceTrackerEntity ¶
func NewDeviceTrackerEntity(id string, name string, opts DiscoveryOptions) *Entity
func NewEntityWithDiscoveryOpts ¶
func NewEntityWithDiscoveryOpts( id string, component Component, name string, opts DiscoveryOptions) *Entity
func NewLightEntity ¶
func NewLightEntity(id string, name string, opts DiscoveryOptions) *Entity
func NewSensorEntity ¶
func NewSensorEntity(id string, name string, opts DiscoveryOptions) *Entity
func NewSwitchEntity ¶
func NewSwitchEntity(id string, name string, opts DiscoveryOptions) *Entity
type IconId ¶
type IconId string
const ( IconAccount IconId = "hass:account" IconAlert IconId = "hass:alert" IconAlertCircle IconId = "hass:alert-circle" IconAltimeter IconId = "hass:altimeter" IconAppleSafari IconId = "hass:apple-safari" IconApps IconId = "hass:apps" IconArrowBottomLeft IconId = "hass:arrow-bottom-left" IconArrowDown IconId = "hass:arrow-down" IconArrowLeft IconId = "hass:arrow-left" IconArrowRight IconId = "hass:arrow-right" IconArrowTopRight IconId = "hass:arrow-top-right" IconArrowUp IconId = "hass:arrow-up" IconAutorenew IconId = "hass:autorenew" IconBattery IconId = "hass:battery" IconBatteryAlert IconId = "hass:battery-alert" IconBlinds IconId = "hass:blinds" IconBatteryMinus IconId = "hass:battery-" IconBatteryOutline IconId = "hass:battery-outline" IconBatteryUnknown IconId = "hass:battery-unknown" IconBell IconId = "hass:bell" IconBellOutline IconId = "hass:bell-outline" IconBellPlus IconId = "hass:bell-plus" IconBellRing IconId = "hass:bell-ring" IconBellSleep IconId = "hass:bell-sleep" IconBookmark IconId = "hass:bookmark" IconBrightness IconId = "hass:brightness-" IconBrightness5 IconId = "hass:brightness-5" IconBroom IconId = "hass:broom" IconCalendar IconId = "hass:calendar" IconCalendarClock IconId = "hass:calendar-clock" IconCancel IconId = "hass:cancel" IconCast IconId = "hass:cast" IconCastConnected IconId = "hass:cast-connected" IconChartLine IconId = "hass:chart-line" IconCheck IconId = "hass:check" IconCheckCircleOutline IconId = "hass:check-circle-outline" IconCheckboxMarkedCircle IconId = "hass:checkbox-marked-circle" IconChevronDown IconId = "hass:chevron-down" IconChevronLeft IconId = "hass:chevron-left" IconChevronRight IconId = "hass:chevron-right" IconChevronUp IconId = "hass:chevron-up" IconClock IconId = "hass:clock" IconClockFast IconId = "hass:clock-fast" IconClose IconId = "hass:close" IconCloudUpload IconId = "hass:cloud-upload" IconCodeTags IconId = "hass:code-tags" IconCog IconId = "hass:cog" IconCommentAlert IconId = "hass:comment-alert" IconContentSave IconId = "hass:content-save" IconCropPortrait IconId = "hass:crop-portrait" IconCursorPointer IconId = "hass:cursor-pointer" IconDelete IconId = "hass:delete" IconDoorClosed IconId = "hass:door-closed" IconDoorOpen IconId = "hass:door-open" IconDotsHorizontal IconId = "hass:dots-horizontal" IconDotsVertical IconId = "hass:dots-vertical" IconDrawing IconId = "hass:drawing" IconEmoticon IconId = "hass:emoticon" IconEmoticonDead IconId = "hass:emoticon-dead" IconEmoticonPoop IconId = "hass:emoticon-poop" IconExitToApp IconId = "hass:exit-to-app" IconEye IconId = "hass:eye" IconEyeOff IconId = "hass:eye-off" IconFan IconId = "hass:fan" IconFileDocument IconId = "hass:file-document" IconFileMultiple IconId = "hass:file-multiple" IconFileWordBox IconId = "hass:file-word-box" IconFileXml IconId = "hass:file-xml" IconFilterVariant IconId = "hass:filter-variant" IconFire IconId = "hass:fire" IconFlash IconId = "hass:flash" IconFlashOff IconId = "hass:flash-off" IconFlower IconId = "hass:flower" IconFormatListBulleted IconId = "hass:format-list-bulleted" IconGarage IconId = "hass:garage" IconGarageOpen IconId = "hass:garage-open" IconGauge IconId = "hass:gauge" IconGoogleCirclesCommunities IconId = "hass:google-circles-communities" IconGooglePages IconId = "hass:google-pages" IconHammer IconId = "hass:hammer" IconHelpCircle IconId = "hass:help-circle" IconHome IconId = "hass:home" IconHomeAssistant IconId = "hass:home-assistant" IconHomeAutomation IconId = "hass:home-automation" IconHomeMapMarker IconId = "hass:home-map-marker" IconHomeOutline IconId = "hass:home-outline" IconHomeVariant IconId = "hass:home-variant" IconImageFilterCenterFocus IconId = "hass:image-filter-center-focus" IconImageFilterFrames IconId = "hass:image-filter-frames" IconInformationOutline IconId = "hass:information-outline" IconLeaf IconId = "hass:leaf" IconLightbulb IconId = "hass:lightbulb" IconLink IconId = "hass:link" IconLock IconId = "hass:lock" IconLockOpen IconId = "hass:lock-open" IconLoginVariant IconId = "hass:login-variant" IconMailbox IconId = "hass:mailbox" IconMapMarker IconId = "hass:map-marker" IconMenu IconId = "hass:menu" IconMenuDown IconId = "hass:menu-down" IconMenuUp IconId = "hass:menu-up" IconMicrophone IconId = "hass:microphone" IconMusicNote IconId = "hass:music-note" IconMusicNoteOff IconId = "hass:music-note-off" IconNature IconId = "hass:nature" IconNotificationClearAll IconId = "hass:notification-clear-all" IconOpenInNew IconId = "hass:open-in-new" IconOriginalIcon IconId = "hass:original-icon" IconPalette IconId = "hass:palette" IconPause IconId = "hass:pause" IconPencil IconId = "hass:pencil" IconPencilOff IconId = "hass:pencil-off" IconPlay IconId = "hass:play" IconPlayPause IconId = "hass:play-pause" IconPlaylistPlay IconId = "hass:playlist-play" IconPlus IconId = "hass:plus" IconPlusCircle IconId = "hass:plus-circle" IconPollBox IconId = "hass:poll-box" IconPower IconId = "hass:power" IconPowerPlug IconId = "hass:power-plug" IconPowerPlugOff IconId = "hass:power-plug-off" IconPowerSleep IconId = "hass:power-sleep" IconRadioTower IconId = "hass:radio-tower" IconRadioboxBlank IconId = "hass:radiobox-blank" IconRayVertex IconId = "hass:ray-vertex" IconRefresh IconId = "hass:refresh" IconRemote IconId = "hass:remote" IconRobotVacuum IconId = "hass:robot-vacuum" IconRotateLeft IconId = "hass:rotate-left" IconRotateRight IconId = "hass:rotate-right" IconRun IconId = "hass:run" IconSecurity IconId = "hass:security" IconSend IconId = "hass:send" IconServerNetwork IconId = "hass:server-network" IconServerNetworkOff IconId = "hass:server-network-off" IconSettings IconId = "hass:settings" IconShieldCheck IconId = "hass:shield-check" IconShieldHome IconId = "hass:shield-home" IconShieldLock IconId = "hass:shield-lock" IconShieldOutline IconId = "hass:shield-outline" IconSkipNext IconId = "hass:skip-next" IconSkipPrevious IconId = "hass:skip-previous" IconSleep IconId = "hass:sleep" IconSnowflake IconId = "hass:snowflake" IconSpeaker IconId = "hass:speaker" IconSquare IconId = "hass:square" IconSquareOutline IconId = "hass:square-outline" IconStop IconId = "hass:stop" IconTargetVariant IconId = "hass:target-variant" IconTablet IconId = "hass:tablet" IconTelevision IconId = "hass:television" IconTelevisionBox IconId = "hass:television-box" IconTelevisionOff IconId = "hass:television-off" IconTextToSpeech IconId = "hass:text-to-speech" IconTextbox IconId = "hass:textbox" IconThermometer IconId = "hass:thermometer" IconThermostat IconId = "hass:thermostat" IconTimer IconId = "hass:timer" IconMonitor IconId = "hass:monitor" IconTimerOff IconId = "hass:timer-off" IconTimerSand IconId = "hass:timer-sand" IconTooltipAccount IconId = "hass:tooltip-account" IconUndo IconId = "hass:undo" IconUserIcon IconId = "hass:user-icon" IconVibrate IconId = "hass:vibrate" IconVideo IconId = "hass:video" IconViewDashboard IconId = "hass:view-dashboard" IconVolumeHigh IconId = "hass:volume-high" IconVolumeMedium IconId = "hass:volume-medium" IconVolumeMinus IconId = "hass:volume-minus" IconVolumeOff IconId = "hass:volume-off" IconVolumePlus IconId = "hass:volume-plus" IconWalk IconId = "hass:walk" IconWater IconId = "hass:water" IconWaterOff IconId = "hass:water-off" IconWaterPercent IconId = "hass:water-percent" IconWeatherCloudy IconId = "hass:weather-cloudy" IconWeatherFog IconId = "hass:weather-fog" IconWeatherHail IconId = "hass:weather-hail" IconWeatherLightning IconId = "hass:weather-lightning" IconWeatherLightningRainy IconId = "hass:weather-lightning-rainy" IconWeatherNight IconId = "hass:weather-night" IconWeatherPartlycloudy IconId = "hass:weather-partlycloudy" IconWeatherPouring IconId = "hass:weather-pouring" IconWeatherRainy IconId = "hass:weather-rainy" IconWeatherSnowy IconId = "hass:weather-snowy" IconWeatherSnowyRainy IconId = "hass:weather-snowy-rainy" IconWeatherSunny IconId = "hass:weather-sunny" IconWeatherWindy IconId = "hass:weather-windy" IconWeatherWindyVariant IconId = "hass:weather-windy-variant" IconWhiteBalanceSunny IconId = "hass:white-balance-sunny" IconWindowClosed IconId = "hass:window-closed" IconWindowOpen IconId = "hass:window-open" IconZWave IconId = "hass:z-wave" )
type InboundCommand ¶
type MQTTConfig ¶
type MQTTConfig struct { Address string `json:"address"` Credentials *MQTTConfigCredentials `json:"credentials"` }
func (MQTTConfig) Valid ¶
func (m MQTTConfig) Valid() error
type MQTTConfigCredentials ¶
type MqttClient ¶
type MqttClient struct {
// contains filtered or unexported fields
}
sends data to Home Assistant over a MQTT broker
func NewMQTTClient ¶
func NewMQTTClient( mqttConf MQTTConfig, clientId string, logl *logex.Leveled, ) (*MqttClient, task)
func (*MqttClient) AutodiscoverEntities ¶
func (h *MqttClient) AutodiscoverEntities(entities ...*Entity) error
func (*MqttClient) PublishAttributes ¶
func (h *MqttClient) PublishAttributes(entity *Entity, attributes map[string]interface{}) <-chan error
func (*MqttClient) PublishState ¶
func (h *MqttClient) PublishState(sensor *Entity, state string) <-chan error
func (*MqttClient) PublishTopic ¶
func (h *MqttClient) PublishTopic(sensor *Entity, payload []byte) <-chan error
func (*MqttClient) SubscribeForCommands ¶
func (h *MqttClient) SubscribeForCommands(prefix TopicPrefix) (<-chan InboundCommand, error)
type TopicPrefix ¶
type TopicPrefix struct {
// contains filtered or unexported fields
}
func NewTopicPrefix ¶
func NewTopicPrefix(prefix string) TopicPrefix
func (TopicPrefix) AttributesTopic ¶
func (t TopicPrefix) AttributesTopic(entityId string) string
func (TopicPrefix) CommandTopic ¶
func (t TopicPrefix) CommandTopic(entityId string) string
func (TopicPrefix) ExtractEntityID ¶
func (t TopicPrefix) ExtractEntityID(topicName string) string
func (TopicPrefix) StateTopic ¶
func (t TopicPrefix) StateTopic(entityId string) string
func (TopicPrefix) WildcardCommandSubscriptionPattern ¶
func (t TopicPrefix) WildcardCommandSubscriptionPattern() string
Click to show internal directories.
Click to hide internal directories.