add readme, set env var for android build
few tweaks for readability
This commit is contained in:
parent
1494131dfa
commit
fb3924ad8b
1
.envrc
1
.envrc
@ -1 +1,2 @@
|
|||||||
use flake
|
use flake
|
||||||
|
export ANDROID_NDK_HOME=~/Android/Sdk/ndk/27.1.12297006
|
||||||
|
@ -5,4 +5,4 @@ Website = "https://github.com/qbit/fass"
|
|||||||
Name = "fass"
|
Name = "fass"
|
||||||
ID = "dev.suah.fass"
|
ID = "dev.suah.fass"
|
||||||
Version = "1.0.0"
|
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 {
|
for entity := range lights {
|
||||||
e := lights[entity]
|
e := lights[entity]
|
||||||
card := makeEntity(e, h)
|
card := makeEntity(e, h)
|
||||||
|
if card != nil {
|
||||||
*lightCards = append(*lightCards, card)
|
*lightCards = append(*lightCards, card)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for entity := range switches {
|
for entity := range switches {
|
||||||
e := switches[entity]
|
e := switches[entity]
|
||||||
card := makeEntity(e, h)
|
card := makeEntity(e, h)
|
||||||
|
if card != nil {
|
||||||
*switchCards = append(*switchCards, card)
|
*switchCards = append(*switchCards, card)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getDevice(id string, h *hass.Access) (hass.Device, error) {
|
func getDevice(id string, h *hass.Access) (hass.Device, error) {
|
||||||
s, err := h.GetState(id)
|
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 {
|
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,
|
fmt.Printf("%s: (%s) %s\n", e.EntityID,
|
||||||
e.Attributes["friendly_name"],
|
e.Attributes["friendly_name"],
|
||||||
e.State)
|
e.State)
|
||||||
@ -70,21 +77,23 @@ func makeEntity(e hass.State, h *hass.Access) *widget.Card {
|
|||||||
dev.Toggle()
|
dev.Toggle()
|
||||||
})
|
})
|
||||||
|
|
||||||
return widget.NewCard("", entityName, container.NewVBox(
|
card := widget.NewCard("", entityName, container.NewVBox(
|
||||||
container.NewHBox(entityButton),
|
container.NewHBox(entityButton),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
card.Refresh()
|
||||||
|
|
||||||
|
return card
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSavedData(a fyne.App, w fyne.Window, input *widget.Entry, file string) {
|
func loadSavedData(a fyne.App, w fyne.Window, input *widget.Entry, file string) {
|
||||||
uri, err := storage.Child(a.Storage().RootURI(), file)
|
uri, err := storage.Child(a.Storage().RootURI(), file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dialog.ShowError(err, w)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reader, err := storage.Reader(uri)
|
reader, err := storage.Reader(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dialog.ShowError(err, w)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
@ -146,7 +155,7 @@ func main() {
|
|||||||
|
|
||||||
h := hass.NewAccess(urlEntry.Text, "")
|
h := hass.NewAccess(urlEntry.Text, "")
|
||||||
if haExists && tkExists {
|
if haExists && tkExists {
|
||||||
if certExists {
|
if certExists && certEntry.Text != "" {
|
||||||
rootCAs, _ := x509.SystemCertPool()
|
rootCAs, _ := x509.SystemCertPool()
|
||||||
if rootCAs == nil {
|
if rootCAs == nil {
|
||||||
rootCAs = x509.NewCertPool()
|
rootCAs = x509.NewCertPool()
|
||||||
@ -197,17 +206,15 @@ func main() {
|
|||||||
w.Hide()
|
w.Hide()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
cols := 5
|
||||||
tabs := container.NewAppTabs(
|
tabs := container.NewAppTabs(
|
||||||
container.NewTabItemWithIcon("Lights",
|
container.NewTabItemWithIcon("Lights",
|
||||||
theme.VisibilityIcon(),
|
theme.VisibilityIcon(),
|
||||||
container.NewVBox(
|
container.NewAdaptiveGrid(cols, lightCards...),
|
||||||
container.NewAdaptiveGrid(3, lightCards...),
|
),
|
||||||
)),
|
|
||||||
container.NewTabItemWithIcon("Switches",
|
container.NewTabItemWithIcon("Switches",
|
||||||
theme.RadioButtonIcon(),
|
theme.RadioButtonIcon(),
|
||||||
container.NewVBox(
|
container.NewAdaptiveGrid(cols, switchCards...),
|
||||||
container.NewAdaptiveGrid(3, switchCards...),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
tabs.SetTabLocation(container.TabLocationLeading)
|
tabs.SetTabLocation(container.TabLocationLeading)
|
||||||
|
Loading…
Reference in New Issue
Block a user