Skip to content

Commit

Permalink
fix state value template for home assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetancollaud committed Dec 17, 2023
1 parent de0ae0c commit ff414f2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/api/devices.http
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @no-cookie-jar
GET {{host}}/api/v1/apartment/dsDevices?includeAll=true
GET {{host}}/api/v1/apartment/dsDevices
Authorization: Bearer {{api-key}}

###
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/modules/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func (c *DeviceModule) GetHomeAssistantEntities() ([]homeassistant.DiscoveryConf
c.deviceStateTopic(device.Attributes.Name, lightOutput.OutputId))
entityConfig.BrightnessCommandTopic = c.mqttClient.GetFullTopic(
c.deviceCommandTopic(device.Attributes.Name, lightOutput.OutputId))
entityConfig.StateValueTemplate = "{% if value|int > 0 %}100.00{% else %}0.00{% endif %}"
}
cfg = homeassistant.DiscoveryConfig{
Domain: homeassistant.Light,
Expand Down
1 change: 1 addition & 0 deletions pkg/homeassistant/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type LightConfig struct {
BaseConfig
CommandTopic string `json:"command_topic,omitempty"`
StateTopic string `json:"state_topic,omitempty"`
StateValueTemplate string `json:"state_value_template,omitempty"`
PayloadOn string `json:"payload_on,omitempty"`
PayloadOff string `json:"payload_off,omitempty"`
OnCommandType string `json:"on_command_type,omitempty"`
Expand Down

0 comments on commit ff414f2

Please sign in to comment.