Page 2 of 3

Re: Device Sharing

Posted: Wednesday 11 December 2019 15:25
by duodiscu92
It works !

Indeed it was a port issue.

The good configuration is : port 8080 for both Master and Slave as you recommended, but 6144 in the Remote Server Config (see screenshot below)
config-master.png
config-master.png (37.42 KiB) Viewed 2175 times
The next step will be to test a similar configuration on my normal installation (a Rpi Zero and a Rpi B+) with my Xiaomi sensor and non-beta domoticz version.

Thank again "FireWizard" for all.

Best regards

Re: Device Sharing

Posted: Wednesday 11 December 2019 16:22
by FireWizard
@duodiscu92

Ok, that is nice to hear.

And you know: Never give up :D

Regards

Re: Device Sharing

Posted: Wednesday 11 December 2019 16:46
by duodiscu92
Right ... never give up

So it works well in my standard configuration Rpi Zero and Rpi B+, Wifi network, last non-beta Domotics version.

All "Motherboards Sensors" are well shared. But the Virtual Sensor I use for my Xiaomi sensor is not shared properly, I mean visible on slave side but not visible on master side.

I think it is an issue already discussed on the forum : Vitual Sensors seems difficult to share.

Trying now to solve this new issue ... :D

Re: Device Sharing

Posted: Wednesday 11 December 2019 17:02
by FireWizard
Hi,

Indeed, I have the same with virtual sensors. Mostly Python scripts.

See: https://github.com/domoticz/domoticz/issues/2642

But you said that you are running MQTT in parallel. Maybe you can try that.

Regards

Re: Device Sharing

Posted: Wednesday 11 December 2019 23:39
by duodiscu92
But you said that you are running MQTT in parallel. Maybe you can try that.
Yes this is what I have done and it works
2019-12-11 23:30:09.076 MQTT: Topic: domoticz/in, Message: {"idx" : 1025, "nvalue" : 0, "svalue" : "23.0;38.1;0"}
capteur-mi-ble.png
capteur-mi-ble.png (18.21 KiB) Viewed 2165 times
But after all these efforts to make working device sharing it's a real pity not to be able to use it for virtual sensors.

Best Regards

Re: Device Sharing

Posted: Wednesday 15 January 2020 21:37
by manjh
duodiscu92 wrote: Wednesday 11 December 2019 23:39
But you said that you are running MQTT in parallel. Maybe you can try that.
Yes this is what I have done and it works
2019-12-11 23:30:09.076 MQTT: Topic: domoticz/in, Message: {"idx" : 1025, "nvalue" : 0, "svalue" : "23.0;38.1;0"}
capteur-mi-ble.png

But after all these efforts to make working device sharing it's a real pity not to be able to use it for virtual sensors.

Best Regards
I fully agree. I also find it strange that there is no warning against this in the Wiki. There is an excellent step-by-step description of the Device sharing setup. But nothing about omission of virtual devices...

Re: Device Sharing

Posted: Wednesday 15 January 2020 22:10
by waaren
manjh wrote: Wednesday 15 January 2020 21:37 I fully agree. I also find it strange that there is no warning against this in the Wiki. There is an excellent step-by-step description of the Device sharing setup. But nothing about omission of virtual devices...
The nicest feature of the wiki pages on domoticz.com is that the are by-, from- and for us all. Just create a user-id or when not yet possible because of recent spam attacks ask @gizmocuz to create one for you and improve the information on the wiki.
Your fellow forum members will be grateful and it will give you the warm feeling that you contributed.

Re: Device Sharing

Posted: Friday 17 January 2020 0:14
by manjh
waaren wrote: Wednesday 15 January 2020 22:10
manjh wrote: Wednesday 15 January 2020 21:37 I fully agree. I also find it strange that there is no warning against this in the Wiki. There is an excellent step-by-step description of the Device sharing setup. But nothing about omission of virtual devices...
The nicest feature of the wiki pages on domoticz.com is that the are by-, from- and for us all. Just create a user-id or when not yet possible because of recent spam attacks ask @gizmocuz to create one for you and improve the information on the wiki.
Your fellow forum members will be grateful and it will give you the warm feeling that you contributed.
I understand that, but it feels a bit wrong. I think the author of this particular piece of code is the ideal person to maintain the page.
Having said this, if that person won't/can't do it, I guess I'll voluteer... I will add some text.

Re: Device Sharing

Posted: Friday 17 January 2020 11:12
by aleph0
A while ago, I had the need to send any kind of device (dummy or not) to a remote domoticz, so I wrote this little LUA function to do it easily via json

Code: Select all

function UpdateRmt(credentials,ipp,local_dev,remote_idx)
    --[[Update a sensor on a remote domoticz
    credentials : string "login:pw" of remote domoticz
    ipp : string "ip:port" of remote domoticz
    local_dev : name of local device to transmit
    remote_idx : index of device on the remote domoticz
    ]]--
    
    cmd = "http://"..credentials.."@"..ipp.."/json.htm?type=command&param=udevice&idx="..tostring(remote_idx).."&nvalue=0&svalue="..otherdevices_svalues[local_dev]
    --print(cmd)
    os.execute('curl "'..cmd..'" &') -- Or we could do it with a 'OpenURL' in a CommandArray...
end
You can call the function at your choice on a devicechanged or regularily...

Re: Device Sharing

Posted: Saturday 18 January 2020 15:55
by manjh
aleph0 wrote: Friday 17 January 2020 11:12 A while ago, I had the need to send any kind of device (dummy or not) to a remote domoticz, so I wrote this little LUA function to do it easily via json

Code: Select all

function UpdateRmt(credentials,ipp,local_dev,remote_idx)
    --[[Update a sensor on a remote domoticz
    credentials : string "login:pw" of remote domoticz
    ipp : string "ip:port" of remote domoticz
    local_dev : name of local device to transmit
    remote_idx : index of device on the remote domoticz
    ]]--
    
    cmd = "http://"..credentials.."@"..ipp.."/json.htm?type=command&param=udevice&idx="..tostring(remote_idx).."&nvalue=0&svalue="..otherdevices_svalues[local_dev]
    --print(cmd)
    os.execute('curl "'..cmd..'" &') -- Or we could do it with a 'OpenURL' in a CommandArray...
end
You can call the function at your choice on a devicechanged or regularily...
This could be helpful, but it would mean opening the Domoticz port through my router. Is that safe? I assumed that the "device sharing" port is OK, but the regular IP port?

Re: Device Sharing

Posted: Saturday 18 January 2020 17:18
by manjh
aleph0 wrote: Friday 17 January 2020 11:12 A while ago, I had the need to send any kind of device (dummy or not) to a remote domoticz, so I wrote this little LUA function to do it easily via json

Code: Select all

function UpdateRmt(credentials,ipp,local_dev,remote_idx)
    --[[Update a sensor on a remote domoticz
    credentials : string "login:pw" of remote domoticz
    ipp : string "ip:port" of remote domoticz
    local_dev : name of local device to transmit
    remote_idx : index of device on the remote domoticz
    ]]--
    
    cmd = "http://"..credentials.."@"..ipp.."/json.htm?type=command&param=udevice&idx="..tostring(remote_idx).."&nvalue=0&svalue="..otherdevices_svalues[local_dev]
    --print(cmd)
    os.execute('curl "'..cmd..'" &') -- Or we could do it with a 'OpenURL' in a CommandArray...
end
You can call the function at your choice on a devicechanged or regularily...
OK. Nice solution. I first tested this while port 8080 was routed through my router to the R-Pi on which Domoticz runs.
I was able to send values into my Domoticz devices, so the mechanism works.
Obviously, I did not want to keep 8080 open for a second longer than really needed to test, so I removed that NAT line, and instead entered 443.
Changed "http" into "https"in your code, and 8080 into 443.
Unfortunately this does not work. Also tried removing the port alltogether, but no.

I then tried using a browser from outside my network, using the https connection works OK (although I do get a warning from the browser). This proves that my NAT settings are good.
Any suggestions?

Re: Device Sharing

Posted: Sunday 19 January 2020 10:36
by aleph0
I did not test this, as my remote domoticz was accessible from inside a VPN. I'll make some tests with https to understand what's going on

Envoyé de mon moto g(6) en utilisant Tapatalk


Re: Device Sharing

Posted: Sunday 19 January 2020 17:15
by manjh
aleph0 wrote: Sunday 19 January 2020 10:36 I did not test this, as my remote domoticz was accessible from inside a VPN. I'll make some tests with https to understand what's going on

Envoyé de mon moto g(6) en utilisant Tapatalk
Very kind of you, thank you.

Re: Device Sharing

Posted: Sunday 19 January 2020 17:22
by manjh
I am looking at a new approach to get virtual device values across to the master domoticz.
Perhaps I could somehow create a device, copy the value into that, and catch it at the master side?
I have three virtual devices, with values from the speedtest: upload Mbit, download Mbit, and ping msec.
Any recommendations as for the type of transport device I should be using?

Re: Device Sharing

Posted: Sunday 19 January 2020 20:26
by FireWizard
Hi manjh,

Did you see my last post at: https://www.domoticz.com/forum/viewtopi ... 60#p234060

I believe probably the simplest way to go is to use MQTT.

Regards

Re: Device Sharing

Posted: Sunday 19 January 2020 20:40
by manjh
FireWizard wrote: Sunday 19 January 2020 20:26 Hi manjh,

Did you see my last post at: https://www.domoticz.com/forum/viewtopi ... 60#p234060

I believe probably the simplest way to go is to use MQTT.

Regards
Ah, thanks. I had not seen that yet.
I do need Domoticz on the remote location, and I also want to be able to see the speedtest results in Domoticz variables.
But on my home Domoticz, I would like to collect the speedtest results and show them in a Node-Red dashboard...
Opening MQTT or Node-Red to the outside internet is something I would like to prevent. Currently the only ports that are in the NAT are VPN and remote-Domoticz. Adding more ports is not something I look forward to...

Re: Device Sharing

Posted: Sunday 19 January 2020 20:47
by manjh
A question that keeps coming back into my mind.
What is the rationale for Virtual Sensors not being sent across to the master Domoticz server? Is there a good reason, or was it simply never implemented before?
Also, is this true for all types of virtual sensors?

Re: Device Sharing

Posted: Sunday 19 January 2020 21:24
by FireWizard
Hi,

You wrote.
A question that keeps coming back into my mind.
What is the rationale for Virtual Sensors not being sent across to the master Domoticz server? Is there a good reason, or was it simply never implemented before?
Also, is this true for all types of virtual sensors?
I cannot answer that question, but maybe some of the developers can.

You can try to publish the Speedtest results to your MQTT server from your Remote Pi and to subscribe to it with your Master Pi.

You have to open port 1883 on your router. On the other hand you can close port 6144.

Regards

Re: Device Sharing

Posted: Sunday 19 January 2020 21:30
by manjh
FireWizard wrote: Sunday 19 January 2020 21:24 Hi,

You wrote.
A question that keeps coming back into my mind.
What is the rationale for Virtual Sensors not being sent across to the master Domoticz server? Is there a good reason, or was it simply never implemented before?
Also, is this true for all types of virtual sensors?
I cannot answer that question, but maybe some of the developers can.

You can try to publish the Speedtest results to your MQTT server from your Remote Pi and to subscribe to it with your Master Pi.

You have to open port 1883 on your router. On the other hand you can close port 6144.

Regards
I understand. But I have more devices and sensors for which I use the 6144 link.
It feels like a work-around..... I would much prefer to use the Domoticz sharing method.

Re: Device Sharing

Posted: Sunday 19 January 2020 21:35
by manjh
To add to my confusion: I checked the sensors coming in on my central Domoticz, and noticed that the Raspberry Pi Motherboard sensors plugin actually uses a couple of General Custom Sensor devices. And they really do come through across the 6144 link!

So why are these sensors different from the ones that I create using the "create virtual sensors: button in the hardware tab?