hkknx

Package hkknx provides functionality to create powerful automations for KNX smart homes.

Index

Functions

func AtSunrise

1func AtSunrise(offset time.Duration, weekdays ...time.Weekday) <-chan time.Time

AtSunrise returns a channel, which waits until sunrise + offset and then returns the current time. If weekdays are specified the channel returns the time only on those weekdays. If no weekdays are specified, the channel returns time everyday.

The time when sunrise happens is calculated based on the location (latitude, longitude) specified in the settings. The default location of Linz (Austria) is used, if no location is specified.

This example demonstrates how to wait until 45 minutes before sunrise.

1var ch = hkknx.AtSunrise(-45 * time.Minute)
2for {
3	<-ch
4	println("it's 45 minutes before sunrise")
5}

func AtSunset

1func AtSunset(offset time.Duration, weekdays ...time.Weekday) <-chan time.Time

AtSunset returns a channel, which waits until sunset + offset and then returns the current time. If weekdays are specified the channel returns the time only on those weekdays. If no weekdays are specified, the channel returns time everyday.

The time when sunrise happens is calculated based on the location (latitude, longitude) specified in the settings. The default location of Linz (Austria) is used, if no location is specified.

This example demonstrates how to wait until 30 minutes after sunset on weekends.

1var ch = hkknx.AtSunset(30*time.Minute, time.Saturday, time.Sunday)
2for {
3	<-ch
4	println("it's 30 minutes after sunset")
5}

func AtTime

1func AtTime(hour, minute, second int, weekdays ...time.Weekday) <-chan time.Time

AtTime returns a channel, which waits until a specific time of day and then returns the current time. If weekdays are specified the channel returns the time only on those weekdays. If no weekdays are specified, the channel returns time everyday.

This example demonstrates how to wait until 8:15 AM on a Monday, Wednesday and Friday.

1var ch = hkknx.AtTime(8, 15, 0, time.Monday, time.Wednesday, time.Friday)
2for {
3	<-ch
4	println("it's 8:15 AM")
5}

func DPT1

1func DPT1(v bool) dpt.Value

DPT1 returns the boolean reprentation of v.

func DPT10001

1func DPT10001(t time.Time) dpt.Value

DPT10001 returns the time representation of t.

func DPT11001

1func DPT11001(t time.Time) dpt.Value

DPT11001 returns the date representation of t.

func DPT12

1func DPT12(v uint32) dpt.Value

DPT12 returns the 32-bit unsigned integer representation of v from 0 to 4,294,967,295.

func DPT13

1func DPT13(v int32) dpt.Value

DPT13 returns the 32-bit integer representation of v from -2,147,483,648 to ,2,147,483,647.

func DPT13010

1func DPT13010(v int32) dpt.Value

DPT13010 returns the active energy representation of v with a resolution of 1 Wh.

func DPT13011

1func DPT13011(v int32) dpt.Value

DPT13011 returns the apparant energy representation of v with a resolution of 1 VAh.

func DPT13012

1func DPT13012(v int32) dpt.Value

DPT13012 returns the reactive energy representation of v with a resolution of 1 VARh.

func DPT13013

1func DPT13013(v int32) dpt.Value

DPT13013 returns the active energy representation of v with a resolution of 1 kWh.

func DPT13014

1func DPT13014(v int32) dpt.Value

DPT13014 returns the apparant energy representation of v with a resolution of 1 kVAh.

func DPT13015

1func DPT13015(v int32) dpt.Value

DPT13015 returns the reactive energy representation of v with a resolution of 1 kVARh.

func DPT13016

1func DPT13016(v int32) dpt.Value

DPT13016 returns the active energy representation of v with a resolution of 1 MWh.

func DPT14

1func DPT14(v float32) dpt.Value

DPT14 returns the 32-bit float representation of v.

func DPT14056

1func DPT14056(v float32) dpt.Value

DPT14056 returns the power representation of v in Watt.

func DPT16000

1func DPT16000(s string) dpt.Value

DPT16000 returns the ascii representation of v.

func DPT16001

1func DPT16001(s string) dpt.Value

DPT16001 returns the latin-1 representation of v.

func DPT17001

1func DPT17001(v byte) dpt.Value

DPT17001 returns the scene number representation of v.

func DPT19001

1func DPT19001(t time.Time) dpt.Value

DPT19001 returns the date time representation of t.

func DPT5

1func DPT5(v int) dpt.Value

DPT5 returns the integer representation of v from 0 to 255 with a resolution of 1.

func DPT5001

1func DPT5001(v float32) dpt.Value

DPT5001 returns the scaling representation of v from 0 to 100% with a resolution of 0.4%.

func DPT5003

1func DPT5003(v float32) dpt.Value

DPT5003 returns the angle representation of v from 0 to 360° with a resolution of 1.4%.

func DPT5004

1func DPT5004(v int) dpt.Value

DPT5004 returns the percentage representation of v from 0 to 100% with a resolution of 1%.

func DPT5010

1func DPT5010(v int) dpt.Value

DPT5010 returns the counter pulses representation of v from 0 to 255 with a resolution of 1 counter pulse.

func DPT5100

1func DPT5100(v int) dpt.Value

DPT5100 returns the fan stage representation of v from 0 to 255 with a resolution of 1.

func DPT7

1func DPT7(v int) dpt.Value

DPT7 returns the integer representation of v from 0 to 65,535 with a resolution of 1.

func DPT7001

1func DPT7001(v int) dpt.Value

DPT7001 returns the integer representation of v from 0 to 65,535 pulses with a resolution of 1 pulse.

func DPT7011

1func DPT7011(v int) dpt.Value

DPT7011 returns the integer representation of v from 0 to 65,535 mm with a resolution of 1 mm.

func DPT7012

1func DPT7012(v int) dpt.Value

DPT7012 returns the integer representation of v from 0 to 65,535 mA with a resolution of 1 mA.

func DPT7013

1func DPT7013(v int) dpt.Value

DPT7013 returns the integer representation of v from 0 to 65,535 lux with a resolution of 1 lux.

func DPT8

1func DPT8(v int) dpt.Value

DPT8 returns the integer representation of v from -32,768 to 32,767 lux with a resolution of 1.

func DPT8011

1func DPT8011(v int) dpt.Value

DPT8011 returns the rotation angle representation of v from -32,768 to 32,767° with a resolution of 1°.

func DPT9

1func DPT9(v float32) dpt.Value

DPT9 returns the float representation of v from -671,088.64 to 670,433.28 with a resolution of 1.

func DPT9001

1func DPT9001(v float32) dpt.Value

DPT9001 returns the temperature representation of v from -273°C to 670,433.28°C with a resolution of 0.01°C.

func DPT9002

1func DPT9002(v float32) dpt.Value

DPT9002 returns the temperature representation of v from -671,088.64 to 670,433.28 Kelvin with a resolution of 0.01 Kelvin.

func DPT9003

1func DPT9003(v float32) dpt.Value

DPT9003 returns the temperature change representation of v from -671,088.64 to 670,433.28 K/h with a resolution of 0.01 K/h.

func DPT9004

1func DPT9004(v float32) dpt.Value

DPT9004 returns the lux representation of v from 0 to 670,433.28 Lux with a resolution of 0.01 Lux.

func DPT9005

1func DPT9005(v float32) dpt.Value

DPT9005 returns the wind speed representation of v from 0 to 670,433.28 m/s with a resolution of 0.01 m/s.

func DPT9006

1func DPT9006(v float32) dpt.Value

DPT9006 returns the pressure representation of v from 0 to 670,433.28 Pa with a resolution of 0.01 Pa.

func DPT9007

1func DPT9007(v float32) dpt.Value

DPT9007 returns the humidity representation of v from 0 to 670,433.28% with a resolution of 0.01%.

func DPT9008

1func DPT9008(v float32) dpt.Value

DPT9008 returns the air quality representation of v from 0 to 670,433.28 ppm with a resolution of 0.01 ppm.

func DPT9009

1func DPT9009(v float32) dpt.Value

DPT9009 returns the air flow representation of v from 0 to 670,433.28 m^3/h with a resolution of 0.01 m^3/h.

func DPT9020

1func DPT9020(v float32) dpt.Value

DPT9020 returns the voltage representation of v from -671,088.64 to 670,433.28 mV with a resolution of 0.01 mV.

func DPT9021

1func DPT9021(v float32) dpt.Value

DPT9021 returns the current representation of v from -671,088.64 to 670,433.28 mA with a resolution of 0.01 mA.

func DPT9024

1func DPT9024(v float32) dpt.Value

DPT9024 returns the power representation of v from -671,088.64 to 670,433.28 kW with a resolution of 0.01 kW.

func DPT9025

1func DPT9025(v float32) dpt.Value

DPT9025 returns the volume flow representation of v from -671,088.64 to 670,433.28 l/h with a resolution of 0.01 l/h.

func DPT9026

1func DPT9026(v float32) dpt.Value

DPT9026 returns the rain amount representation of v from -671,088.64 to 670,433.28 l/m^2 with a resolution of 0.01 l/m^2.

func DPT9027

1func DPT9027(v float32) dpt.Value

DPT9027 returns the temperature representation of v from -459.6 to 670,433.28 °F with a resolution of 0.01 °F.

func DPT9028

1func DPT9028(v float32) dpt.Value

DPT9028 returns the wind speed representation of v from 0 to 670,433.28 km/h with a resolution of 0.01 km/h.

func DPT9029

1func DPT9029(v float32) dpt.Value

DPT9029 returns the absolute humidity representation of v from 0 to 670,760 gm^-3 with a resolution of 0.01 gm^-3.

func DPT9030

1func DPT9030(v float32) dpt.Value

DPT9030 returns the particle concentration representation of v from 0 to 670,760 µm^3 with a resolution of 0.01 µm^3.

func GroupRead

1func GroupRead(addr string) (buf []byte, err error)

GroupRead reads the bytes from group address addr and returns the byte and an error, if any.

This example demonstrates how to read the value from 0/1/1 and convert it to the datapoint type DPST-5-1 (5.001).

1var buf, err = hkknx.GroupRead("0/1/1")
2if err != nil {
3	println(err)
4	return
5}
6
7var val = hkknx.ParseDPT5001(buf)
8println(val)

func GroupReadBool

1func GroupReadBool(addr string) (b bool, err error)

GroupReadBool reads the bytes from group address addr and returns the boolean value and an error, if any.

func GroupReadNotify

1func GroupReadNotify(addr string) <-chan interface{}

GroupReadNotify returns a channel which provides an opaque value as a results of a group read telegram sent to addr.

func GroupResponse

1func GroupResponse(v interface{}, addr ...string) (err error)

GroupResponse responds with value v to group addresses addrs and returns an error, if any. A group address response telegram should be sent as a responds to a group read telegram.

Note that GroupResponse is defined as a variadic function and can write v to one or more group addresses at a time. https://gobyexample.com/variadic-functions

This example demonstrates how to respond to a read request by first listing to a group read telegram and then responding with a group response telegram.

1var ch = hkknx.GroupReadNotify("0/2/1")
2<-ch
3hkknx.GroupResponse(true, "0/2/1")

func GroupWrite

1func GroupWrite(v interface{}, addrs ...string) (err error)

GroupWrite writes value v to group addresses addrs and returns an error, if any. Note that GroupWrite is defined as a variadic function and can write v to one or more group addresses at a time. https://gobyexample.com/variadic-functions

This example demonstrates how to write the bit 1 to three group addresses.

1var err = hkknx.GroupWrite(true, "0/0/1", "0/0/2", "0/0/3")
2if err != nil {
3	println(err)
4}

func GroupWriteBoolNotify

1func GroupWriteBoolNotify(addr string) <-chan bool

GroupWriteBoolNotify returns a channel which provides boolean values from a group write telegram sent to addr.

This example demonstrates how to listens for group write telegrams to "0/0/1".

1var ch = hkknx.GroupWriteBoolNotify("0/0/1")
2var on = <-ch
3println(on)

func GroupWriteNotify

1func GroupWriteNotify(addr string) <-chan []byte

GroupWriteNotify returns a channel which provides bytes from a group write telegram sent to addr.

This example demonstrates how to listens for group write telegrams to "0/1/1" and convert the bytes to the datapoint type DPST-5-1 (5.001).

1var ch = hkknx.GroupWriteNotify("0/1/1")
2var buf = <-ch
3var val = hkknx.ParseDPT5001(buf)
4println(val)

func GroupWriteTelegramNotify

1func GroupWriteTelegramNotify(patterns ...string) <-chan Telegram

GroupWriteTelegramNotify returns a channel which provides group write telegrams sent to matching group addresses.

A pattern can be a specific group address (ex. “0/1/1”) or a range of group addresses (“0/1/1-100”).

Note that GroupWriteTelegramNotify is defined as a variadic function and takes one or more group address patterns. https://gobyexample.com/variadic-functions

If no pattern is specified, all group write telegrams are received.

This example demonstrates how to listens for group write telegrams to group address "0/1/1" and "0/1/2".

1var ch = hkknx.GroupWriteTelegramNotify("0/1/1", "0/1/2")
2var telegram = <-ch
3printf("%s: %v", telegram.Addr, telegram.Bytes)

This example demonstrates how to listens for group write telegrams to group address in a specific range.

1var ch = hkknx.GroupWriteTelegramNotify("0/1/1-100")
2var telegram = <-ch
3printf("%s: %v", telegram.Addr, telegram.Bytes)

This example demonstrates how to listens for any group write telegram.

1var ch = hkknx.GroupWriteTelegramNotify()
2var telegram = <-ch
3printf("%s: %v", telegram.Addr, telegram.Bytes)

func ParseBool

1func ParseBool(buf []byte) bool

ParseBool returns the boolean value of the bytes in buf.

1var val = hkknx.ParseBool([]byte{0x1})
2println(val)

Output

true

func ParseDPT1

1func ParseDPT1(buf []byte) bool

ParseDPT1 returns the boolean value of the bytes in buf.

func ParseDPT12

1func ParseDPT12(buf []byte) uint32

ParseDPT12 returns the unsigned integer value of the bytes in buf.

func ParseDPT13

1func ParseDPT13(buf []byte) int32

ParseDPT13 returns the integer value of the bytes in buf.

1var val = hkknx.ParseDPT13([]byte{0x00, 0x00, 0x01, 0x00})
2println(val)
3println(hkknx.DPT13(val))

Output

256
256

func ParseDPT13010

1func ParseDPT13010(buf []byte) int32

ParseDPT13010 returns the integer value of the bytes in buf. The datapoint type 13.010 represents active energy values in Wh from -2,147,483,648 to 2,147,483,647 Wh.

func ParseDPT13011

1func ParseDPT13011(buf []byte) int32

ParseDPT13011 returns the integer value of the bytes in buf. The datapoint type 13.011 represents apparant energy values in VAh from -2,147,483,648 to 2,147,483,647 VAh.

func ParseDPT13012

1func ParseDPT13012(buf []byte) int32

ParseDPT13012 returns the integer value of the bytes in buf. The datapoint type 13.012 represents reactive energy values in VARh from -2,147,483,648 to 2,147,483,647 VARh.

func ParseDPT13013

1func ParseDPT13013(buf []byte) int32

ParseDPT13013 returns the integer value of the bytes in buf. The datapoint type 13.013 represents active energy values in kWh from -2,147,483,648 to 2,147,483,647 kWh.

func ParseDPT13014

1func ParseDPT13014(buf []byte) int32

ParseDPT13014 returns the integer value of the bytes in buf. The datapoint type 13.014 represents apparant energy values in kVAh from -2,147,483,648 to 2,147,483,647 kVAh.

func ParseDPT13015

1func ParseDPT13015(buf []byte) int32

ParseDPT13015 returns the integer value of the bytes in buf. The datapoint type 13.015 represents reactive energy values in kVARh from -2,157,483,648 to 2,157,483,647 kVARh.

func ParseDPT13016

1func ParseDPT13016(buf []byte) int32

ParseDPT13016 returns the integer value of the bytes in buf. The datapoint type 13.016 represents active energy values in MWh from -2,157,483,648 to 2,157,483,647 MWh.

func ParseDPT14

1func ParseDPT14(buf []byte) float32

ParseDPT14 returns the float value of the bytes in buf.

1var val = hkknx.ParseDPT14([]byte{0x42, 0xEA, 0x0, 0x0})
2println(val)
3println(hkknx.DPT14(val))

Output

117
117

func ParseDPT14056

1func ParseDPT14056(buf []byte) float32

ParseDPT14056 returns the float value of the bytes in buf. The datapoint type 14.056 represents power values in Watt.

1var val = hkknx.ParseDPT14056([]byte{0x42, 0xEA, 0x0, 0x0})
2println(val)
3println(hkknx.DPT14056(val))

Output

117
117 W

func ParseDPT16000

1func ParseDPT16000(buf []byte) string

ParseDPT16000 returns the ascii encoded string value of the bytes in buf.

func ParseDPT16001

1func ParseDPT16001(buf []byte) string

ParseDPT16001 returns the latin-1 (ISO 8859-1) encoded string value of the bytes in buf.

func ParseDPT17001

1func ParseDPT17001(buf []byte) byte

ParseDPT17001 returns the scene number of the bytes in buf.

func ParseDPT19001

1func ParseDPT19001(buf []byte) (*time.Time, error)

ParseDPT19001 returns the date and time of the bytes in buf. An error is returned, if either year, month or day are invalid.

func ParseDPT5

1func ParseDPT5(buf []byte) byte

ParseDPT5 returns the byte value of the bytes in buf. The datapoint type 5 represents values from 0 to 255 with a resolution of 1.

func ParseDPT5001

1func ParseDPT5001(buf []byte) float32

ParseDPT5001 returns the float value of the bytes in buf. The datapoint type 5.001 represents scaling values from 0 to 100% with a resolution of 0.4%.

1var val = hkknx.ParseDPT5001([]byte{0xFF})
2println(val)

Output

100

func ParseDPT5003

1func ParseDPT5003(buf []byte) float32

ParseDPT5003 returns the float value of the bytes in buf. The datapoint type 5.003 represents angles from 0 to 360° with a resolution of 1.4°.

1var val = hkknx.ParseDPT5003([]byte{0xFF})
2println(val)

Output

360

func ParseDPT5004

1func ParseDPT5004(buf []byte) int

ParseDPT5004 returns the integer value of the bytes in buf. The datapoint type 5.004 represents percentages from 0 to 100% with a resolution of 1%.

1var val = hkknx.ParseDPT5004([]byte{0xFF})
2println(val)

Output

255

func ParseDPT5010

1func ParseDPT5010(buf []byte) int

ParseDPT5010 returns the integer value of the bytes in buf. The datapoint type 5.010 represents integer values from 0 to 255 with a resolution of 1.

1var val = hkknx.ParseDPT5010([]byte{0xFF})
2println(val)

Output

255

func ParseDPT5100

1func ParseDPT5100(buf []byte) int

ParseDPT5100 returns the integer value of the bytes in buf. The datapoint type 5.100 represents fan stage values from 0 to 255 with a resolution of 1.

func ParseDPT7

1func ParseDPT7(buf []byte) int

ParseDPT7 returns the integer value of the bytes in buf. The datapoint type 7 represents integer values from 0 to 65,535 with a resolution of 1.

func ParseDPT7001

1func ParseDPT7001(buf []byte) int

ParseDPT7001 returns the integer value of the bytes in buf. The datapoint type 7.001 represents integer values from 0 to 65,535 pulses with a resolution of 1 pulses.

func ParseDPT7011

1func ParseDPT7011(buf []byte) int

ParseDPT7011 returns the integer value of the bytes in buf. The datapoint type 7.011 represents values from 0 to 65,535 mm with a resolution of 1 mm.

func ParseDPT7012

1func ParseDPT7012(buf []byte) int

ParseDPT7012 returns the integer value of the bytes in buf. The datapoint type 7.012 represents integer values from 0 to 65,535 mA with a resolution of 1 mA.

func ParseDPT7013

1func ParseDPT7013(buf []byte) int

ParseDPT7013 returns the integer value of the bytes in buf. The datapoint type 7.013 represents integer values from 0 to 65,535 lux with a resolution of 1 lux.

1var val = hkknx.ParseDPT7013([]byte{0xFF, 0xFF})
2println(val)

Output

65535

func ParseDPT8

1func ParseDPT8(buf []byte) int

ParseDPT8 returns the integer value of the bytes in buf. The datapoint type 8 represents integer values from -32,768 to 32,767 with a resolution of 1.

func ParseDPT8011

1func ParseDPT8011(buf []byte) int

ParseDPT8011 returns the integer value of the bytes in buf. The datapoint type 8.011 represents integer values from -32,768 to 32,767° with a resolution of 1°.

func ParseDPT9

1func ParseDPT9(buf []byte) float32

ParseDPT9 returns the float value of the bytes in buf. The datapoint type 9 represents values from -671,088.64 to 670,433.28 with a resolution of up to 0,01.

func ParseDPT9001

1func ParseDPT9001(buf []byte) float32

ParseDPT9001 returns the float value of the bytes in buf. The datapoint type 9.001 represents temperature values from -273°C to 670,433.28°C with a resolution of 0.01°C.

func ParseDPT9002

1func ParseDPT9002(buf []byte) float32

ParseDPT9002 returns the float value of the bytes in buf. The datapoint type 9.002 represents temperature difference values from -671,088.64 to 670,433.28 Kelvin with a resolution of 0.01 K.

func ParseDPT9003

1func ParseDPT9003(buf []byte) float32

ParseDPT9003 returns the float value of the bytes in buf. The datapoint type 9.003 represents temperature change values from -671,088.64 to 670,433.28 Kelvin per hour with a resolution of 0.01 K/h.

func ParseDPT9004

1func ParseDPT9004(buf []byte) float32

ParseDPT9004 returns the float value of the bytes in buf. The datapoint type 9.004 represents lux values from 0 to 670,433.28 Lux with a resolution of 0.01 Lux.

func ParseDPT9005

1func ParseDPT9005(buf []byte) float32

ParseDPT9005 returns the float value of the bytes in buf. The datapoint type 9.005 represents wind speed values from 0 to 670,433.28 m/s with a resolution of 0.01 m/s.

func ParseDPT9006

1func ParseDPT9006(buf []byte) float32

ParseDPT9006 returns the float value of the bytes in buf. The datapoint type 9.006 represents pressurce values from 0 to 670,433.28 Pa with a resolution of 0.01 Pa.

func ParseDPT9007

1func ParseDPT9007(buf []byte) float32

ParseDPT9007 returns the float value of the bytes in buf. The datapoint type 9.007 represents humidity values from 0 to 670,433.28% with a resolution of 0.01%.

func ParseDPT9008

1func ParseDPT9008(buf []byte) float32

ParseDPT9008 returns the float value of the bytes in buf. The datapoint type 9.008 represents air quality values from 0 to 670,433.28 ppm with a resolution of 0.01 ppm.

func ParseDPT9009

1func ParseDPT9009(buf []byte) float32

ParseDPT9009 returns the float value of the bytes in buf. The datapoint type 9.009 represents air flow values from 0 to 670,433.28 m^3/h with a resolution of 0.01 m^3/h.

func ParseDPT9020

1func ParseDPT9020(buf []byte) float32

ParseDPT9020 returns the float value of the bytes in buf. The datapoint type 9.020 represents voltage values from 0 to 670,433.28 mV with a resolution of 0.01 mV.

func ParseDPT9021

1func ParseDPT9021(buf []byte) float32

ParseDPT9021 returns the float value of the bytes in buf. The datapoint type 9.021 represents current values from -671,088.64 to 670,433.28 mA with a resolution of 0.01 mA.

func ParseDPT9024

1func ParseDPT9024(buf []byte) float32

ParseDPT9024 returns the float value of the bytes in buf. The datapoint type 9.024 represents power values from -671,088.64 to 670,433.28 kW with a resolution of 0.01 kW.

func ParseDPT9025

1func ParseDPT9025(buf []byte) float32

ParseDPT9025 returns the float value of the bytes in buf. The datapoint type 9.025 represents volume flow values from -671,088.64 to 670,433.28 l/h with a resolution of 0.01 l/h.

func ParseDPT9026

1func ParseDPT9026(buf []byte) float32

ParseDPT9026 returns the float value of the bytes in buf. The datapoint type 9.026 represents rain amount values from -671,088.64 to 670,433.28 l/m^2 with a resolution of 0.01 l/m^2.

func ParseDPT9027

1func ParseDPT9027(buf []byte) float32

ParseDPT9027 returns the float value of the bytes in buf. The datapoint type 9.027 represents temperature values from -459.6 to 670,433.28 °F with a resolution of 0.01 °F.

func ParseDPT9028

1func ParseDPT9028(buf []byte) float32

ParseDPT9028 returns the float value of the bytes in buf. The datapoint type 9.028 represents wind speed values from 0 to 670,433.28 km/h with a resolution of 0.01 km/h.

func ParseDPT9029

1func ParseDPT9029(buf []byte) float32

ParseDPT9029 returns the float value of the bytes in buf. The datapoint type 9.029 represents humidity values from 0 to 670,760 gm^-3 with a resolution of 0.01 gm^-3.

func ParseDPT9030

1func ParseDPT9030(buf []byte) float32

ParseDPT9030 returns the float value of the bytes in buf. The datapoint type 9.030 represents particle concentration from 0 to 670,760 µm^3 with a resolution of 0.01 µm^-3.

func ParseString

1func ParseString(buf []byte) string

ParseString returns the string of the bytes in buf.

1var str = hkknx.ParseString([]byte{0x4B, 0x4E, 0x58, 0x20, 0x69, 0x73, 0x20, 0x4F, 0x4B, 0x00})
2println(str)

Output

KNX is OK

func Send

1func Send(notification *Notification, deviceNames ...string) error

Send sends a notification to registered devices. If device names are specified, the notification is only sent to devices, which contain any specified term in their names. Sending a notification requires an internet connection.

func SendNotification

1func SendNotification(title string, message string, deviceNames ...string) error

SendNotification sends a notification to registered devices. If device names are specified, the notification is only sent to devices, which contain any specified term in their names. Sending a notification requires an internet connection.

This example demonstrates how to send a notification to all registered devices.

1var err = hkknx.SendNotification("Alarm Triggered", "The alarm was triggered because motion was detected.")
2if err != nil {
3	println(err)
4}

This example demonstrates how to send a notification to devices, which contain the term "Matthias" in the name.

1var err = hkknx.SendNotification("Front Door", "The doorbell rang.", "Matthias")
2if err != nil {
3	println(err)
4}

func GetDailyWeather

1func GetDailyWeather() ([]*DailyWeather, error)

GetDailyWeather returns the daily weather forcast and an error, if any. The weather is downloaded based on the location (latitude, longitude) specified in the settings.

func ParseDPT11001

1func ParseDPT11001(buf []byte) Date

ParseDPT10001 returns the date of the bytes in buf.

func GroupReadTelegram

1func GroupReadTelegram(addr string) (telegram *Telegram, err error)

GroupReadTelegram sends a group read telegram to a group address and returns the received telegram and an error, if any.

func ObserveValues

1func ObserveValues(addrs ...string) ValueObservation

ObserveValues returns an observation of values from one or more group addresses. Use the returned observation to get notified when specific conditions are met. Value observation only works for group addresses with numeric datapoint types, e.g float, integer and boolean. The datapoint type must be specified in the imported ETS project.

This example demonstrates how to wait until all values from the group addresses 1/2/0 and 1/2/1 are true (1).

 1// Observe the group addresses 1/2/0 and 1/2/1
 2var observe = hkknx.ObserveValues("1/2/0", "1/2/1")
 3
 4// Specify the observation conditions and then
 5// call Notify() to get the notification channel.
 6var ch = observe.All().EqualTo(1).Notify()
 7
 8for {
 9	<-ch
10	println("all values are true")
11}

This example demonstrates how to get notified when a washing maschine started or finished a wash cycle. For this, the power current from the group address 1/2/10 is observed. A wash cycle started, if the current is higher than 500 mA for 5 minutes. A wash cycle finished, if the current is less than 100 mA for 5 minutes. A more detailed example is available in the online handbook.

1// Observe the group addresses 1/2/10
2var observe = hkknx.ObserveValues("1/2/10")
3
4<-observe.GreaterThan(500).Duration(5 * time.Second).Tolerance(1 * time.Minute).NotifyOnce()
5hkknx.SendNotification("Washing Maschine", "A new wash cycle started.")
6
7<-observe.LessThan(100).Duration(5 * time.Second).Tolerance(1 * time.Minute).NotifyOnce()
8hkknx.SendNotification("Washing Maschine", "The wash cycle finished.")

func GetCurrentWeather

1func GetCurrentWeather() (*Weather, error)

GetCurrentWeather returns the current weather and an error, if any. The weather is downloaded based on the location (latitude, longitude) specified in the settings.

This example demonstrates how to print the current temperature.

1var weather, err = hkknx.GetCurrentWeather()
2if err != nil {
3	println(err)
4	return
5}
6
7printf("%.2f °C\n", weather.Temp)

func GetHourlyWeather

1func GetHourlyWeather() ([]*Weather, error)

GetHourlyWeather returns the hourly weather forcast and an error, if any. The weather is downloaded based on the location (latitude, longitude) specified in the settings.

func ParseDPT10001

1func ParseDPT10001(buf []byte) WeekdayTime

ParseDPT10001 returns the weekday time of the bytes in buf.

Types

type DailyWeather

 1type DailyWeather struct {
 2	// Date is the day of the weather information.
 3	Date	time.Time
 4	// Temp is the temperature information for a day.
 5	Temp	DailyWeatherTemp
 6	// Pressure is the atmospheric in Hectopascal (hPa).
 7	Pressure	int
 8	// Humidity is the humidity in %.
 9	Humidity	int
10	// Clouds is the cloudiness in %.
11	Clouds	int
12	// WindSpeed is the wind speed in meter per second.
13	WindSpeed	float64
14	// WindGust is the wind gust in meter per second; added in 2.6.0
15	WindGust	float64
16	// WindDegree is the wind direction in degrees.
17	WindDegree	int
18	// Rain is the rain volume for a day in mm or l/m².
19	// This property is nil, if rain information is not available.
20	Rain	*RainVolume
21	// Snow is the snow volume for a day in mm or l/m²..
22	// This property is nil, if snow information is not available.
23	Snow	*SnowVolume
24}

DailyWeather represents the daily weather.

func RainVolume

1func (w DailyWeather) RainVolume() float64

RainVolume returns the rain volume in mm (l/m²) – or 0, if no rain information is available.

func SnowVolume

1func (w DailyWeather) SnowVolume() float64

SnowVolume returns the rain volume in mm (l/m²) – or 0, if no snow information is available.

type DailyWeatherTemp

 1type DailyWeatherTemp struct {
 2	// Day is the average temperature.
 3	Day	float64
 4	// Min is the minimum temperature.
 5	Min	float64
 6	// Min is the maximum temperature.
 7	Max	float64
 8	// Night is the night temperature.
 9	Night	float64
10	// Night is the evening temperature.
11	Evening	float64
12	// Night is the morning temperature.
13	Morning	float64
14}

DailyWeatherTemp represents the temperature information for a day.

type Date

1type Date struct {
2	Year	int
3	Month	time.Month
4	Day	int
5}

Date represents a date like January, 22nd 2024.

type Notification

1type Notification struct {
2	// Title of the notification
3	Title	string
4	// Message of the notification
5	Message	string
6	// Image of the notification
7	Image	[]byte
8}

Notification represents a push notification.

type NumericValue

1type NumericValue struct {
2}

NumericValue represents a number value, like float, int or bool.

func Bool

1func (val NumericValue) Bool() bool

Bool returns the boolean value.

func Float

1func (val NumericValue) Float() float64

Float returns the floating-point value.

func Int

1func (val NumericValue) Int() int64

Int returns the integer value.

func Unit

1func (val NumericValue) Unit() string

Unit returns the unit of the value, e.g. lux or kWh.

type RainVolume

1type RainVolume struct {
2	Volume float64
3}

func String

1func (v RainVolume) String() string

type SnowVolume

1type SnowVolume struct {
2	Volume float64
3}

func String

1func (v SnowVolume) String() string

type Telegram

 1type Telegram struct {
 2	// Addr is the telegram address.
 3	Addr	string
 4	// Bytes is the telegram payload.
 5	Bytes	[]byte
 6	// Value is the decoded value of the telegram payload.
 7	// This field is nil, if the payload cannot be decoded
 8	// because thte datapoint type is not known.
 9	Value	*Value
10}

Telegram represents a knx telegram.

func NumericValue

1func (t Telegram) NumericValue() *NumericValue

NumericValue returns the numeric representation of the telegram value. This method return nil, if the payload cannot be decoded because the datapoint type is not known.

type Value

1type Value struct {
2}

Value represents a generic value.

func Name

1func (v Value) Name() string

Name returns the name of the value.

func String

1func (v Value) String() string

String returns a string representation of the value.

type ValueObservation

1type ValueObservation struct {
2}

ValueObservation observes values over time and validates them against specific conditions. For example if you want to wait until a washing maschine finished a program, you can use a ValueObservation to first detect that the washing maschine is running, and then wait until the maschine finished.

func All

1func (o ValueObservation) All() ValueObservation

All returns an observation for all values.

func Any

1func (o ValueObservation) Any() ValueObservation

Any returns an observation for any value.

func Debug

1func (o ValueObservation) Debug() ValueObservation

Debug returns an observation which has debugging enabled. When debuggin is enabled, the internal state of an observation is logged to the console.

func Duration

1func (o ValueObservation) Duration(d time.Duration) ValueObservation

Duration sets the observation duration the the value of d.

func EqualTo

1func (o ValueObservation) EqualTo(value float64) ValueObservation

EqualTo sets the observation predicate to be equal the value.

func GreaterThan

1func (o ValueObservation) GreaterThan(value float64) ValueObservation

GreaterThan sets the observation predicate to be greater than value.

func LessThan

1func (o ValueObservation) LessThan(value float64) ValueObservation

LessThan sets the observation prediate to be less than value.

func Notify

1func (o ValueObservation) Notify() <-chan Telegram

Notify returns a channel which delivers the last received telegram when the observation finishes.

func NotifyOnce

1func (o ValueObservation) NotifyOnce() <-chan Telegram

NotifyOnce returns a channel which delivers the last received telegram only once, when the observation finishes.

func Tolerance

1func (o ValueObservation) Tolerance(d time.Duration) ValueObservation

Tolerance sets the observation's tolerance duration to the value of d. A non-zero tolerance duration means that the observation tolerates values outside of the observed range.

For example a tolerance of 5 seconds for an observation “> 10” means, thats values below or equal 10 are tolerated for 5 seconds.

type Weather

 1type Weather struct {
 2	// Date is the date and time of the weather information.
 3	Date	time.Time
 4	// Temp is the temperature in Celsius degree.
 5	Temp	float64
 6	// Pressure is the atmospheric in Hectopascal (hPa).
 7	Pressure	int
 8	// Humidity is the humidity in %.
 9	Humidity	int
10	// Clouds is the cloudiness in %.
11	Clouds	int
12	// WindSpeed is the wind speed in meter per second.
13	WindSpeed	float64
14	// WindGust is the wind gust in meter per second; added in 2.6.0
15	WindGust	float64
16	// WindDegree is the wind direction in degrees.
17	WindDegree	int
18	// Rain is the rain volume for an hour in mm (l/m²).
19	// This property is nil, if rain information is not available.
20	Rain	*RainVolume
21	// Snow is the snow volume for an hour in mm (l/m²).
22	// This property is nil, if snow information is not available.
23	Snow	*SnowVolume
24}

Weather represents the weather.

func RainVolume

1func (w Weather) RainVolume() float64

RainVolume returns the rain volume in mm (l/m²) – or 0, if no rain information is available.

func SnowVolume

1func (w Weather) SnowVolume() float64

SnowVolume returns the rain volume in mm (l/m²) – or 0, if no snow information is available.

type WeekdayTime

1type WeekdayTime struct {
2	Weekday	time.Weekday
3	Hour	int
4	Minute	int
5	Second	int
6}

WeekdayTime represents time on a weekday like 8:15 AM on Monday.


© Matthias Hochgatterer – MastodonGithubRésumé