Hive Offline again?

One of the joys of the British Gas Hive system is the scheduling of heating & water. However, it me install has a particular tendency to just stop working. This is a problem because you don’t get any real warning apart from a freezing cold shower. Since this has just happened to me for the 3rd time in a year (twice in as many weeks) I thought I’d write down my guide to getting it online again. This is just for me, you should obviously phone the Hive helpline and NOT follow these instructions.

    Look at the Hive Hub controller (probably next to your boiler). If it’s got a big red light on then; ensure no other functions are on, i.e. no green lights on heating or water. Turn the hub off, wait a second or two, turn it back on again. For me this is fuse-style switch.
    Now go to your graphical thermostat and press the knob in. If it says, “no signal” then take it near to the Hub Controller (see 1). Take a battery out of the thermostat, wait a second or two, put the battery back in. Press the centre knob again, you should now have a signal.
    Log on to your Hive App or the online web site. If the heating & water are still saying offline then go to the Hive Hub next to your router. Turn that off, wait a second or two and back on again. Wait for the green light to settle down. Once it has then you just have to wait about 15 mins. If you are using the App you may have to also kill that off and restart it (not just move away from it, you need to kill it). Hopefully it will be back online. If not, you’ll have to call the Hive help line.
Advertisements
Posted in Uncategorized | Leave a comment

MS Load Test – System.IO.IOException Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

Today I was tearing my hair out trying to figure out why my Web Performance Tests were not playing back correctly. Each run stubbornly displayed, ‘System.IO.IOException Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host’. Turns out that the WebTestRequest wasn’t issued with the correct https protocol. My fix for now is to place the following in the WebTest constructor;

 
public WebTestCoded()
{
     this.PreAuthenticate = true;
     this.Proxy = "default";
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
}
Posted in Uncategorized | Leave a comment

Forcing Specflow to generate files using a specific version

I recently ran into annoying problem with the lovely Specflow. The latest Visual Studio Extension for Specflow was version 1.x. That shouldn’t be very important as each individual project installs all the juicy code via Nuget packages, in my example version 2.x. In theory you should be able to create a new feature file and the 1.x Extension should use the 2.x code generator. This is especially important as 2.x now uses a later version of NUnit where 1.x still uses older unsupported attributes. To put it another way, if you want to use the latest version of NUnit then you need to be using the latest version of the Specflow code generator. The problem is that every now and again the 1.x Extension becomes confused and reverts back to using the 1.x generator. This causes the build to fail, and worse still you typically have to restart Visual Studio before it magically decides to use the 2.x generator…ARRGH!

Fortunately not all is lost. When the Extension starts it looks into the App.Config for various settings, one of which is the path to the generator is should use. So be explicit;

<specFlow>
    <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
    <generator
       allowDebugGeneratedFiles="false"
       allowRowTests="true"
       generateAsyncTests="false"
       path="<your path>\packages\SpecFlow.2.2.1\tools" />
  </specFlow>
Posted in Uncategorized | Leave a comment

Using SQL Server OpenJson with Code First Entity Framework

SQL Server’s OpenJson function is a really nice way to expose data hidden in a SQL column as JSON. Without going into the ethical arguments I have found it very useful. Today I was faced with combining it with Entity Framework Code First, or to put it another way, how do you expose the OpenJson functionality to IQuerable Linq? Here is a quick workaround (read hack), use a view.

1. Create a View to wrap your JSON e.g.;

CREATE VIEW MyJsonView AS
SELECT M.*, J.*
FROM MySqlTable M  
CROSS APPLY OPENJSON(M.MyJson)   
     WITH (Id int '$.Id', 	 
	 Name nvarchar(255) '$.Name'
	 )  
     AS J

2. Jump through a few CF hoops; USING SQL VIEWS WITH ENTITY FRAMEWORK CODE FIRST
3. You can now access the JSON that’s exposed via the View.

Posted in Uncategorized | Leave a comment

Honda Civic 2008 – Inertia Switch

A non-tech post, today our 2008 Honda Civic wouldn’t start and the dash lit up with VSA and Engine Warning lights. Whilst getting in the car the dash got a bang with a knee. The car decided it was in an accident and activated the Inertia Switch to stop the petrol flowing. Locating the switch was a pain in the rear. For a 2008 UK Honda Civic, you have to open the driver door, remove the vertical dash panel that sits next to the door (the other side of the wing-mirror) but on the main dash. With that removed you can reset the Inertia Switch. Hopefully the car will then start and you won’t have broken any plastic panel retainers.

Posted in Uncategorized | Leave a comment

Simple animated carousel in CSS3 via keyframes

I had a little delve into CSS3 Animations to see if I could create a simple carousel. My first idea is to use keyframes. I’ll start with showing the result;
AnimExample

The idea is to infinitely fade between 3 elements.

<body>
    <div class="a isanim">AAAA</div>
    <div class="b isanim">BBBB</div>
    <div class="c isanim">CCCC</div>
</body>

The core style is;

 div.isanim {
            width:  250px;
            height: 250px;
            border: 3px solid black;
            position: absolute;            
            animation-duration: 18s;
            animation-direction: normal;
            animation-iteration-count: infinite;            
            display: block;
            opacity: 0
        }

What that says is we’re going to run an animation for a total of 18 seconds and then repeat it infinite times. Easy enough. Now for the bit that I didn’t think was too obvious;

        div.a {            
            animation-name: ani1;
            animation-delay: 0s;         
        }

        div.b {
            animation-name: ani2;
            animation-delay: 6s;            
        }

        div.c {
            animation-name: ani3;
            animation-delay: 12s;            
        }

We overwrite the core animation by providing specific details. The one I think is strange is that animation-delay is within the overall animation time. I.e. we’ve defined three animations all taking 18 seconds in total INCLUDING the delay. Is that correct? Is it, honestly I’m asking (?). Anyway with that in mind we can set up the keyframes;

        @keyframes ani1 {
            33% {
                background: green;
                opacity: 1;               
            }

            66% {
                display: none;
                opacity: 0
            }
        }

        @keyframes ani2 {
            0% {
                display: none;
                opacity: 0
            }

            33% {
                display: block;
                opacity: 1;
                background: red;
            }

            66% {
                display: none;
                opacity: 0;
            }           
        }

        @keyframes ani3 {
            0% {
                display: none;
                opacity: 0                
            }

            33% {
                display: block;
                opacity: 1;
                background: yellow;
            }

            66% {
                display: none;
                opacity: 0
            }           
        }

Since each animation has a proportional delay, the keyframes can all use the same % start. So after 33% they show themselves and after 66% they should have hidden themselves. I found these proportions worked better than 100% as that created too much of a clash of colours. One gotcha seems to be the 0% keyframe rule. If you don’t set that up you can get a strange ‘jumping’ effect.

Posted in Html, Uncategorized | Tagged , | Leave a comment

Event Grid – Filters with Custom Events

In End-To-End Custom Events I posted about how to create a .net publisher and a c# Azure Function to listen to the post. However, Event Grid comes with some additional tricks, one of these is Filters. To test this I created two additional Azure Functions, HttpTriggerCSharpOranges and HttpTriggerCSharpApples. For this example they are exactly the same bar the log text, here is the Orange variant, you can guess what the Apple one looks like 😉

using System.Net;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
    log.Info("C# HTTP trigger function processed an Orange request.");       

   // Get request body
   dynamic data = await req.Content.ReadAsAsync<object>();

   // Set name to query string or body data
   string subject = data[0].subject;
   log.Info(subject);

   return subject == null
                ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a subject on the query string or in the request body")
                : req.CreateResponse(HttpStatusCode.OK, "Hello " + subject);
}

The next step is to create the filtered subscriptions. The REST API pointed the way but it wasn’t that clear what I needed to define in AZ. So I entered;

az eventgrid topic event-subscription  create -h

That led to the following two filtered subscription definitions (remember to grab the Function URL by selecting the function ‘Copy Function URL’;

az eventgrid topic event-subscription create --name functionlisteneroranges --endpoint <function URL to oranges> -g gridResourceGroup --topic-name <your topic> --subject-begins-with oranges

az eventgrid topic event-subscription create --name functionlistenerapples --endpoint <function URL for apples> -g gridResourceGroup --topic-name <your topic> --subject-begins-with apples

All that’s left to do is to change the subject in the calling code to start with either apples or oranges;

new PaulsTopic
{
  Id = Guid.NewGuid().ToString(),
  EventTime = DateTime.UtcNow,
  EventType = EventType.recordInserted,
  Subject = "oranges\\paulstopics\\mytest",
  Data = new SomeData
  {
    Name = "Paul",
    Rate = 99.9
   }
}

Now when you run, the subscription pushes the correct message to the correct listener. Nice 🙂

Posted in Azure, Uncategorized | Tagged , | Leave a comment