Add Hue lights by serial no

It can be a pain to add new devices to Philips Hue – it takes quite some time and sometimes, it does not seem to want to work – even with “touchlink”.

Anyhow, it is always nice to have an alternative, and in the Hue app, you can also add devices by serial-number. But how does this work with the Hue API?.

This Reddit page suggest you can add lights using the Hue API by sending

{“deviceid”:[“SN”,”SN”,”SN”,”SN”,”SN”,”SN”,”SN”,”SN”,”SN”,”SN”]}

with most likely PUT (but it may be POST)

it is not clear, which object the json should be PUT to


This page says that you can POST this Json
{“deviceid”: “light_id”}
(…where light_id is the serial number printed on the side of the Hue bulb.) to this object
/api/[hash]/lights


drashsmith.com


After a little trial-and-error, I get an error if I try to either PUT or POST on the root object (ie http://[ip-address]/api/[username]) saying that neither PUT nor POST were accessible on this object.
PUT was also not accessible on the “lights” object, but when trying to POST “{“deviceid”:[“SN1″,”SN2″]}” to the lights object (http://[ip-address]/api/[username]/lights), I got this reply

[
{
“error”: {
“type”: 7,
“address”: “/lights/deviceid”,
“description”: “invalid value, SN1, for parameter, deviceid”
}
}
]

which seems to suggest, that the serials for new devices should be POST’ed to the “lights” object. When I try to post the same Json to the “sensors” object, I get the same error, but I am not sure, that you can use the same method for the “sensors” object – I cannot seem to find serials on my sensors.

Happy hunting.

[srs_total_visitors]

Why does SQLPlus not execute my command-file

Oracle SQLPlus is an effective tool, but sometimes it has some hard-to-explain behavior.

Like when you try to get it to replace an existing view, and all that happens, is that it very patiently does – nothing at all.

There are several possible reasons – where SQLPlus has requirements that other SQL tools (like Toad) does not have.

http://www.vertabelo.com/blog/notes-from-the-lab/blank-lines-in-sql-plus

  1. Blank lines prevent the execution of a command in SQL*PlusA blank line in a SQL statement or script tells SQL*Plus that you have finished entering the command, but do not want to run it yet.If you’re writing or generating SQL scripts for SQL*Plus, make sure there are no blank lines in your SQL commands or the statements will not be executed.

    This only seems to be required for views. Packages are executed even if they contain some blank lines

  2. Package replace script must end with a “/”

[srs_total_visitors]

Cannot resolve the ‘schemaLocation’ attribute

Biztalk are often quite troublesome with XSD schema imports

I had recently the problem with the Italian PA-Xml format, which imports the standard w3 xmldsig schema

When working with schema imports in Biztalk, it is not uncommon to receive the error “Cannot resolve the ‘schemaLocation’ attribute”, which simply means, that Biztalk cannot load the imported schema.

There are several possible reasons for this error:

  • The schema location is an URL. I have never yet seen an imported schema work in Biztalk if the schemalocation is an URL. Download the imported schema, include it in the project and modifiy the schemalocation to point to the local file
  • In the “xsd:import” element, the namespace attribute are listed before the schemalocation attribute. Biztalk seems to prefer that the schemalocation attribute is listed first
  • When modifying the schemalocation to point to a local file (same directory as the .XSD file), Biztalk sometimes prefer if you put “./” before the filename of the imported schema

I have yet not found a clear rule for when to do what – except that an URL in the schemalocation will never work.

With the Italian PAXml format, neither of these points work. Whatever I did, Biztalk kept informing me, that it “could not resolve the schemalocation” attribute.

What worked for me, was to create a folder in the Biztalk Schema project, and place the PAXml schema as well as the xmldsig schema in this folder. This folder in the project, does not have any practical impact when using this schema. When I did this, the schema project compiled without problems.

References:

https://social.msdn.microsoft.com/Forums/en-US/7ae8ac29-7f60-447b-8e4e-a470dd21e259/cannot-resolve-the-schemalocation-attribute?forum=biztalkgeneral

Biztalkmessages.wordpress.com

[srs_total_visitors]

New SFTP adapter in Biztalk 2016

WCF WinSCP-based SFTP Adapter

Since Microsoft now supplies a SFTP Adapter with Biztalk Server 2016, we thought we might as well try it out instead of using the Blogical one (which we have had several problems with).

It is relatively straightforward to use it in static sendports and receivelocations – the only thing we miss, is a possibility to use temporary filenames during transmission, which it does not support – only temporary folders.

However, it does not seem to be documented how to use the adapter in a dynamic sendport (at least, we have been unable to find it)

As documented, the SFTP Adapter uses the WinSCP program to do its actual work and specifically, it requires the WinSCPnet.dll to do its work.

Microsoft have implemented the WCF adapter in this DLL which wraps the calls to WinSCP.

C:\Program Files (x86)\Microsoft BizTalk Server 2016\Microsoft.BizTalk.Adapter.Sftp.dll – Assembly version 3.0.1.0

The Adapter loads the WinSCPnet DLL in the class SftpHelper.

The dynamic properties can be found in the class SftpOutputChannel Method AddPropertiesFromMessageContext.

Context Property Description
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ClientAuthenticationMode this.sendPropertyBag.ClientAuthenticationMode = (ClientAuthenticationMode) Enum.Parse(typeof (ClientAuthenticationMode), property.Value.ToString());

enum Password, PublicKeyAuthentication, MultiFactorAuthentication

http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#UserName Either specify UserName and Password, or specify a keyfile in PrivateKeyFile
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#Password Password
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#PrivateKeyFile Full path to Private Key
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#PrivateKeyPassword Password to the private key, if it is password protected
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#AccessAnyServerHostKey If False, host fingerprint must be specified. If True, all hosts will be accepted
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#SSHServerHostKeyFingerPrint Specify the fingerprint of SSH servers HostKey, if “AccessAnyServerHostKey” is False
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#AppendIfExists If False, transfer will fail if a file with the filename already exists. If True, the contents will be appended to the existing file

We have not been able to make the “AppendIfExists” work. If this property is true, the adapter issues a get command for the filename, and if the file does not exist yet (first transfer), then the transmission fails.

http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#TargetFileName The name of the file created on the SFTP server. You can use the macros specified below
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#TemporaryFolder this.sendPropertyBag.TemporaryFolder = property.Value.ToString();
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyAddress Address of a proxy-server, if you need to use one, or blank.
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyUserName Username and password for the proxy-server, or blank if they are not needed
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyPassword
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyPort Port for the proxy-server
http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#ProxyType this.sendPropertyBag.ProxyType = (Microsoft.BizTalk.Adapter.Sftp.ProxyType) Enum.Parse(typeof (Microsoft.BizTalk.Adapter.Sftp.ProxyType), property.Value.ToString());

enum None, SOCKS4, SOCKS5, HTTP

http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#EncryptionCipher this.sendPropertyBag.EncryptionCipher = (EncryptionCipher) Enum.Parse(typeof (EncryptionCipher), property.Value.ToString());

enum Auto, AES, Arcfour, BlowFish, TripleDES, DES

http://schemas.microsoft.com/BizTalk/2012/Adapter/sftp-properties#Log this.sendPropertyBag.Log = property.Value.ToString();
http://schemas.microsoft.com/BizTalk/2003/system-properties#OutboundTransportLocation Contains the full EndPointAddress of the server – on the form sftp://servername:port

this.ParseSftpUrl(property.Value.ToString());

OutboundTransportLocation needs to be ‘sftp’ (case insensitive compare)

Supported macros

Macro Value
Use fixed context-property
%MessageID% http://schemas.microsoft.com/BizTalk/2003/system-properties#BizTalkMessageID
%SourceFileName% http://schemas.microsoft.com/BizTalk/2003/file-properties#ReceivedFileName
Use the macro as the name of a context-property
Use the contextproperty with the namespace namespace http://schemas.microsoft.com/BizTalk/2003/system-properties# with the macroname (nix the percent-signs) appended
%DestinationParty%
%DestinationPartyQualifier%
%SourceParty%
%SourcePartyQualifier
These macros formats either DateTime.Now or DateTime.UtcNow in the specified format
%datetime% yyyy-MM-ddThhmmss
%datetime_bts2000% yyyyMMddhhmmssf
%datetime.tz% yyyy-MM-ddThhmmsszzz
%time% hhmmss
%time.tz% hhmmsszzz

Biztalk – Orchestrations gather up in status “Ready to run”

In a previous post, I wrote about a situation we encountered on our production Biztalk 2016 system.

After a series of not-Biztalk related issues (including the MSDTC service crashing), we ended up in a situation, where one of our orchestrations would not process any messages. Existing instances would not process, and new instances would only pile up in status “Ready to run”. NONE of them would change to status “Active”, even after restarting the hostinstance bound to that orchestration.

We could not see any hints anywhere (like eventlog on Biztalk- and SQL server, SQL-server locks or similar) as to why the orchestrations would not be processed.

We run a ESB-like architecture, and since that orchestration was part of the main ESB itinerary, no documents could in fact be fully processed.

In the end, we were able to get most the of the orchestration serviceinstances processed, by Suspending all the serviceinstances in status “Ready to Run” and then “Resubmit” them 1 or 2 at a time. If we took more than a few, the situation would lock up again, and we again would have to Suspend all and resubmit them a few at a time.

In the end we had 5 serviceinstances that simply would not process. These 5 were terminated (they were already saved in our Tracking) and after a hostinstance restart (that may not have  been necessary), the orchestration would once again process messages without problems.

Another suggestion we had to resolve this situation, was to remove and then recreate all hostinstances for the host which had problems. We did not try this method.

Extra permission needed for Biztalk File Adapter

If you try to pickup files with the standard Biztalk File Adapter, you will receive these two errors in the eventlog (and the Receive Location will disable) – even if you have givet it MODIFY access to the folder.

The Messaging Engine failed to add a receive location "RL_Test_EDIFACT" with URL "C:\FileDrop\Test\EDIFACT\*.edi" to the adapter "FILE". Reason: "File transport does not have read/write privileges for receive location "C:\FileDrop\Test\EDIFACT\". ".

followed by

The receive location "RL_Test_EDIFACT" with URL "C:\FileDrop\Test\EDIFACT\*.edi" is shutting down. Details:"The Messaging Engine failed while notifying an adapter of its configuration. ".

That is because the Biztalk File Adapter expects “Full Control” on the folders it reads from, but if that is not possible, you can also just add a single extra permission

https://social.technet.microsoft.com/wiki/contents/articles/7008.biztalk-file-adapter-permission-issue-workaround.aspx

Apart from MODIFY access, add the “Delete Sub Folders and Files” Advanced permission to enable the Biztalk File Adapter to read files

Required NTFS permissions for BizTalk File Adapter connecting to network share

Firmware extraction

Just found this site which discusses methods to extract firmware.

ianhowson.com

Could be interesting to try it out on a Maginon socket, but the relevant chip seem to be located on the backside and is thus not accessible without destroying a plug

Maginon SP-2 plug
Maginon SP-2 plug

If one is able to download the firmware from the supplier, it is much
easier

Biztalk 2016 / SQL Server 2016 – MAXDOP and MSDTC port range

At my dayjob, we have a sizable Biztalk installation. We are currently running Biztalk 2016 / SQL Server 2016, and it ran well for half a year or so.

But, some months ago, we started getting deadlocks in the MessageBox database, causing substantial problems.

We are currently running a Microsoft case (of the “Production down” sort), and in that case we have learned, that at least two things, that seem to be an “accepted” way to setup biztalk, may not be supported by Microsoft.

Setting up MSDTC with a limited port range
https://www.biztalkadmin.com/firewall-and-msdtc/

Setting up MAXDOP on the SQL-server, on the database-level instead of the instance-level (this has only been possible since SQL Server 2016):

https://www.codit.eu/blog/2017/11/sql-server-2016-max-dop-at-database-level/

vs. the official MS guide (which is clearly written with regards to sql-server versions before 2016):
https://docs.microsoft.com/en-us/biztalk/technical-guides/sql-server-settings-that-should-not-be-changed

Question regarding MAXDOP:
I think the Biztalk Health Monitor tool is only checking the MAXDOP value on the Instance-level. While the instance-level MAXDOP value is indeed set to 4, The MAXDOP has been set to 1 on the Messagebox database
As far as we can read, only the MessageBox requires MaxDOP 1. Do you see a problem with doing it this way?
MS Answer:
We use TempDB a lot in our queries and we have never tested with this configuration only per database so please change the SQL instance also so we make sure TempDB and other system databases are running ok as well.

MS comment with regards to the limited port range for MSDTC:
I see you have a very tight range of ports. This is not recommended. I would recommend to use full range of ports and instead do firewall on IPs instead of ports to not block BizTalk/SQL batches:
Ports range A range of TCP ports have been specified: 5000-5100
The default is 49152-65535 (around 16000 ports) . we increased from Windows 2003 which only had 4000 ports (1024-5000) up to the new range. Also if a range is needed it is recommended to use high range to not interfere with lower known ports, e g 20000 and higher range.

I should point out, that the reason for these deadlocks in MessageBox is still not determined. The system after all ran well with the database-specified MAXDOP and limited MSDTC port range for half a year or so.

For the MAXDOP setting, we are currently considering reversing the current setup – ie. setting the MAXDOP to 1 on the SQL instance and to a specific MAXDOP on our custom databases, which should satisfy Biztalks demand.