Skip to content

Instantly share code, notes, and snippets.

View elden1337's full-sized avatar
🥬

Magnus Eldén elden1337

🥬
  • Gothenburg, Sweden
  • 18:36 (UTC +02:00)
  • X @elden1337
View GitHub Profile
@elden1337
elden1337 / peaqev_vs_all.py
Created July 19, 2023 20:16
Peaqev total costs vs other types of smart charging
prices = [0.34, 0.34, 0.32, 0.33, 0.36, 0.38, 0.5, 0.57, 0.58, 0.57, 0.56, 0.54, 0.52, 0.51, 0.51, 0.52, 0.54, 0.57, 0.59, 0.61, 0.61, 0.6, 0.58, 0.52]
allowed_peak = 3 #how much is set in peaqev
other_consumption = 1.2
charged_kwh = 200
charge_days = 20
max_total_charge = 11
peak_price = 36.25 #gothenburg
#---------------------------------------
per_diem = charged_kwh / charge_days
average_price_month = sum(prices) / len(prices)
@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%}
@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 / 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
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 / 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 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 / 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 / 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 / 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;