Connecting MQTT server with OpenHab - home-automation

As a sample test, I just want to ON/OFF a bulb using OpenHab via wifi. So I connect the hivemq server and openhab as follows in the openhab configuration.
mqtt:broker.url=tcp://127.0.0.1:1883
mqtt:broker.clientId=openhab
So when starting openhab I can see following in the console.
2016-09-01 19:18:11.692 [INFO ] [.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2016-09-01 19:18:11.695 [INFO ] [o.i.t.m.i.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2016-09-01 19:18:13.092 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
So it seems openhab and hivemq connected successfully. Then I created following file on openhab distribution.
home.sitemap
sitemap home label="My House"
{
Frame label="ESP Module"{
Group item=FF_Bed label="Front Porch"
}
}
home.items
Group All
Group gGF (All)
Group gFF (All)
Group GF_Living "Living Room" <video> (gGF)
Group FF_Bed "Bedroom" <bedroom> (gFF)
Dimmer Light_GF_Living_Table "Table" (GF_Living, Lights) {mqtt="<[mybroker:/myHome/Table:command:ON]"}
Switch Light_FF_Bed_Ceiling "Ceiling" (FF_Bed, Lights) {mqtt="<[mybroker:/myHome/doorbell:command:ON]"}
/* Locations */
Location HomeLocation MyHome
esp-pic.map
0=Still
1=Motion
I can see above specified items on my openhab site. But when I click on the light there are no updates from the MQTT server. But I can see following on OpenHab console.
2016-09-02 12:00:35.484 [INFO ] [runtime.busevents ] - Light_FF_Bed_Ceiling received command ON
So why it doesn't publish this change to HiveMQ topic?
Thanks.

You can only have inbound or outbound mqtt messages in openHAB.
Your current configuration in home.items is inbound because of the "<"-sign.
If you want to a click on the switch to cause a mqtt-message to be published to the broker, you have to change it to the ">"-sign.
For reference have look on this page: https://github.com/openhab/openhab/wiki/MQTT-Binding and search for inbound or outbound messages

Related

Photon. OnRoomListUpdate doesn't work after restart WI-FI on Android

PUN2.31 Photon lib: 4.1.6.0
Unity 2019.4.26f1
Hello dear friends!
I have a simple app with rooms. Master creates room, client can join room, client can leave room. If master leaves room client leaves room too. Its ok, its working. (for example Master - UnityEditor, client - AndroidBuild).
When the master creates a room, an callbacks OnRoomListUpdated is triggered for the client correctly.
But if client in lobby and he disconnected from server, then he connected to server, all callbacks is working correctly (OnConnectedToMaster, OnJoinedLobby e.t.c) its ok.
Debug.Log("Client IsConnected = " + PhotonNetwork.IsConnected);
Debug.Log("Client InLobby = " + PhotonNetwork.InLobby);
These logs are true when client reconnected.
But now, if master creates room, client can't join because OnRoomListUpdated callback is not triggering.
Can anyone help or know some reasons of this problem?
Here is a link to video of my problem (at the end of video I restarted WI-FI): https://youtu.be/wkDFxIMfzH8
Master and client had different AppVersion.
Mistake in my code. This part of code I wrote in Awake, but had to write this in callback OnConnectedToMaster
PhotonNetwork.GameVersion = Application.version;

Connecting to janus server always hangs with hangup message from janus

I have problem connecting to janus janus.plugin.videoroom plugin from iOS device using swift.
Although every steps take place correctly but janus server send following message:
{
"janus": "hangup",
"session_id": 3201104494179497,
"sender": 7759980289270843,
"reason": "ICE failed"
}
and disconnect.
Debugging the messages of connecting to janus leads me to following:
1- RTCIceGatheringState never changes to Completed
2- The generated candidates are like following:
candidate:3215141415 1 udp 1686052607 w.x.y.z 57168 typ srflx raddr w.x.y.z rport 57168 generation 0 ufrag 340a network-id 1 network-cost 10
as you can see video and audio words are replaced by 1 and 0 respectively in the generated candidate.
Do you have any idea about these two observations!
And why janus send the "ICE failed" message?
I found that the reason of getting "hang up" message is because I did not set the received jsep (from janus) to my peerconnection.
after setAnswer the jsep "hang up" message gone!
1- RTCIceGatheringState never changes to Completed
For the problem of not having "Completed" state For RTCIceGatheringState was because of "continualGatheringPolicy" options in configuring the peerConnection which was set to "gatherContinually" after setting that to "gatherOnce" the Completed state seen! :)
2- The generated candidates are like following:
It seem this is normal to have audio/video or 0/1

How to Listen events in node-red - hyperledger composer

I have deployed my business network using node-red and local composer over fabric. I would like to listen to an event in node-red. I am able to submit the transaction successfully but not able to see the notification emitted by event in the same transaction on debug console in node-red.
composer nodes are latest and Composer is 0.16v. Event url port is 7053. I have attached two images below.
Transaction Submitted - shipmentreceived. When the transaction processor function is executed for this transaction, event is emitted as mentioned below:
var basicEvent=getFactory().newEvent('org.acme.shipping.perishable','ShipmentNotification');
basicEvent.shipmentStatus = shipment.status;
emit(basicEvent);
Model File:
event ShipmentNotification{
o String shipmentStatus
}
Node-red - Submitting and Listening event
This could be error
see https://medium.com/#CazChurchUk/integrate-your-blockchain-with-anything-using-hyperledger-composer-and-nodered-4226676f7e54
it needs to be updated to use 'business network cards' not 'profiles' in the NodeRed node widgets / flow, but the same principle applies where subscribing to events are concerned.

iOS & Safari 11 WebRTC does not gather STUN/TURN Trickle ICE Candidates

My web application is failing to gather WebRTC relay ICE candidates via a CoTURN server when using Safari 11 on iOS 11 (iPhone 5s & iPhone 7) or desktop. The web application (which establishes a one-way audio only WebRTC peer connection) works fine between the real browsers (Chrome and Firefox) either direct or via CoTURN relay, and I normally get 6-15 ICE candidates on these browsers.
I have a (frankly, unnecessary) call to getUserMedia on the receiving side, which allows host ICE candidates to be produced by Safari. (Note... the user must approve audio and/or video access before Safari will provide host Ice Candidates, even if on a receiving-only end. I'm past that hurdle, but just so you won't hit it too... This is out of "privacy" concerns.). Before I added the allow getUserMedia, I received no ICE. Now I receive two candidates. One with a private IPv4 and another with an IPv6. This is enough to get the app working properly when on the same machine or local network. So I'm pretty confident with other parts of the application code. I am not sure if my problem is with the application code or the CoTURN server.
Example of the ICE candidates received:
{"candidate":{"candidate":"candidate:622522263 1 udp 2113937151 172.27.0.65 56182 typ host generation 0 ufrag r23H network-cost 50","sdpMid":"audio","sdpMLineIndex":0,"usernameFragment":"r23H"}}
I pretty sure the RTCIceServer Dictionary for my RTCPeerConnection is inline with the following standards:
https://w3c.github.io/webrtc-pc/webrtc.html
https://www.rfc-editor.org/rfc/rfc7064
https://www.rfc-editor.org/rfc/rfc7065
And I've tried multiple variations of parameters:
// For Example:
var RPCconfig = {
iceServers: [{
urls: "turn:Example.live",
username: "un",
credential: "pw"
}]
};
// Or:
var RPCconfig = {
iceServers: [{
urls: "turns:Example.live",
username: "un",
credential: "pw",
credentialType: "password"
}, {
urls: "stun:Example.live"
}]
};
// And even more desperate attempts...
var RPCconfig = {
iceServers: [{
urls: "turn:Example.live?transport=tcp",
username: "un",
credential: "pw",
credentialType: "password"
}]
};
Here's an example of the signaling process log for an idea of what is going on. This is from the receiving side, which is Safari 11. The other browser was Chrome (compare 6 vs 2 ICE candidates). The state change refers to oniceconnectionstatechange.
SDP Offer received.
Sending signal SDP
Sending signal IceCandidate
Sending signal IceCandidate
ICE Candidate Received
4:08:25 AM State Change -> checking
ICE Candidate Received
ICE Candidate Received
ICE Candidate Received
ICE Candidate Received
ICE Candidate Received
4:08:40 AM State Change -> failed
CoTURN is configured quite liberally in terms of accepting every possible transport method as far as I am aware. It works well for providing ICE Candidates and as a relay for the other browsers.
Any direction would be greatly appreciated. Even if it is just a sample RTCIceServer Dictionary code that works or a proven TURN server to try.

Cooja - How to assign different services to a mote/node?

I need to create a network of 10 motes. I want each mote to provide 3 services with s1 = 0.25, s2 = 0.5 and s3 = 0.025. Also, I want to identify / select selfish / malicious mote(s).
Any help will be highly appreciated.
A solution to this should not be complicated to write yourself but I guess you can look at using the service registration and dissemination hack (servreg-hack) application in contiki. The operation of the application is very simple, all the application does is enable nodes to advertise services that they offer by broadcasting a SERVICE_ID (which is just an unsigned 8-bit integer). When a another node in the vicinity of the broadcasting node receives a message it stores the SERVICE_ID and the address of the node that sent the message. If the node needs a service, it can then just look up the address of a node that offers the service by calling the servreg_hack_lookup function.
The unicast-sender and unicast receiver applications in the examples section of the contiki distribution (Contiki/examples/ipv6/simple-udp-rpl) use servreg_hack.
So on both nodes you would initialise the servreg app by calling
servreg_hack_init();
then on the service provider you would register a service by calling
servreg_hack_register(SERVICE_ID, service_provider_ip_addr);
this service would then be received and registered on the service user node. The service user would can then call
service_provider_ipaddr = servreg_hack_lookup(SERVICE_ID);
to get the address of the node that provides the service identified by SERVICE_ID.

Resources