Skip to content

Instantly share code, notes, and snippets.

View elden1337's full-sized avatar
🥬

Magnus Eldén elden1337

🥬
View GitHub Profile
@elden1337
elden1337 / booli.cs
Last active May 27, 2021 06:36
Basic implementation of the Booli API rest-service using C#
using RestSharp;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
namespace api.Services
{
public class BooliServices
@elden1337
elden1337 / polymergetester.cs
Last active January 8, 2018 09:06
C# polygon parallell-merge tester
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using SqlServerTypes;
using Microsoft.SqlServer.Types;
using System.Data.SqlTypes;
using System.Threading;
@elden1337
elden1337 / pantbrevskalkylator.cs
Created January 8, 2018 09:09
Swedish pawn-letter calculation for house purchases.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pantbrevskalkylator
{
class Program
{
@elden1337
elden1337 / minimalenclosingcircleradius.cs
Last active January 18, 2018 13:19
Quick calc to determine centerpoint and radius of circle enclosing a bounding box (helper to query Redis geospatial data)
using System;
using Microsoft.SqlServer.Types;
using System.Data.SqlTypes;
namespace circleradius
{
class Program
{
static void Main()
{
@elden1337
elden1337 / automations.yaml
Created May 27, 2021 06:45
Example automation to set chargeamps Halo to activate through ios-notification and Home Assistant (and turn off when charging is done). Added layer of security for owners without the rfid-card needed.
- id: '1234567'
alias: Chargeamps - Charger connected
description: ''
trigger:
- platform: state
entity_id: sensor.chargeamps_phasesocket
from: Available
to: Connected
condition: []
action:
@elden1337
elden1337 / configuration.yaml
Created May 27, 2021 06:54
brightness helper to slowly (linear) dim the lights from 17:00 - 20:00 and then inverted exponential until 23:00. Use in automations to call light.turn_on in Home Assistant.
- platform: template
sensors:
lightbrightness:
friendly_name: 'light brightness - helper'
unit_of_measurement: '%'
value_template: >
{% if now().hour > 16 and now().hour < 23 %}
{% set timer = now().minute+((now().hour-17)*60) %}
{% set const = 1.01452 %}
{% set hourdivider = ((now().hour/20)-0.45)|round(0) %}
@elden1337
elden1337 / automations.yaml
Created June 7, 2021 11:45
Circadian lighting calculator fit for Scandianvian countries.
- id: '12345'
alias: Light - Circadian lights
description: ''
trigger:
- platform: time_pattern
minutes: /10
condition:
- condition: template
value_template: '{{ states.light|selectattr(''state'',''eq'',''on'')|list|count
> 0 }}
@elden1337
elden1337 / automations.yaml
Last active April 30, 2022 23:31
Nibe automations for Home Assistant.
- id: '1616449993366'
alias: Nibe - COP increase
trigger:
- platform: time
at: '11:00'
- platform: time
at: '12:00'
- platform: time
at: '12:30'
- platform: time
@elden1337
elden1337 / automations.yaml
Last active September 4, 2022 17:51
Price color light (philips hue and nordpool)
- id: '1234567890'
alias: Light - Price color
trigger:
- platform: time_pattern
hours: /1
seconds: '5'
condition: []
action:
- service: light.turn_on
data:
@elden1337
elden1337 / sensors.yaml
Last active March 2, 2023 10:07
Home assistant sensors to show cheapest average period
#requires Nordpool integraiton through HACS
- platform: template
sensors:
next_dryer:
value_template: >
{%set duration = 3%}
{%set ret_dict = namespace(value = []) %}
{%set grow = namespace(value=0)%}
{%set prices = state_attr('sensor.nordpool_kwh_se3_sek_3_10_025','today')|list%}
{%set tomorrow = state_attr('sensor.nordpool_kwh_se3_sek_3_10_025','tomorrow')|list%}