update
This commit is contained in:
@@ -20,6 +20,7 @@ type HADevice struct {
|
||||
// SwitchDiscovery represents Home Assistant MQTT switch discovery config
|
||||
// Reference: https://www.home-assistant.io/integrations/switch.mqtt/
|
||||
type SwitchDiscovery struct {
|
||||
Platform string `json:"platform"`
|
||||
Name string `json:"name"`
|
||||
CommandTopic string `json:"command_topic"`
|
||||
StateTopic string `json:"state_topic"`
|
||||
@@ -38,6 +39,7 @@ type SwitchDiscovery struct {
|
||||
// SensorDiscovery represents Home Assistant MQTT sensor discovery config
|
||||
// Reference: https://www.home-assistant.io/integrations/sensor.mqtt/
|
||||
type SensorDiscovery struct {
|
||||
Platform string `json:"platform"`
|
||||
Name string `json:"name"`
|
||||
StateTopic string `json:"state_topic"`
|
||||
UniqueID string `json:"unique_id"`
|
||||
@@ -79,6 +81,7 @@ func (c *Client) PublishDeviceDiscovery(deviceID int) error {
|
||||
}
|
||||
|
||||
discovery := SwitchDiscovery{
|
||||
Platform: "mqtt",
|
||||
Name: device.Name,
|
||||
CommandTopic: fmt.Sprintf("telldus/device/%d/set", deviceID),
|
||||
StateTopic: fmt.Sprintf("telldus/device/%d/state", deviceID),
|
||||
@@ -162,6 +165,7 @@ func (c *Client) publishSensorDiscoveryForSensor(sensor *datastore.Sensor, dataT
|
||||
|
||||
if dataTypes&telldus.DataTypeTemperature != 0 && sensor.TemperatureUniqueID != "" {
|
||||
discovery := SensorDiscovery{
|
||||
Platform: "mqtt",
|
||||
Name: fmt.Sprintf("%s Temperature", sensor.Name),
|
||||
StateTopic: fmt.Sprintf("telldus/sensor/%s/%s/%d/temperature", sensor.Protocol, sensor.Model, sensor.ID),
|
||||
UniqueID: sensor.TemperatureUniqueID,
|
||||
@@ -182,6 +186,7 @@ func (c *Client) publishSensorDiscoveryForSensor(sensor *datastore.Sensor, dataT
|
||||
|
||||
if dataTypes&telldus.DataTypeHumidity != 0 && sensor.HumidityUniqueID != "" {
|
||||
discovery := SensorDiscovery{
|
||||
Platform: "mqtt",
|
||||
Name: fmt.Sprintf("%s Humidity", sensor.Name),
|
||||
StateTopic: fmt.Sprintf("telldus/sensor/%s/%s/%d/humidity", sensor.Protocol, sensor.Model, sensor.ID),
|
||||
UniqueID: sensor.HumidityUniqueID,
|
||||
|
||||
Reference in New Issue
Block a user