add readme, set env var for android build

few tweaks for readability
This commit is contained in:
Aaron Bieber 2024-09-25 08:06:18 -06:00
parent 1494131dfa
commit fb3924ad8b
No known key found for this signature in database
4 changed files with 27 additions and 13 deletions

1
.envrc
View File

@ -1 +1,2 @@
use flake
export ANDROID_NDK_HOME=~/Android/Sdk/ndk/27.1.12297006

View File

@ -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
View 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]]

31
main.go
View File

@ -33,13 +33,17 @@ func loadData(h *hass.Access, lightCards *[]fyne.CanvasObject, switchCards *[]fy
for entity := range lights {
e := lights[entity]
card := makeEntity(e, h)
*lightCards = append(*lightCards, card)
if card != nil {
*lightCards = append(*lightCards, card)
}
}
for entity := range switches {
e := switches[entity]
card := makeEntity(e, h)
*switchCards = append(*switchCards, card)
if card != nil {
*switchCards = append(*switchCards, card)
}
}
}
@ -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)