Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network plugin item value not send as payload #186

Open
rthill opened this issue Nov 26, 2015 · 1 comment
Open

Network plugin item value not send as payload #186

rthill opened this issue Nov 26, 2015 · 1 comment

Comments

@rthill
Copy link

rthill commented Nov 26, 2015

The network plugin documentation claims that you can send the actual item value as:

    [test]
        [[item1]]
            type = str
            nw_udp_send = 11.11.11.11:7777  # sends an UDP packet with the item value as payload

But this does actually not work, this simply sends nothing.

One way of correcting this error is to update the documentation as follows which currently works for me:

    [test]
        [[item1]]
            type = str
            nw_udp_send = 11.11.11.11:7777=itemvalue  # sends an UDP packet with the item value as payload

or by modifying the code which I didn't choose for me. I tested only the following modification in the code which was working too:

diff --git a/plugins/network/__init__.py b/plugins/network/__init__.py
index 4aa2f66..3b8618a 100755
--- a/plugins/network/__init__.py
+++ b/plugins/network/__init__.py
@@ -290,7 +290,10 @@ class Network():
             else:
                 message = message.replace('itemvalue', str(item()))
             host, __, port = addr.partition(':')
-            self.udp(host, port, message)
+            if message:
+                self.udp(host, port, message)
+            else:
+                self.udp(host, port, str(item()))

     def parse_obj(self, obj, obj_type):
         # nw_acl, nw_udp, nw_tcp
@ohinckel
Copy link

Inspecting the code it seems that only the check if message is None is simply wrong and should check on an empty string instead, e.g. if message = ''. At least the documentation tells us that the partition() method returns a three-item-tuple with empty strings when separator was not found.

rthill added a commit to rthill/smarthome that referenced this issue Jan 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants