Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
z2m
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Go
z2m
Commits
2b12280a
Commit
2b12280a
authored
5 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup
parent
97895cb2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xaal.go
+18
-18
18 additions, 18 deletions
xaal.go
z2m.go
+7
-6
7 additions, 6 deletions
z2m.go
with
25 additions
and
24 deletions
xaal.go
+
18
−
18
View file @
2b12280a
...
...
@@ -71,9 +71,9 @@ func (dev *XAALDevice) getXAALDevice() *xaal.Device {
return
dev
.
Device
}
//
----------------------------------------------------------------------------
//
=============================================================================
// Contact
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewContact
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
Contact
{
XAALDevice
{
schemas
.
NewContact
(
addr
)}}
dev
.
setup
(
zDev
)
...
...
@@ -87,9 +87,9 @@ func (dev *Contact) update(payload map[string]interface{}) {
}
}
//
----------------------------------------------------------------------------
//
=============================================================================
// Thermometer
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewThermometer
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
Thermometer
{
XAALDevice
{
schemas
.
NewThermometer
(
addr
)}}
dev
.
setup
(
zDev
)
...
...
@@ -103,9 +103,9 @@ func (dev *Thermometer) update(payload map[string]interface{}) {
}
}
//
----------------------------------------------------------------------------
//
=============================================================================
// Hygrometer
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewHygrometer
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
Hygrometer
{
XAALDevice
{
schemas
.
NewHygrometer
(
addr
)}}
dev
.
setup
(
zDev
)
...
...
@@ -119,9 +119,9 @@ func (dev *Hygrometer) update(payload map[string]interface{}) {
}
}
//
----------------------------------------------------------------------------
//
=============================================================================
// LinkQuality
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewLinkQuality
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
LinkQuality
{
XAALDevice
{
schemas
.
NewLinkquality
(
addr
)}}
dev
.
setup
(
zDev
)
...
...
@@ -138,9 +138,9 @@ func (dev *LinkQuality) update(payload map[string]interface{}) {
}
}
//
----------------------------------------------------------------------------
//
=============================================================================
// Battery
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewBattery
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
Battery
{
XAALDevice
{
schemas
.
NewBattery
(
addr
)}}
dev
.
setup
(
zDev
)
...
...
@@ -156,9 +156,9 @@ func (dev *Battery) update(payload map[string]interface{}) {
}
}
//
----------------------------------------------------------------------------
//
=============================================================================
// PowerRelay
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewPowerRelay
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
,
property
string
)
XAALDeviceInterface
{
dev
:=
&
PowerRelay
{
XAALDevice
{
schemas
.
NewPowerrelayToggle
(
addr
)},
property
,
*
zDev
}
dev
.
SetMethod
(
"turn_on"
,
dev
.
On
)
...
...
@@ -201,9 +201,9 @@ func (dev *PowerRelay) Toggle(xaal.MessageBody) *xaal.MessageBody {
return
nil
}
//
----------------------------------------------------------------------------
//
=============================================================================
// PowerMeter
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewPowerMeter
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
PowerMeter
{
XAALDevice
{
schemas
.
NewPowermeter
(
addr
)}}
dev
.
setup
(
zDev
)
...
...
@@ -225,9 +225,9 @@ func (dev *PowerMeter) update(payload map[string]interface{}) {
}
}
//
----------------------------------------------------------------------------
//
=============================================================================
// Lamp
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewLamp
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
Lamp
{
XAALDevice
{
schemas
.
NewLamp
(
addr
)},
*
zDev
}
dev
.
SetMethod
(
"turn_on"
,
dev
.
On
)
...
...
@@ -265,9 +265,9 @@ func (dev *Lamp) Toggle(xaal.MessageBody) *xaal.MessageBody {
return
nil
}
//
----------------------------------------------------------------------------
//
=============================================================================
// NetButtonRemote
//
----------------------------------------------------------------------------
//
=============================================================================
func
NewButtonRemote
(
addr
uuid
.
UUID
,
zDev
*
Z2MDevice
)
XAALDeviceInterface
{
dev
:=
&
ButtonRemote
{
XAALDevice
{
schemas
.
NewButtonRemote
(
addr
)},
*
zDev
}
dev
.
setup
(
zDev
)
...
...
This diff is collapsed.
Click to expand it.
z2m.go
+
7
−
6
View file @
2b12280a
...
...
@@ -65,10 +65,11 @@ type Feature struct {
Access
int
`json:"access,omitempty"`
}
//
------------------------------------------------------------------------------
//
=============================================================================
// Z2MDevice API
//
------------------------------------------------------------------------------
//
=============================================================================
// returns the topic for the device
func
(
zDev
*
Z2MDevice
)
GetTopic
()
string
{
return
mqttTopic
+
"/"
+
zDev
.
FriendlyName
}
...
...
@@ -144,9 +145,9 @@ func (zDev *Z2MDevice) setupXAALDevices(gw *Gateway) {
}
}
//
----------------------------------------------------------------------------
//
==============================================================================
// MQTT API
//
----------------------------------------------------------------------------
//
==============================================================================
// Publish the payload to the right topic
func
(
zDev
*
Z2MDevice
)
Publish
(
topic
string
,
payload
interface
{})
{
...
...
@@ -175,9 +176,9 @@ func (zDev *Z2MDevice) Sync() {
zDev
.
Publish
(
"dump"
,
"{}"
)
}
//
------------------------------------------------------------------------------
//
=============================================================================
// Helpers
//
------------------------------------------------------------------------------
//
=============================================================================
func
(
zDev
*
Z2MDevice
)
dump
()
{
tab
:=
table
.
NewWriter
()
tab
.
SetTitle
(
"Def:"
+
zDev
.
FriendlyName
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment