This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Startup | |
| { | |
| readonly string MyAllowSpecificOrigins = "randomPolicyNameUsedForTestingPurposes"; //the name doesn't matter | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.AddCors(options => | |
| { | |
| options.AddPolicy(name: MyAllowSpecificOrigins, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static async Task Main(string[] args) | |
| { | |
| var resultUrl = await StartAnalyzingImage(); // defined here https://gist.github.com/thewindev/a3a06af46693b890e968fbf810d2b50d | |
| IdentificationResult result; | |
| do | |
| { | |
| await Task.Delay(1000); // wait 1 second before checking, otherwise the API will return 429 | |
| var json = await _client.GetStringAsync(resultUrl); | |
| result = JsonConvert.DeserializeObject<IdentificationResult>(json); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Sends an image to Form Recognizer and returns back the URL that contains the result | |
| /// </summary> | |
| /// <returns></returns> | |
| private async Task<string> StartAnalyzingImage() | |
| { | |
| var queryString = HttpUtility.ParseQueryString(string.Empty); | |
| var client = _httpClientFactory.CreateClient(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{ | |
| "id": "dc813b26.76fc98", | |
| "type": "subflow", | |
| "name": "Identify office person", | |
| "info": "", | |
| "category": "", | |
| "in": [{ | |
| "x": 20, | |
| "y": 160, | |
| "wires": [{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{"id":"b6e164fe.1d31e8","type":"subflow","name":"Galaxy S9 notification","info":"","category":"","in":[{"x":100,"y":80,"wires":[{"id":"af896d84.97285"}]}],"out":[{"x":600,"y":80,"wires":[{"id":"fe75d18.e659d3","port":0}]}],"env":[{"name":"message","type":"str","value":""},{"name":"title","type":"str","value":""}],"color":"#A5C13D","icon":"font-awesome/fa-mobile-phone"},{"id":"fe75d18.e659d3","type":"api-call-service","z":"b6e164fe.1d31e8","name":"Send notification","server":"8501408e.93b69","version":1,"debugenabled":true,"service_domain":"notify","service":"mobile_app_galaxy_s9","entityId":"","data":"msg.data","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":430,"y":80,"wires":[[]]},{"id":"af896d84.97285","type":"function","z":"b6e164fe.1d31e8","name":"","func":"var message = env.get(\"message\") || msg.message || global.get('GalaxyS9Message');\nvar title = env.get(\"title\") || msg.title || global.get('GalaxyS9Title');\n\nmsg.data = {\n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const globalHomeAssistant = global.get('homeassistant'); | |
| var html = msg.payload; | |
| var attributeName = "efficiency_percent"; | |
| var start = html.indexOf(attributeName); | |
| var attr = html.substr(start + attributeName.length + 2, 5); | |
| msg = {}; | |
| msg.attr = attr; | |
| msg.start = start; | |
| msg.productivity = parseInt(attr.replace(/\"/g, "").trim()); | |
| var previousScore = parseInt(globalHomeAssistant.homeAssistant.states["sensor.productivity_score"].state); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type: custom:auto-entities | |
| card: | |
| type: entities | |
| filter: | |
| include: | |
| - entity_id: /last_detected/ | |
| exclude: | |
| - entity_id: "*0x*" | |
| sort: | |
| method: attribute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| office_position: | |
| friendly_name: "Office position" | |
| value_template: >- | |
| {% if states.binary_sensor.chair.state == 'on' %} | |
| Standing up | |
| {% else %} | |
| Sitting down | |
| {% endif %} | |
| icon_template: >- | |
| {% if states.binary_sensor.chair.state == 'on' %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Get-ChildItem -include bin,obj,packages,'_ReSharper.Caches','.vs' -Force -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse -ErrorAction SilentlyContinue -Verbose} | |
| # Found on StackOverflow: https://stackoverflow.com/a/42762639/1091894 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type: conditional | |
| conditions: | |
| - entity: sensor.apartment_power_total | |
| state_not: "off" | |
| card: | |
| type: vertical-stack | |
| cards: | |
| - type: custom:auto-entities | |
| card: |