add readme, set env var for android build
few tweaks for readability
This commit is contained in:
parent
1494131dfa
commit
fb3924ad8b
@ -5,4 +5,4 @@ Website = "https://github.com/qbit/fass"
|
||||
Name = "fass"
|
||||
ID = "dev.suah.fass"
|
||||
Version = "1.0.0"
|
||||
Build = 5
|
||||
Build = 11
|
||||
|
6
README.org
Normal file
6
README.org
Normal file
@ -0,0 +1,6 @@
|
||||
#+TITLE: fass
|
||||
|
||||
A simple [[https://fyne.io/][Fyne]] app for controlling lights and switches in your [[https://www.home-assistant.io/][Home Assistant]]
|
||||
install.
|
||||
|
||||
[[file:toggleswitch.png]]
|
27
main.go
27
main.go
@ -33,15 +33,19 @@ func loadData(h *hass.Access, lightCards *[]fyne.CanvasObject, switchCards *[]fy
|
||||
for entity := range lights {
|
||||
e := lights[entity]
|
||||
card := makeEntity(e, h)
|
||||
if card != nil {
|
||||
*lightCards = append(*lightCards, card)
|
||||
}
|
||||
}
|
||||
|
||||
for entity := range switches {
|
||||
e := switches[entity]
|
||||
card := makeEntity(e, h)
|
||||
if card != nil {
|
||||
*switchCards = append(*switchCards, card)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getDevice(id string, h *hass.Access) (hass.Device, error) {
|
||||
s, err := h.GetState(id)
|
||||
@ -52,6 +56,9 @@ func getDevice(id string, h *hass.Access) (hass.Device, error) {
|
||||
}
|
||||
|
||||
func makeEntity(e hass.State, h *hass.Access) *widget.Card {
|
||||
if e.State != "on" && e.State != "off" {
|
||||
return nil
|
||||
}
|
||||
fmt.Printf("%s: (%s) %s\n", e.EntityID,
|
||||
e.Attributes["friendly_name"],
|
||||
e.State)
|
||||
@ -70,21 +77,23 @@ func makeEntity(e hass.State, h *hass.Access) *widget.Card {
|
||||
dev.Toggle()
|
||||
})
|
||||
|
||||
return widget.NewCard("", entityName, container.NewVBox(
|
||||
card := widget.NewCard("", entityName, container.NewVBox(
|
||||
container.NewHBox(entityButton),
|
||||
))
|
||||
|
||||
card.Refresh()
|
||||
|
||||
return card
|
||||
}
|
||||
|
||||
func loadSavedData(a fyne.App, w fyne.Window, input *widget.Entry, file string) {
|
||||
uri, err := storage.Child(a.Storage().RootURI(), file)
|
||||
if err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
return
|
||||
}
|
||||
|
||||
reader, err := storage.Reader(uri)
|
||||
if err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
return
|
||||
}
|
||||
defer reader.Close()
|
||||
@ -146,7 +155,7 @@ func main() {
|
||||
|
||||
h := hass.NewAccess(urlEntry.Text, "")
|
||||
if haExists && tkExists {
|
||||
if certExists {
|
||||
if certExists && certEntry.Text != "" {
|
||||
rootCAs, _ := x509.SystemCertPool()
|
||||
if rootCAs == nil {
|
||||
rootCAs = x509.NewCertPool()
|
||||
@ -197,17 +206,15 @@ func main() {
|
||||
w.Hide()
|
||||
})
|
||||
|
||||
cols := 5
|
||||
tabs := container.NewAppTabs(
|
||||
container.NewTabItemWithIcon("Lights",
|
||||
theme.VisibilityIcon(),
|
||||
container.NewVBox(
|
||||
container.NewAdaptiveGrid(3, lightCards...),
|
||||
)),
|
||||
container.NewAdaptiveGrid(cols, lightCards...),
|
||||
),
|
||||
container.NewTabItemWithIcon("Switches",
|
||||
theme.RadioButtonIcon(),
|
||||
container.NewVBox(
|
||||
container.NewAdaptiveGrid(3, switchCards...),
|
||||
),
|
||||
container.NewAdaptiveGrid(cols, switchCards...),
|
||||
),
|
||||
)
|
||||
tabs.SetTabLocation(container.TabLocationLeading)
|
||||
|
Loading…
Reference in New Issue
Block a user